The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
TypeScript b2b-marketplacecomposable-commerceecommerceenterpriseheadless-commercemarketplacemedusamedusajsmulti-vendortypescript
feat(vendor): customizable onboarding wizard with live handle check (#1658)
Viktor Holik8a40aa230c5f
diff --git a/apps/docs/references/panel-extensions/custom-fields.mdx b/apps/docs/references/panel-extensions/custom-fields.mdxindex a7a8c2a2d..2f92bf4b1 100644--- a/apps/docs/references/panel-extensions/custom-fields.mdx+++ b/apps/docs/references/panel-extensions/custom-fields.mdx@@ -134,6 +134,60 @@ Each field is a `CustomFormField`.onto the product's `metadata`.</Warning>+## Customize the onboarding wizard++The vendor onboarding wizard is the `onboarding` form zone of the `seller` model. Each step is a `tab`. Use the same `forms` entries to add fields to a step, add a step, remove a step, or reorder the steps.++```tsx apps/vendor/src/custom-fields/seller.tsx+import { defineCustomFieldsConfig } from "@mercurjs/dashboard-sdk"+import { createFormHelper } from "@mercurjs/dashboard-shared"++const form = createFormHelper()++export default defineCustomFieldsConfig({+ model: "seller",+ forms: [+ // Add fields to a built-in step+ { zone: "onboarding", tab: "address", fields: { region_note: form.define({ validation: form.string().optional() }) } },+ // An unknown tab becomes a new step+ {+ zone: "onboarding",+ tab: "documents",+ label: "Documents",+ rank: 25,+ optional: true,+ fields: {+ vat_document_url: form.define({ validation: form.string().url(), label: "VAT document URL" }),+ },+ },+ // Remove a built-in step+ { zone: "onboarding", tab: "company", disabled: true },+ ],+})+```++| Option | Type | Description |+| ---------- | --------- | ------------------------------------------------------------------------------------------------- |+| `label` | `string` | Step heading. Set it on every new step. |+| `rank` | `number` | Sort position. New steps without a rank go last. Also reorders a built-in step. |+| `optional` | `boolean` | Shows a **Skip** button. Set `false` on a built-in step to hide its Skip button. |+| `disabled` | `true` | Removes a built-in step. Takes no `fields`. The `store` step can't be removed. |++The built-in steps and their defaults:++| Step | `rank` | `optional` |+| --------- | ------ | ---------- |+| `store` | 10 | `false` |+| `address` | 20 | `true` |+| `company` | 30 | `true` |+| `payment` | 40 | `true` |++The last step's button reads **Finish** and creates the seller. Values from every step's custom fields are merged into one `additional_data` object on `POST /vendor/sellers`, which reaches the `sellerAccountCreated` hook of `createSellerAccountWorkflow`. A skipped step contributes nothing, even if its fields are required.++<Note>+ Always set `tab` on an onboarding entry. An entry without a `tab` renders its fields on every step.+</Note>+## Extend detail sectionsAdd, replace, or remove fields on a detail section, and add actions to its@@ -238,6 +292,36 @@ built-in ones.the field list. The `link` declaration drives it.</Warning>+## Combine configs from plugins and your app++Every config for a model applies in order: installed plugins first, then your+app's `src/custom-fields/` files. A later config sees everything earlier configs+added, not only the built-ins, so your app can change what a plugin contributed.++| Contribution | Matched by | A later config with the same id/key |+| --------------------- | ---------- | -------------------------------------------------------------------------- |+| `list.columns` | `id` | Replaces the column in place. Hide it with `columnVisibility: { id: false }`. |+| `list.filters` | `key` | Replaces the filter in place, or drops it with `remove: true`. |+| `displays[].fields` | `id` | Replaces the field in place, or drops it with `component: null`. |+| `forms[].fields` | field name | Replaces the field, including its `zone` and `tab`. |+| `columnVisibility` | column id | Overrides the earlier value for that column. |+| `columnOrder` | n/a | Replaces the earlier order. |++`link`, `bulkActions`, display `actions`, `activity`, and `actionLocks` add up+across configs.++```tsx+// src/custom-fields/product-brand.tsx: rework the plugin's "brand" column+export default defineCustomFieldsConfig({+ model: "product",+ link: "brand",+ list: {+ columns: [{ id: "brand", header: "Maker", component: ({ row }) => row.brand?.name }],+ filters: [{ key: "brand_id", remove: true }],+ },+})+```+## Fetch linked module dataDeclare `link` to fetch a module link alongside the entity. Its data rides on thediff --git a/apps/docs/resources/tutorials/extend-onboarding.mdx b/apps/docs/resources/tutorials/extend-onboarding.mdxindex 1c9dc36d1..222ca3744 100644--- a/apps/docs/resources/tutorials/extend-onboarding.mdx+++ b/apps/docs/resources/tutorials/extend-onboarding.mdx@@ -12,6 +12,10 @@ The vendor store-setup and onboarding surface is a widget zone, `seller.setup`,**Three layers, one flow.** The panel, a `seller.setup` widget, renders and collects. The vendor seller route carries the value through `additional_data` with no core schema change. A `sellersUpdated` workflow hook persists it. Each layer is additive: nothing built-in is replaced.</Info>+<Tip>+ To change the onboarding wizard itself (fields on any step, new steps, removed or reordered steps), use `forms` entries with `zone: "onboarding"`. See [Customize the onboarding wizard](/references/panel-extensions/custom-fields#customize-the-onboarding-wizard).+</Tip>+## What you buildA "Tax ID" prompt on the vendor store-setup surface. The vendor types a VAT number. It rides `additional_data` to `POST /vendor/sellers/:id`, and a workflow hook stores it durably through the [Custom Fields module](/rc/resources/customization/custom-fields).diff --git a/integration-tests/http/seller/vendor/seller-handle-availability.spec.ts b/integration-tests/http/seller/vendor/seller-handle-availability.spec.tsnew file mode 100644index 000000000..a7492b780--- /dev/null+++ b/integration-tests/http/seller/vendor/seller-handle-availability.spec.ts@@ -0,0 +1,105 @@+import { medusaIntegrationTestRunner } from "@medusajs/test-utils"+import { MedusaContainer } from "@medusajs/framework/types"+import { MercurModules } from "@mercurjs/types"+import { createSellerUser } from "../../../helpers/create-seller-user"++jest.setTimeout(50000)++medusaIntegrationTestRunner({+ testSuite: ({ getContainer, api }) => {+ describe("GET /vendor/sellers/handle-availability", () => {+ let appContainer: MedusaContainer+ let unregisteredHeaders: { headers: Record<string, string> }++ beforeAll(async () => {+ appContainer = getContainer()+ })++ beforeEach(async () => {+ await createSellerUser(appContainer, {+ email: "[email protected]",+ name: "Taken Store",+ })++ const { data } = await api.post(`/auth/member/emailpass/register`, {+ email: `onboarding-${Date.now()}@test.com`,+ password: "somepassword",+ })++ unregisteredHeaders = {+ headers: { authorization: `Bearer ${data.token}` },+ }+ })++ it("reports a free handle as available for a member without a seller", async () => {+ const response = await api.get(+ `/vendor/sellers/handle-availability?handle=brand-new-store`,+ unregisteredHeaders+ )++ expect(response.status).toEqual(200)+ expect(response.data).toEqual({+ handle: "brand-new-store",+ available: true,+ })+ })++ it("reports a handle used by an existing seller as taken", async () => {+ const response = await api.get(+ `/vendor/sellers/handle-availability?handle=taken-store`,+ unregisteredHeaders+ )++ expect(response.data).toEqual({+ handle: "taken-store",+ available: false,+ reason: "taken",+ })+ })++ it("reports a handle that is not URL safe as invalid", async () => {+ const response = await api.get(+ `/vendor/sellers/handle-availability?handle=Not%20Valid`,+ unregisteredHeaders+ )++ expect(response.data).toEqual({+ handle: "Not Valid",+ available: false,+ reason: "invalid",+ })+ })++ it("frees the handle of a soft-deleted seller", async () => {+ const sellerService = appContainer.resolve(MercurModules.SELLER)+ const [seller] = await sellerService.listSellers({+ handle: "taken-store",+ })+ await sellerService.softDeleteSellers([seller.id])++ const response = await api.get(+ `/vendor/sellers/handle-availability?handle=taken-store`,+ unregisteredHeaders+ )++ expect(response.data.available).toEqual(true)+ })++ it("rejects a missing handle", async () => {+ const error = await api+ .get(`/vendor/sellers/handle-availability`, unregisteredHeaders)+ .catch((e) => e)++ expect(error.response.status).toEqual(400)+ })++ it("rejects unauthenticated requests", async () => {+ const error = await api+ .get(`/vendor/sellers/handle-availability?handle=anything`)+ .catch((e) => e)++ expect(error.response.status).toEqual(401)+ })+ })+ },+})diff --git a/packages/cli/routes-manifest.json b/packages/cli/routes-manifest.jsonindex 0deddbda8..af53fec08 100644--- a/packages/cli/routes-manifest.json+++ b/packages/cli/routes-manifest.json@@ -545,6 +545,7 @@"/vendor/sellers/:id/members/me": "typeof import(\"@mercurjs/core/api/vendor/sellers/[id]/members/me/route\")","/vendor/sellers/:id/payment-details": "typeof import(\"@mercurjs/core/api/vendor/sellers/[id]/payment-details/route\")","/vendor/sellers/:id/professional-details": "typeof import(\"@mercurjs/core/api/vendor/sellers/[id]/professional-details/route\")",+ "/vendor/sellers/handle-availability": "typeof import(\"@mercurjs/core/api/vendor/sellers/handle-availability/route\")","/vendor/sellers/me": "typeof import(\"@mercurjs/core/api/vendor/sellers/me/route\")","/vendor/sellers/select": "typeof import(\"@mercurjs/core/api/vendor/sellers/select/route\")","/vendor/shipping-option-types": "typeof import(\"@mercurjs/core/api/vendor/shipping-option-types/route\")",diff --git a/packages/core/.mercur/routes.d.ts b/packages/core/.mercur/routes.d.tsindex 2666d7eb9..3c1b0cea1 100644--- a/packages/core/.mercur/routes.d.ts+++ b/packages/core/.mercur/routes.d.ts@@ -911,6 +911,7 @@ export type Routes = {};me: typeof import("../src/api/vendor/sellers/me/route");select: typeof import("../src/api/vendor/sellers/select/route");+ handleAvailability: typeof import("../src/api/vendor/sellers/handle-availability/route");};shippingOptionTypes: typeof import("../src/api/vendor/shipping-option-types/route") & {$id: typeof import("../src/api/vendor/shipping-option-types/[id]/route");diff --git a/packages/core/src/api/vendor/middlewares.ts b/packages/core/src/api/vendor/middlewares.tsindex d299c6f77..dfb941c0c 100644--- a/packages/core/src/api/vendor/middlewares.ts+++ b/packages/core/src/api/vendor/middlewares.ts@@ -67,7 +67,11 @@ const unauthenticatedRoutes = [// Marketplace-level routes: authenticated, but reachable before the member// belongs to a seller (onboarding). They authenticate through their own// matcher with `allowUnregistered: true`, so the catch-all must skip them.-const sellerlessRoutes = [...unauthenticatedRoutes, /^\/vendor\/stores$/]+const sellerlessRoutes = [+ ...unauthenticatedRoutes,+ /^\/vendor\/stores$/,+ /^\/vendor\/sellers\/handle-availability$/,+]const resolveSellerlessRoutes = async (req: MedusaRequest) => [...sellerlessRoutes,@@ -93,6 +97,15 @@ export const vendorMiddlewares: MiddlewareRoute[] = [}),],},+ {+ matcher: "/vendor/sellers/handle-availability",+ method: ["GET"],+ middlewares: [+ authenticate("member", ["session", "bearer"], {+ allowUnregistered: true,+ }),+ ],+ },{matcher: "/vendor/sellers/select",method: ["POST"],diff --git a/packages/core/src/api/vendor/sellers/handle-availability/route.ts b/packages/core/src/api/vendor/sellers/handle-availability/route.tsnew file mode 100644index 000000000..2e2a9d499--- /dev/null+++ b/packages/core/src/api/vendor/sellers/handle-availability/route.ts@@ -0,0 +1,38 @@+import {+ AuthenticatedMedusaRequest,+ MedusaResponse,+} from "@medusajs/framework"+import {+ ContainerRegistrationKeys,+ isValidHandle,+} from "@medusajs/framework/utils"+import { HttpTypes } from "@mercurjs/types"++import { VendorGetSellerHandleAvailabilityParamsType } from "../validators"++export const GET = async (+ req: AuthenticatedMedusaRequest<VendorGetSellerHandleAvailabilityParamsType>,+ res: MedusaResponse<HttpTypes.VendorSellerHandleAvailabilityResponse>+) => {+ const { handle } =+ req.validatedQuery as VendorGetSellerHandleAvailabilityParamsType++ if (!isValidHandle(handle)) {+ return res.json({ handle, available: false, reason: "invalid" })+ }++ const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)++ const { data: sellers } = await query.graph({+ entity: "seller",+ fields: ["id"],+ filters: { handle },+ pagination: { take: 1, skip: 0 },+ })++ res.json(+ sellers.length+ ? { handle, available: false, reason: "taken" }+ : { handle, available: true }+ )+}diff --git a/packages/core/src/api/vendor/sellers/middlewares.ts b/packages/core/src/api/vendor/sellers/middlewares.tsindex 7a0d7bc95..0507e8f07 100644--- a/packages/core/src/api/vendor/sellers/middlewares.ts+++ b/packages/core/src/api/vendor/sellers/middlewares.ts@@ -16,6 +16,7 @@ import { MiddlewareRoute } from "@medusajs/medusa"import * as QueryConfig from "./query-config"import {VendorCreateSellerAccount,+ VendorGetSellerHandleAvailabilityParams,VendorGetSellerParams,VendorGetSellersParams,VendorInviteMember,@@ -35,6 +36,13 @@ export const vendorSellersMiddlewares: MiddlewareRoute[] = [validateAndTransformBody(VendorSelectSeller),],},+ {+ method: ["GET"],+ matcher: "/vendor/sellers/handle-availability",+ middlewares: [+ validateAndTransformQuery(VendorGetSellerHandleAvailabilityParams, {}),+ ],+ },{method: ["GET"],matcher: "/vendor/sellers/me",diff --git a/packages/core/src/api/vendor/sellers/validators.ts b/packages/core/src/api/vendor/sellers/validators.tsindex 1d028f9c0..d7030123d 100644--- a/packages/core/src/api/vendor/sellers/validators.ts+++ b/packages/core/src/api/vendor/sellers/validators.ts@@ -16,6 +16,13 @@ export const VendorGetSellersParams = createFindParams({export type VendorGetSellerParamsType = z.infer<typeof VendorGetSellerParams>export const VendorGetSellerParams = createSelectParams()+export type VendorGetSellerHandleAvailabilityParamsType = z.infer<+ typeof VendorGetSellerHandleAvailabilityParams+>+export const VendorGetSellerHandleAvailabilityParams = z.object({+ handle: z.string().min(1),+})+export type VendorCreateSellerAccountType = z.infer<typeof CreateSellerAccount> & AdditionalDataexport const CreateSellerAccount = z.object({name: z.string(),diff --git a/packages/dashboard-sdk/src/__tests__/custom-fields.spec.ts b/packages/dashboard-sdk/src/__tests__/custom-fields.spec.tsnew file mode 100644index 000000000..f03c08829--- /dev/null+++ b/packages/dashboard-sdk/src/__tests__/custom-fields.spec.ts@@ -0,0 +1,68 @@+import fs from "fs"+import os from "os"+import path from "path"+import { afterEach, describe, expect, test } from "vitest"+import { generateCustomFields } from "../custom-fields"+import type { BuiltMercurConfig } from "../types"++const tmpDirs: string[] = []++const setup = async ({+ app = [],+ plugins = [],+}: {+ app?: string[]+ plugins?: string[][]+}) => {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "mercur-custom-fields-"))+ tmpDirs.push(root)+ const srcDir = path.join(root, "src")+ fs.mkdirSync(path.join(srcDir, "custom-fields"), { recursive: true })++ for (const id of app) {+ fs.writeFileSync(+ path.join(srcDir, "custom-fields", `${id}.ts`),+ `export default { model: "product", id: "${id}" }`+ )+ }++ const pluginExtensions = plugins.map((ids, i) => {+ const file = path.join(root, `plugin-${i}.ts`)+ const configs = ids.map((id) => ({ model: "product", id }))+ fs.writeFileSync(+ file,+ `export default { customFieldsModule: { configs: ${JSON.stringify(configs)} } }`+ )+ return file+ })++ const code = generateCustomFields({+ srcDir,+ pluginExtensions,+ } as unknown as BuiltMercurConfig)+ const out = path.join(root, "virtual-custom-fields.ts")+ fs.writeFileSync(out, code)++ const { configs } = (await import(out)).default as {+ configs: { id: string }[]+ }+ return configs.map((c) => c.id)+}++afterEach(() => {+ for (const dir of tmpDirs.splice(0)) {+ fs.rmSync(dir, { recursive: true, force: true })+ }+})++describe("generateCustomFields", () => {+ test("no configs yields an empty module", async () => {+ expect(await setup({})).toEqual([])+ })++ test("orders plugin configs before the host app's so the host applies last", async () => {+ expect(+ await setup({ app: ["host"], plugins: [["plugin-a"], ["plugin-b"]] })+ ).toEqual(["plugin-a", "plugin-b", "host"])+ })+})diff --git a/packages/dashboard-sdk/src/config/custom-fields.ts b/packages/dashboard-sdk/src/config/custom-fields.tsindex c8cc14209..12c95a11c 100644--- a/packages/dashboard-sdk/src/config/custom-fields.ts+++ b/packages/dashboard-sdk/src/config/custom-fields.ts@@ -68,15 +68,38 @@ export type CustomFormTab<TModel, TZone> =? ModelShape<TModel>["formTabs"][TZone]: string+/**+ * Onboarding wizard step settings, read only for `zone: "onboarding"`. A tab id+ * the wizard doesn't ship becomes a new step; on a built-in step these override+ * its defaults. Built-in ranks: store 10, address 20, company 30, payment 40.+ */+export type OnboardingStepOptions = {+ /** Step heading. Required in practice for new steps. */+ label?: string+ /** Sort position. New steps without a rank go last. */+ rank?: number+ /** Shows a Skip button on the step. */+ optional?: boolean+}+export type CustomFormEntry<TModel> =CustomFormZone<TModel> extends infer TZone? TZone extends CustomFormZone<TModel>- ? {- zone: TZone- /** TabbedForm tab id, or onboarding wizard step id for `zone: "onboarding"`. */- tab?: CustomFormTab<TModel, TZone>- fields: Record<string, CustomFormField>- }+ ?+ | ({+ zone: TZone+ /** TabbedForm tab id, or onboarding wizard step id for `zone: "onboarding"`. */+ tab?: CustomFormTab<TModel, TZone>+ fields?: Record<string, CustomFormField>+ disabled?: false+ } & OnboardingStepOptions)+ | {+ zone: TZone+ tab: CustomFormTab<TModel, TZone>+ /** Removes a built-in onboarding step. The store step can't be removed. */+ disabled: true+ fields?: never+ }: never: neverdiff --git a/packages/dashboard-sdk/src/custom-fields.ts b/packages/dashboard-sdk/src/custom-fields.tsindex c8b9d891e..caa8b4316 100644--- a/packages/dashboard-sdk/src/custom-fields.ts+++ b/packages/dashboard-sdk/src/custom-fields.ts@@ -7,7 +7,8 @@ import type { BuiltMercurConfig } from "./types"* components, default-value resolvers), so — unlike widgets — the emitted* module re-exports the actual default-exported config objects rather than a* build-time-extracted literal. The runtime `ExtensionRegistry` reads- * `model` / `link` / `forms` / `displays` / `list` off each object.+ * `model` / `link` / `forms` / `displays` / `list` off each object, applying+ * them in array order.*/export function generateCustomFields({srcDir,@@ -29,9 +30,10 @@ export function generateCustomFields({(_, i) => ` ...(__plugin${i}.customFieldsModule?.configs ?? [])`)+ // Host configs go last so they layer over (and win against) plugin configs.const configs = [- ...localRefs.map((ref) => ` ${ref}`),...pluginSpreads,+ ...localRefs.map((ref) => ` ${ref}`),]if (configs.length === 0 && pluginDeclarations.length === 0) {diff --git a/packages/dashboard-shared/src/extensions/index.ts b/packages/dashboard-shared/src/extensions/index.tsindex b2577a05a..8e82b8a94 100644--- a/packages/dashboard-shared/src/extensions/index.ts+++ b/packages/dashboard-shared/src/extensions/index.ts@@ -5,6 +5,8 @@ export {type NavigationModule,type CustomFieldsModule,type ResolvedFormField,+ type OnboardingStep,+ type OnboardingStepDefault,type ResolvedDisplays,type ZoneWidgets,type WidgetPlacement,diff --git a/packages/dashboard-shared/src/extensions/registry.spec.ts b/packages/dashboard-shared/src/extensions/registry.spec.tsindex 87c0d25d7..be784767e 100644--- a/packages/dashboard-shared/src/extensions/registry.spec.ts+++ b/packages/dashboard-shared/src/extensions/registry.spec.ts@@ -82,4 +82,272 @@ describe("ExtensionRegistry", () => {"Dispute resolved",])})++ describe("layered custom-fields configs", () => {+ const Plugin = () => null+ const Host = () => null++ test("a later column with the same id replaces an added one in place", () => {+ const registry = new ExtensionRegistry({+ customFields: {+ configs: [+ {+ model: "product",+ list: {+ columns: [+ { id: "brand", header: "Brand", component: Plugin },+ { id: "erp", header: "ERP" },+ ],+ },+ },+ {+ model: "product",+ list: { columns: [{ id: "brand", header: "Maker", component: Host }] },+ },+ ],+ },+ })++ const { columns } = registry.getListExtension("product")+ expect(columns).toEqual([+ { id: "brand", header: "Maker", component: Host },+ { id: "erp", header: "ERP" },+ ])+ })++ test("view defaults from later configs take precedence", () => {+ const registry = new ExtensionRegistry({+ customFields: {+ configs: [+ {+ model: "product",+ list: {+ viewDefaults: {+ columnVisibility: { brand: true, sku: false },+ columnOrder: ["brand", "title"],+ },+ },+ },+ {+ model: "product",+ list: {+ viewDefaults: {+ columnVisibility: { brand: false },+ columnOrder: ["title", "brand"],+ },+ },+ },+ ],+ },+ })++ const { viewDefaults } = registry.getListExtension("product")+ expect(viewDefaults).toEqual({+ columnVisibility: { brand: false, sku: false },+ columnOrder: ["title", "brand"],+ })+ })++ test("a later filter replaces or removes an added filter by key", () => {+ const registry = new ExtensionRegistry({+ customFields: {+ configs: [+ {+ model: "product",+ list: {+ filters: [+ { key: "brand", label: "Brand", type: "string" },+ { key: "erp_id", label: "ERP", type: "string" },+ ],+ },+ },+ {+ model: "product",+ list: {+ filters: [+ { key: "brand", label: "Maker", type: "string" },+ { key: "erp_id", remove: true },+ ],+ },+ },+ ],+ },+ })++ expect(registry.getListExtension("product").filters).toEqual([+ { key: "brand", label: "Maker", type: "string" },+ { key: "erp_id", remove: true },+ ])+ })++ test("a later display field replaces or removes an added field by id", () => {+ const registry = new ExtensionRegistry({+ customFields: {+ configs: [+ {+ model: "product",+ displays: [+ {+ zone: "general",+ fields: [+ { id: "title", component: Plugin },+ { id: "brand", component: Plugin },+ { id: "erp", component: Plugin },+ ],+ },+ ],+ },+ {+ model: "product",+ displays: [+ {+ zone: "general",+ fields: [+ { id: "title", component: Host },+ { id: "brand", component: Host },+ { id: "erp", component: null },+ ],+ },+ ],+ },+ ],+ },+ })++ expect(registry.getDisplays("product", "general").fields).toEqual([+ { id: "title", component: Host },+ { id: "brand", component: Host },+ { id: "erp", component: null },+ ])+ })++ test("a later form field with the same name replaces an added one", () => {+ const validation = {}+ const registry = new ExtensionRegistry({+ customFields: {+ configs: [+ {+ model: "product",+ forms: [+ {+ zone: "create",+ tab: "general",+ fields: {+ brand: { validation, label: "Brand" },+ erp: { validation, label: "ERP" },+ },+ },+ ],+ },+ {+ model: "product",+ forms: [+ {+ zone: "create",+ tab: "general",+ fields: { brand: { validation, label: "Maker" } },+ },+ { zone: "edit", fields: { erp: { validation, label: "ERP id" } } },+ ],+ },+ ],+ },+ })++ const labels = (fields: { name: string; field: { label?: string } }[]) =>+ fields.map(({ name, field }) => [name, field.label])++ expect(labels(registry.getFormFields("product", "create", "general"))).toEqual([+ ["brand", "Maker"],+ ])+ expect(labels(registry.getFormFields("product", "edit"))).toEqual([+ ["erp", "ERP id"],+ ])+ expect(labels(registry.getAllFormFields("product"))).toEqual([+ ["brand", "Maker"],+ ["erp", "ERP id"],+ ])+ })+ })++ describe("getOnboardingSteps", () => {+ const builtIns = [+ { id: "store", rank: 10, optional: false, required: true },+ { id: "address", rank: 20, optional: true },+ { id: "company", rank: 30, optional: true },+ { id: "payment", rank: 40, optional: true },+ ]++ const ids = (steps: { id: string }[]) => steps.map((step) => step.id)++ test("returns the built-in steps when nothing is configured", () => {+ const registry = new ExtensionRegistry()++ expect(ids(registry.getOnboardingSteps("seller", builtIns))).toEqual([+ "store",+ "address",+ "company",+ "payment",+ ])+ })++ test("adds, removes, reorders and flags steps from onboarding form entries", () => {+ const validation = {}+ const registry = new ExtensionRegistry({+ customFields: {+ configs: [+ {+ model: "seller",+ forms: [+ { zone: "onboarding", tab: "address", fields: { region: { validation } } },+ {+ zone: "onboarding",+ tab: "documents",+ label: "Documents",+ rank: 25,+ optional: true,+ fields: { vat: { validation } },+ },+ { zone: "onboarding", tab: "company", disabled: true },+ { zone: "onboarding", tab: "payment", optional: false },+ { zone: "onboarding", tab: "terms", label: "Terms" },+ { zone: "edit", tab: "ignored", label: "Not onboarding" },+ ],+ },+ ],+ },+ })++ const steps = registry.getOnboardingSteps("seller", builtIns)++ expect(ids(steps)).toEqual(["store", "address", "documents", "payment", "terms"])+ expect(steps.find((step) => step.id === "documents")).toEqual({+ id: "documents",+ label: "Documents",+ rank: 25,+ optional: true,+ custom: true,+ })+ expect(steps.find((step) => step.id === "payment")?.optional).toBe(false)+ expect(steps.find((step) => step.id === "terms")).toMatchObject({+ custom: true,+ optional: false,+ })+ expect(+ registry.getFormFields("seller", "onboarding", "documents").map((f) => f.name)+ ).toEqual(["vat"])+ })++ test("ignores attempts to disable a required step", () => {+ const registry = new ExtensionRegistry({+ customFields: {+ configs: [+ { model: "seller", forms: [{ zone: "onboarding", tab: "store", disabled: true }] },+ ],+ },+ })++ expect(ids(registry.getOnboardingSteps("seller", builtIns))[0]).toEqual("store")+ })+ })})diff --git a/packages/dashboard-shared/src/extensions/registry.ts b/packages/dashboard-shared/src/extensions/registry.tsindex 97940892c..1b7094723 100644--- a/packages/dashboard-shared/src/extensions/registry.ts+++ b/packages/dashboard-shared/src/extensions/registry.ts@@ -1,10 +1,12 @@import type { ComponentType } from "react"import type {ActivityEntry,+ CustomColumn,CustomDisplayField,CustomFieldsConfig,CustomFormField,CustomListExtension,+ CustomListFilter,NavGroupConfig,NavItemOverride,Permission,@@ -29,6 +31,23 @@ export type NavigationModule = {export type CustomFieldsModule = { configs?: CustomFieldsConfig[] }export type ResolvedFormField = { name: string; field: CustomFormField }+type ResolvedFormEntry = ResolvedFormField & { zone: string; tab?: string }++export type OnboardingStep = {+ id: string+ label?: string+ rank: number+ optional: boolean+ custom: boolean+}++export type OnboardingStepDefault = {+ id: string+ rank: number+ optional: boolean+ /** Built-in steps that carry required data and can't be disabled. */+ required?: boolean+}export type ResolvedDisplays = {fields: CustomDisplayField[]actions: SectionAction[]@@ -153,78 +172,138 @@ export class ExtensionRegistry {return this.configsFor(model).flatMap((c) => c.activity?.(entity) ?? [])}- /** Custom form fields for a model's form zone (and optional tab). */- getFormFields(model: string, zone: string, tab?: string): ResolvedFormField[] {- const out: ResolvedFormField[] = []+ // Configs are ordered plugins first, host app last. Entries are keyed so a+ // later config replaces an earlier one in place — including entries another+ // config added — instead of stacking a duplicate.+ private resolveFormFields(model: string): ResolvedFormEntry[] {+ const byName = new Map<string, ResolvedFormEntry>()for (const config of this.configsFor(model)) {for (const form of config.forms ?? []) {- if (form.zone !== zone) continue- if (form.tab && tab && form.tab !== tab) continue- if (form.tab && !tab) continue- for (const [name, field] of Object.entries(form.fields)) {- out.push({ name, field })+ for (const [name, field] of Object.entries(form.fields ?? {})) {+ byName.set(name, { name, field, zone: form.zone, tab: form.tab })}}}- return out+ return [...byName.values()]}- /** All custom form fields for a model, keyed for schema/default building. */- getAllFormFields(model: string): ResolvedFormField[] {- const out: ResolvedFormField[] = []- const seen = new Set<string>()+ /** Custom form fields for a model's form zone (and optional tab). */+ getFormFields(model: string, zone: string, tab?: string): ResolvedFormField[] {+ return this.resolveFormFields(model)+ .filter((entry) => {+ if (entry.zone !== zone) return false+ if (!entry.tab) return true+ return !!tab && entry.tab === tab+ })+ .map(({ name, field }) => ({ name, field }))+ }++ /**+ * Resolves the onboarding wizard steps: built-ins merged with every+ * `zone: "onboarding"` form entry for the model. Later configs win per tab.+ */+ getOnboardingSteps(+ model: string,+ builtIns: OnboardingStepDefault[]+ ): OnboardingStep[] {+ const steps = new Map<string, OnboardingStep & { disabled?: boolean }>()+ for (const step of builtIns) {+ steps.set(step.id, {+ id: step.id,+ rank: step.rank,+ optional: step.optional,+ custom: false,+ })+ }++ const maxBuiltInRank = Math.max(0, ...builtIns.map((step) => step.rank))+ let nextCustomRank = maxBuiltInRank+for (const config of this.configsFor(model)) {for (const form of config.forms ?? []) {- for (const [name, field] of Object.entries(form.fields)) {- if (seen.has(name)) continue- seen.add(name)- out.push({ name, field })+ if (form.zone !== "onboarding" || !form.tab) continue++ const existing = steps.get(form.tab)+ const builtIn = builtIns.find((step) => step.id === form.tab)++ if (form.disabled) {+ if (builtIn?.required) {+ if (process.env.NODE_ENV === "development") {+ console.warn(+ `[mercur] The "${form.tab}" onboarding step can't be disabled.`+ )+ }+ continue+ }+ if (existing) existing.disabled = true+ continue+ }++ const step = existing ?? {+ id: form.tab,+ rank: (nextCustomRank += 1),+ optional: false,+ custom: true,}+ if (form.label !== undefined) step.label = form.label+ if (form.rank !== undefined) step.rank = form.rank+ if (form.optional !== undefined) step.optional = form.optional+ steps.set(form.tab, step)}}- return out++ return [...steps.values()]+ .filter((step) => !step.disabled)+ .map(({ disabled: _disabled, ...step }) => step)+ .sort((a, b) => a.rank - b.rank)+ }++ /** All custom form fields for a model, keyed for schema/default building. */+ getAllFormFields(model: string): ResolvedFormField[] {+ return this.resolveFormFields(model).map(({ name, field }) => ({ name, field }))}/** Section display contributions (field add/replace/remove + actions). */getDisplays(model: string, zone: string): ResolvedDisplays {- const fields: CustomDisplayField[] = []+ const fields = new Map<string, CustomDisplayField>()const actions: SectionAction[] = []for (const config of this.configsFor(model)) {for (const display of config.displays ?? []) {if (display.zone !== zone) continue- if (display.fields) fields.push(...display.fields)+ for (const field of display.fields ?? []) fields.set(field.id, field)if (display.actions) actions.push(...display.actions)}}actions.sort((a, b) => (a.rank ?? 0) - (b.rank ?? 0))- return { fields, actions }+ return { fields: [...fields.values()], actions }}/** Merged list-table extension for a model. */getListExtension(model: string): CustomListExtension {- const merged: Required<CustomListExtension> = {- columns: [],- bulkActions: [],- filters: [],- viewDefaults: { columnVisibility: {}, columnOrder: [] },- }+ const columns = new Map<string, CustomColumn>()+ const filters = new Map<string, CustomListFilter>()+ const bulkActions: SectionAction[] = []+ const columnVisibility: Record<string, boolean> = {}+ let columnOrder: string[] = []+for (const config of this.configsFor(model)) {const list = config.listif (!list) continue- if (list.columns) merged.columns.push(...list.columns)- if (list.bulkActions) merged.bulkActions.push(...list.bulkActions)- if (list.filters) merged.filters.push(...list.filters)- if (list.viewDefaults?.columnVisibility) {- Object.assign(- merged.viewDefaults.columnVisibility!,- list.viewDefaults.columnVisibility- )- }+ for (const column of list.columns ?? []) columns.set(column.id, column)+ for (const filter of list.filters ?? []) filters.set(filter.key, filter)+ if (list.bulkActions) bulkActions.push(...list.bulkActions)+ Object.assign(columnVisibility, list.viewDefaults?.columnVisibility)if (list.viewDefaults?.columnOrder) {- merged.viewDefaults.columnOrder = list.viewDefaults.columnOrder+ columnOrder = list.viewDefaults.columnOrder}}- merged.bulkActions.sort((a, b) => (a.rank ?? 0) - (b.rank ?? 0))- return merged+ bulkActions.sort((a, b) => (a.rank ?? 0) - (b.rank ?? 0))++ return {+ columns: [...columns.values()],+ bulkActions,+ filters: [...filters.values()],+ viewDefaults: { columnVisibility, columnOrder },+ }}}diff --git a/packages/types/src/http/seller.ts b/packages/types/src/http/seller.tsindex 7cd16e1c0..5024b5c2f 100644--- a/packages/types/src/http/seller.ts+++ b/packages/types/src/http/seller.ts@@ -9,6 +9,21 @@ export interface VendorSellerResponse {seller: SellerDTO}+export interface VendorSellerHandleAvailabilityResponse {+ /**+ * The handle that was checked.+ */+ handle: string+ /**+ * Whether a new seller can use the handle.+ */+ available: boolean+ /**+ * Why the handle can't be used.+ */+ reason?: "invalid" | "taken"+}+export type VendorSellerListResponse = PaginatedResponse<{/*** The list of sellers.diff --git a/packages/vendor/src/components/onboarding-wizard/constants.ts b/packages/vendor/src/components/onboarding-wizard/constants.tsindex db4a50051..8fa7af5c3 100644--- a/packages/vendor/src/components/onboarding-wizard/constants.ts+++ b/packages/vendor/src/components/onboarding-wizard/constants.ts@@ -1,26 +1,10 @@+import type { OnboardingStepDefault } from "@mercurjs/dashboard-shared";+export const WIZARD_STEPS = [- {- id: "store",- number: 1,- labelKey: "onboarding.wizard.steps.store",- },- {- id: "address",- number: 2,- labelKey: "onboarding.wizard.steps.address",- },- {- id: "company",- number: 3,- labelKey: "onboarding.wizard.steps.company",- },- {- id: "payment",- number: 4,- labelKey: "onboarding.wizard.steps.payment",- },-] as const;+ { id: "store", rank: 10, optional: false, required: true },+ { id: "address", rank: 20, optional: true },+ { id: "company", rank: 30, optional: true },+ { id: "payment", rank: 40, optional: true },+] as const satisfies readonly OnboardingStepDefault[];export type WizardStepId = (typeof WIZARD_STEPS)[number]["id"];--export const TOTAL_STEPS = WIZARD_STEPS.length;diff --git a/packages/vendor/src/components/onboarding-wizard/hooks/use-onboarding.ts b/packages/vendor/src/components/onboarding-wizard/hooks/use-onboarding.tsindex 8c311be45..f193b8e91 100644--- a/packages/vendor/src/components/onboarding-wizard/hooks/use-onboarding.ts+++ b/packages/vendor/src/components/onboarding-wizard/hooks/use-onboarding.ts@@ -1,10 +1,11 @@-import { useState, useCallback, useRef } from "react";+import { useCallback, useRef, useState } from "react";import { useNavigate } from "react-router-dom";import { toast } from "@medusajs/ui";+import type { OnboardingStep } from "@mercurjs/dashboard-shared";import { useCreateSellerAccount, useLogout } from "@hooks/api";import { queryClient } from "@lib/query-client";-import { TOTAL_STEPS } from "../constants";+import type { StepSubmission } from "../steps/types";type StoreData = {name: string;@@ -12,8 +13,7 @@ type StoreData = {phone?: string;currency_code: string;description?: string;- handle?: string;- additional_data?: Record<string, unknown>;+ handle: string;};type AddressData = {@@ -41,22 +41,32 @@ type PaymentData = {account_number?: string;};-export const useOnboarding = (memberEmail: string) => {+const readRegisterDraft = (): {+ first_name?: string;+ last_name?: string;+ additional_data?: Record<string, unknown>;+} => {+ try {+ const raw = sessionStorage.getItem("mercur_register_draft");+ if (!raw) return {};+ const parsed = JSON.parse(raw);+ return {+ first_name: parsed.first_name || undefined,+ last_name: parsed.last_name || undefined,+ additional_data: parsed.additional_data || undefined,+ };+ } catch {+ return {};+ }+};++export const useOnboarding = (memberEmail: string, steps: OnboardingStep[]) => {const navigate = useNavigate();const [currentStep, setCurrentStep] = useState(0);+ const [furthestStep, setFurthestStep] = useState(0);const [isSubmitting, setIsSubmitting] = useState(false);-const sellerIdRef = useRef<string | null>(null);- const [sellerIdState, setSellerIdState] = useState<string | null>(null);-- const setSellerId = (id: string) => {- sellerIdRef.current = id;- setSellerIdState(id);- };-- const storeDataRef = useRef<StoreData | null>(null);- const addressDataRef = useRef<AddressData | null>(null);- const companyDataRef = useRef<CompanyData | null>(null);+ const stepDataRef = useRef<Record<string, StepSubmission | null>>({});const { mutateAsync: createSeller, isPending: isCreating } =useCreateSellerAccount();@@ -64,187 +74,146 @@ export const useOnboarding = (memberEmail: string) => {const isPending = isCreating || isSubmitting;- // Step 1: Store — save locally- const submitStoreStep = useCallback(async (data: StoreData) => {- storeDataRef.current = data;- setCurrentStep(1);- }, []);-- // Step 2: Address — save locally- const submitAddressStep = useCallback(async (data: AddressData) => {- addressDataRef.current = data;- setCurrentStep(2);- }, []);-- const skipAddressStep = useCallback(() => {- addressDataRef.current = null;- setCurrentStep(2);- }, []);-- // Step 3: Company — save locally- const submitCompanyStep = useCallback(async (data: CompanyData) => {- companyDataRef.current = data;- setCurrentStep(3);- }, []);-- const skipCompanyStep = useCallback(() => {- companyDataRef.current = null;- setCurrentStep(3);- }, []);-- /**- * Creates seller with ALL collected data (Steps 1-4) in one API call.- * This goes through POST /vendor/sellers which is unauthenticated —- * no seller_context needed, no session issues.- */- const createSellerWithAllData = useCallback(- async (paymentData?: PaymentData) => {- const storeData = storeDataRef.current;- if (!storeData) return;-- // Already created (user went back and forward)- if (sellerIdRef.current) {- navigate("/store-select", { replace: true });- return;- }-- const addressData = addressDataRef.current;- const companyData = companyDataRef.current;- const hasCompanyData =- companyData?.corporate_name ||- companyData?.registration_number ||- companyData?.tax_id;-- const isUS = paymentData?.country_code === "us";-- let registerDraft: {- first_name?: string;- last_name?: string;- additional_data?: Record<string, unknown>;- } = {};- try {- const raw = sessionStorage.getItem("mercur_register_draft");- if (raw) {- const parsed = JSON.parse(raw);- registerDraft = {- first_name: parsed.first_name || undefined,- last_name: parsed.last_name || undefined,- additional_data: parsed.additional_data || undefined,- };- }- } catch {- // Ignore malformed draft- }-- const additionalData = {- ...registerDraft.additional_data,- ...storeData.additional_data,- };+ const createSellerWithAllData = useCallback(async () => {+ if (sellerIdRef.current) {+ navigate("/store-select", { replace: true });+ return;+ }- try {- setIsSubmitting(true);-- const result = await createSeller({- name: storeData.name,- handle: storeData.handle || undefined,- email: storeData.email,- phone: storeData.phone || undefined,- member_email: memberEmail,- first_name: registerDraft.first_name,- last_name: registerDraft.last_name,- currency_code: storeData.currency_code.toLowerCase(),- description: storeData.description || undefined,- ...(Object.keys(additionalData).length- ? { additional_data: additionalData }- : {}),- address: addressData+ const stepData = stepDataRef.current;+ const valuesOf = (id: string) => {+ const entry = stepData[id];+ if (!entry) return undefined;+ const { additional_data: _additionalData, ...values } = entry;+ return values;+ };++ const storeData = valuesOf("store") as StoreData | undefined;+ if (!storeData) return;++ const addressData = valuesOf("address") as AddressData | undefined;+ const companyData = valuesOf("company") as CompanyData | undefined;+ const paymentData = valuesOf("payment") as PaymentData | undefined;++ const hasCompanyData =+ companyData?.corporate_name ||+ companyData?.registration_number ||+ companyData?.tax_id;+ const isUS = paymentData?.country_code === "us";++ const registerDraft = readRegisterDraft();+ const additionalData = steps.reduce<Record<string, unknown>>(+ (acc, step) => ({ ...acc, ...stepData[step.id]?.additional_data }),+ { ...registerDraft.additional_data },+ );++ try {+ setIsSubmitting(true);++ const result = await createSeller({+ name: storeData.name,+ handle: storeData.handle,+ email: storeData.email,+ phone: storeData.phone || undefined,+ member_email: memberEmail,+ first_name: registerDraft.first_name,+ last_name: registerDraft.last_name,+ currency_code: storeData.currency_code.toLowerCase(),+ description: storeData.description || undefined,+ ...(Object.keys(additionalData).length+ ? { additional_data: additionalData }+ : {}),+ address: addressData+ ? {+ name: addressData.name || undefined,+ address_1: addressData.address_1 || undefined,+ address_2: addressData.address_2 || undefined,+ postal_code: addressData.postal_code || undefined,+ city: addressData.city || undefined,+ country_code: addressData.country_code,+ province: addressData.province || undefined,+ }+ : undefined,+ professional_details:+ companyData && hasCompanyData? {- name: addressData.name || undefined,- address_1: addressData.address_1 || undefined,- address_2: addressData.address_2 || undefined,- postal_code: addressData.postal_code || undefined,- city: addressData.city || undefined,- country_code: addressData.country_code,- province: addressData.province || undefined,- }- : undefined,- professional_details: hasCompanyData- ? {- corporate_name: companyData!.corporate_name || undefined,+ corporate_name: companyData.corporate_name || undefined,registration_number:- companyData!.registration_number || undefined,- tax_id: companyData!.tax_id || undefined,- }- : undefined,- payment_details: paymentData- ? {- country_code: paymentData.country_code,- holder_name: paymentData.holder_name,- iban: isUS ? null : paymentData.iban || null,- bic: isUS ? null : paymentData.bic || null,- routing_number: isUS- ? paymentData.routing_number || null- : null,- account_number: paymentData.account_number || null,+ companyData.registration_number || undefined,+ tax_id: companyData.tax_id || undefined,}: undefined,- });-- const newSellerId = result.seller.id;- setSellerId(newSellerId);-- // Force a fresh login so the new member_id lands in the JWT.- try {- await logout();- } catch {- // If logout fails we still redirect to /login — user will re-auth there.- }- queryClient.clear();- sessionStorage.removeItem("mercur_onboarding_email");- sessionStorage.removeItem("mercur_register_draft");-- navigate("/login", { replace: true });- } catch (error: any) {- toast.error(error.message);- } finally {- setIsSubmitting(false);+ payment_details: paymentData+ ? {+ country_code: paymentData.country_code,+ holder_name: paymentData.holder_name,+ iban: isUS ? null : paymentData.iban || null,+ bic: isUS ? null : paymentData.bic || null,+ routing_number: isUS ? paymentData.routing_number || null : null,+ account_number: paymentData.account_number || null,+ }+ : undefined,+ });++ sellerIdRef.current = result.seller.id;++ // Force a fresh login so the new member_id lands in the JWT.+ try {+ await logout();+ } catch {+ // The user re-authenticates on /login either way.}+ queryClient.clear();+ sessionStorage.removeItem("mercur_onboarding_email");+ sessionStorage.removeItem("mercur_register_draft");++ navigate("/login", { replace: true });+ } catch (error) {+ toast.error(error instanceof Error ? error.message : String(error));+ } finally {+ setIsSubmitting(false);+ }+ }, [createSeller, logout, memberEmail, navigate, steps]);++ const advance = useCallback(+ async (index: number) => {+ if (index >= steps.length - 1) {+ await createSellerWithAllData();+ return;+ }+ setCurrentStep(index + 1);+ setFurthestStep((prev) => Math.max(prev, index + 1));},- [createSeller, logout, memberEmail, navigate],+ [steps.length, createSellerWithAllData],);- // Step 4: Payment — create seller with everything and finish- const submitPaymentStep = useCallback(- async (data: PaymentData) => {- await createSellerWithAllData(data);+ const submitStep = useCallback(+ async (index: number, data: StepSubmission) => {+ stepDataRef.current[steps[index].id] = data;+ await advance(index);},- [createSellerWithAllData],+ [steps, advance],);- // Skip payment — create seller without payment details- const skipPaymentStep = useCallback(async () => {- await createSellerWithAllData();- }, [createSellerWithAllData]);+ const skipStep = useCallback(+ async (index: number) => {+ stepDataRef.current[steps[index].id] = null;+ await advance(index);+ },+ [steps, advance],+ );const goBack = useCallback(() => {- if (currentStep > 0) {- setCurrentStep((prev) => prev - 1);- }- }, [currentStep]);+ setCurrentStep((prev) => Math.max(0, prev - 1));+ }, []);return {currentStep,- totalSteps: TOTAL_STEPS,- sellerId: sellerIdState,+ furthestStep,+ totalSteps: steps.length,isPending,- canGoBack: currentStep > 0,goBack,- submitStoreStep,- submitAddressStep,- skipAddressStep,- submitCompanyStep,- skipCompanyStep,- submitPaymentStep,- skipPaymentStep,+ submitStep,+ skipStep,};};diff --git a/packages/vendor/src/components/onboarding-wizard/onboarding-wizard.tsx b/packages/vendor/src/components/onboarding-wizard/onboarding-wizard.tsxindex 9750121c5..029332440 100644--- a/packages/vendor/src/components/onboarding-wizard/onboarding-wizard.tsx+++ b/packages/vendor/src/components/onboarding-wizard/onboarding-wizard.tsx@@ -1,9 +1,10 @@-import { AnimatePresence } from "motion/react";+import { ComponentType, useMemo } from "react";import { useNavigate } from "react-router-dom";-import { useLinkQuery } from "@mercurjs/dashboard-shared";+import { useExtension, useLinkQuery } from "@mercurjs/dashboard-shared";import { useLogout, useSellers } from "@hooks/api";import { queryClient } from "@lib/query-client";+import { WIZARD_STEPS, WizardStepId } from "./constants";import { WizardSidebar } from "./wizard-sidebar";import { WizardPreview } from "./wizard-preview";import { WizardStep } from "./wizard-step";@@ -12,6 +13,15 @@ import { StoreStep } from "./steps/store-step";import { AddressStep } from "./steps/address-step";import { CompanyStep } from "./steps/company-step";import { PaymentStep } from "./steps/payment-step";+import { CustomStep } from "./steps/custom-step";+import { StepProps, StepSubmission } from "./steps/types";++const BUILT_IN_STEPS: Record<WizardStepId, ComponentType<StepProps>> = {+ store: StoreStep,+ address: AddressStep,+ company: CompanyStep,+ payment: PaymentStep,+};type OnboardingWizardProps = {memberEmail: string;@@ -19,23 +29,18 @@ type OnboardingWizardProps = {export const OnboardingWizard = ({ memberEmail }: OnboardingWizardProps) => {const navigate = useNavigate();+ const extension = useExtension();const { mutateAsync: logoutMutation } = useLogout();const { seller_members } = useSellers(useLinkQuery("seller"));const hasStores = (seller_members?.length ?? 0) > 0;- const {- currentStep,- sellerId,- isPending,- goBack,- submitStoreStep,- submitAddressStep,- skipAddressStep,- submitCompanyStep,- skipCompanyStep,- submitPaymentStep,- skipPaymentStep,- } = useOnboarding(memberEmail);+ const steps = useMemo(+ () => extension.getOnboardingSteps("seller", [...WIZARD_STEPS]),+ [extension],+ );++ const { currentStep, furthestStep, isPending, goBack, submitStep, skipStep } =+ useOnboarding(memberEmail, steps);const handleBack = async () => {if (currentStep === 0) {@@ -52,58 +57,44 @@ export const OnboardingWizard = ({ memberEmail }: OnboardingWizardProps) => {}};- const renderStep = () => {- switch (currentStep) {- case 0:- return (- <WizardStep key="store">- <StoreStep onSubmit={submitStoreStep} isPending={isPending} />- </WizardStep>- );- case 1:- return (- <WizardStep key="address">- <AddressStep- onSubmit={submitAddressStep}- onSkip={skipAddressStep}- isPending={isPending}- />- </WizardStep>- );- case 2:- return (- <WizardStep key="company">- <CompanyStep- onSubmit={submitCompanyStep}- onSkip={skipCompanyStep}- isPending={isPending}- />- </WizardStep>- );- case 3:- return (- <WizardStep key="payment">- <PaymentStep- sellerId={sellerId!}- onSubmit={submitPaymentStep}- onSkip={skipPaymentStep}- isPending={isPending}- />- </WizardStep>- );- default:- return null;- }+ const renderStep = (index: number) => {+ const step = steps[index];++ const props: StepProps = {+ onSubmit: (data: StepSubmission) => submitStep(index, data),+ onSkip: step.optional ? () => skipStep(index) : undefined,+ isLast: index === steps.length - 1,+ isPending,+ };++ const BuiltIn = step.custom+ ? undefined+ : BUILT_IN_STEPS[step.id as WizardStepId];++ return (+ <WizardStep key={step.id} active={index === currentStep}>+ <div data-testid={`onboarding-step-${step.id}`}>+ {BuiltIn ? (+ <BuiltIn {...props} />+ ) : (+ <CustomStep id={step.id} label={step.label} {...props} />+ )}+ </div>+ </WizardStep>+ );};return (<div className="flex h-dvh w-dvw overflow-hidden"><WizardSidebarcurrentStep={currentStep}+ totalSteps={steps.length}onBack={handleBack}showBack>- <AnimatePresence mode="wait">{renderStep()}</AnimatePresence>+ {/* Visited steps stay mounted (just hidden) so going back, or retrying+ after a failed Finish, keeps everything the user typed. */}+ {steps.slice(0, furthestStep + 1).map((_, index) => renderStep(index))}</WizardSidebar><WizardPreview /></div>diff --git a/packages/vendor/src/components/onboarding-wizard/steps/address-step.tsx b/packages/vendor/src/components/onboarding-wizard/steps/address-step.tsxindex ba069a55f..9e3663a2d 100644--- a/packages/vendor/src/components/onboarding-wizard/steps/address-step.tsx+++ b/packages/vendor/src/components/onboarding-wizard/steps/address-step.tsx@@ -1,12 +1,17 @@-import { zodResolver } from "@hookform/resolvers/zod";-import { Button, Heading, Input } from "@medusajs/ui";+import { Heading, Input } from "@medusajs/ui";import i18n from "i18next";-import { useForm } from "react-hook-form";import { useTranslation } from "react-i18next";import * as z from "zod";+import {+ FormExtensionZone,+ useExtendableForm,+} from "@mercurjs/dashboard-shared";+import { Form } from "@components/common/form";import { CountrySelect } from "@components/inputs/country-select/country-select";+import { StepActions } from "./step-actions";+import { StepProps } from "./types";const AddressStepSchema = z.object({name: z.string().min(1, i18n.t("onboarding.wizard.validation.nameRequired")),@@ -20,17 +25,23 @@ const AddressStepSchema = z.object({type AddressStepValues = z.infer<typeof AddressStepSchema>;-type AddressStepProps = {- onSubmit: (data: AddressStepValues) => Promise<void>;- onSkip: () => void;- isPending?: boolean;-};+type AddressStepProps = StepProps<AddressStepValues & {+ additional_data?: Record<string, unknown>;+}>;-export const AddressStep = ({ onSubmit, onSkip, isPending }: AddressStepProps) => {+export const AddressStep = ({+ onSubmit,+ onSkip,+ isLast,+ isPending,+}: AddressStepProps) => {const { t } = useTranslation();- const form = useForm<AddressStepValues>({- resolver: zodResolver(AddressStepSchema),+ const form = useExtendableForm({+ schema: AddressStepSchema,+ model: "seller",+ zone: "onboarding",+ tab: "address",defaultValues: {name: "",address_1: "",@@ -150,20 +161,14 @@ export const AddressStep = ({ onSubmit, onSkip, isPending }: AddressStepProps) =</Form.Item>)}/>+ <FormExtensionZone+ model="seller"+ zone="onboarding"+ tab="address"+ control={form.control}+ /></div>- <div className="flex flex-col gap-y-2">- <Button type="submit" className="w-full" isLoading={isPending}>- {t("actions.continue")}- </Button>- <Button- type="button"- variant="transparent"- className="w-full"- onClick={onSkip}- >- {t("onboarding.wizard.skip")}- </Button>- </div>+ <StepActions onSkip={onSkip} isLast={isLast} isPending={isPending} /></form></Form></div>diff --git a/packages/vendor/src/components/onboarding-wizard/steps/company-step.tsx b/packages/vendor/src/components/onboarding-wizard/steps/company-step.tsxindex 96afb34c5..d7ae25a51 100644--- a/packages/vendor/src/components/onboarding-wizard/steps/company-step.tsx+++ b/packages/vendor/src/components/onboarding-wizard/steps/company-step.tsx@@ -1,10 +1,15 @@-import { zodResolver } from "@hookform/resolvers/zod";-import { Button, Heading, Input } from "@medusajs/ui";-import { useForm } from "react-hook-form";+import { Heading, Input } from "@medusajs/ui";import { useTranslation } from "react-i18next";import * as z from "zod";+import {+ FormExtensionZone,+ useExtendableForm,+} from "@mercurjs/dashboard-shared";+import { Form } from "@components/common/form";+import { StepActions } from "./step-actions";+import { StepProps } from "./types";const CompanyStepSchema = z.object({corporate_name: z.string().optional(),@@ -14,17 +19,23 @@ const CompanyStepSchema = z.object({type CompanyStepValues = z.infer<typeof CompanyStepSchema>;-type CompanyStepProps = {- onSubmit: (data: CompanyStepValues) => Promise<void>;- onSkip: () => void;- isPending?: boolean;-};+type CompanyStepProps = StepProps<CompanyStepValues & {+ additional_data?: Record<string, unknown>;+}>;-export const CompanyStep = ({ onSubmit, onSkip, isPending }: CompanyStepProps) => {+export const CompanyStep = ({+ onSubmit,+ onSkip,+ isLast,+ isPending,+}: CompanyStepProps) => {const { t } = useTranslation();- const form = useForm<CompanyStepValues>({- resolver: zodResolver(CompanyStepSchema),+ const form = useExtendableForm({+ schema: CompanyStepSchema,+ model: "seller",+ zone: "onboarding",+ tab: "company",defaultValues: {corporate_name: "",registration_number: "",@@ -90,20 +101,14 @@ export const CompanyStep = ({ onSubmit, onSkip, isPending }: CompanyStepProps) =</Form.Item>)}/>+ <FormExtensionZone+ model="seller"+ zone="onboarding"+ tab="company"+ control={form.control}+ /></div>- <div className="flex flex-col gap-y-2">- <Button type="submit" className="w-full" isLoading={isPending}>- {t("actions.continue")}- </Button>- <Button- type="button"- variant="transparent"- className="w-full"- onClick={onSkip}- >- {t("onboarding.wizard.skip")}- </Button>- </div>+ <StepActions onSkip={onSkip} isLast={isLast} isPending={isPending} /></form></Form></div>diff --git a/packages/vendor/src/components/onboarding-wizard/steps/custom-step.tsx b/packages/vendor/src/components/onboarding-wizard/steps/custom-step.tsxnew file mode 100644index 000000000..3c1373705--- /dev/null+++ b/packages/vendor/src/components/onboarding-wizard/steps/custom-step.tsx@@ -0,0 +1,61 @@+import { Heading } from "@medusajs/ui";+import * as z from "zod";++import {+ FormExtensionZone,+ useExtendableForm,+} from "@mercurjs/dashboard-shared";++import { Form } from "@components/common/form";+import { StepActions } from "./step-actions";+import { StepProps } from "./types";++const CustomStepSchema = z.object({});++type CustomStepProps = StepProps & {+ id: string;+ label?: string;+};++export const CustomStep = ({+ id,+ label,+ onSubmit,+ onSkip,+ isLast,+ isPending,+}: CustomStepProps) => {+ const form = useExtendableForm({+ schema: CustomStepSchema,+ model: "seller",+ zone: "onboarding",+ tab: id,+ defaultValues: {},+ });++ const handleSubmit = form.handleSubmit(async (data) => {+ await onSubmit(data);+ });++ return (+ <div className="flex flex-col gap-y-8">+ {label && (+ <Heading level="h2" className="text-ui-fg-base text-lg">+ {label}+ </Heading>+ )}++ <Form {...form}>+ <form onSubmit={handleSubmit} className="flex flex-col gap-y-6">+ <FormExtensionZone+ model="seller"+ zone="onboarding"+ tab={id}+ control={form.control}+ />+ <StepActions onSkip={onSkip} isLast={isLast} isPending={isPending} />+ </form>+ </Form>+ </div>+ );+};diff --git a/packages/vendor/src/components/onboarding-wizard/steps/payment-step.tsx b/packages/vendor/src/components/onboarding-wizard/steps/payment-step.tsxindex 0b21e131d..3e5f019c9 100644--- a/packages/vendor/src/components/onboarding-wizard/steps/payment-step.tsx+++ b/packages/vendor/src/components/onboarding-wizard/steps/payment-step.tsx@@ -1,12 +1,17 @@-import { zodResolver } from "@hookform/resolvers/zod";-import { Button, Heading, Input } from "@medusajs/ui";+import { Heading, Input } from "@medusajs/ui";import i18n from "i18next";-import { useForm } from "react-hook-form";import { useTranslation } from "react-i18next";import * as z from "zod";+import {+ FormExtensionZone,+ useExtendableForm,+} from "@mercurjs/dashboard-shared";+import { Form } from "@components/common/form";import { CountrySelect } from "@components/inputs/country-select/country-select";+import { StepActions } from "./step-actions";+import { StepProps } from "./types";const PaymentStepSchema = z.object({country_code: z.string().min(1, i18n.t("onboarding.wizard.validation.countryRequired")),@@ -19,22 +24,23 @@ const PaymentStepSchema = z.object({type PaymentStepValues = z.infer<typeof PaymentStepSchema>;-type PaymentStepProps = {- sellerId: string;- onSubmit: (data: PaymentStepValues) => Promise<void>;- onSkip: () => void;- isPending?: boolean;-};+type PaymentStepProps = StepProps<PaymentStepValues & {+ additional_data?: Record<string, unknown>;+}>;export const PaymentStep = ({onSubmit,onSkip,+ isLast,isPending,}: PaymentStepProps) => {const { t } = useTranslation();- const form = useForm<PaymentStepValues>({- resolver: zodResolver(PaymentStepSchema),+ const form = useExtendableForm({+ schema: PaymentStepSchema,+ model: "seller",+ zone: "onboarding",+ tab: "payment",defaultValues: {country_code: "",holder_name: "",@@ -179,21 +185,14 @@ export const PaymentStep = ({)}</>)}+ <FormExtensionZone+ model="seller"+ zone="onboarding"+ tab="payment"+ control={form.control}+ /></div>-- <div className="flex flex-col gap-y-2">- <Button type="submit" className="w-full" isLoading={isPending}>- {t("actions.continue")}- </Button>- <Button- type="button"- variant="transparent"- className="w-full"- onClick={onSkip}- >- {t("onboarding.wizard.skip")}- </Button>- </div>+ <StepActions onSkip={onSkip} isLast={isLast} isPending={isPending} /></form></Form></div>diff --git a/packages/vendor/src/components/onboarding-wizard/steps/step-actions.tsx b/packages/vendor/src/components/onboarding-wizard/steps/step-actions.tsxnew file mode 100644index 000000000..978be10fc--- /dev/null+++ b/packages/vendor/src/components/onboarding-wizard/steps/step-actions.tsx@@ -0,0 +1,37 @@+import { Button } from "@medusajs/ui";+import { useTranslation } from "react-i18next";++type StepActionsProps = {+ onSkip?: () => void;+ isLast: boolean;+ isPending?: boolean;+};++export const StepActions = ({ onSkip, isLast, isPending }: StepActionsProps) => {+ const { t } = useTranslation();++ return (+ <div className="flex flex-col gap-y-2">+ <Button+ type="submit"+ className="w-full"+ isLoading={isPending}+ data-testid="onboarding-continue-button"+ >+ {isLast ? t("onboarding.wizard.finish") : t("actions.continue")}+ </Button>+ {onSkip && (+ <Button+ type="button"+ variant="transparent"+ className="w-full"+ onClick={onSkip}+ disabled={isPending}+ data-testid="onboarding-skip-button"+ >+ {t("onboarding.wizard.skip")}+ </Button>+ )}+ </div>+ );+};diff --git a/packages/vendor/src/components/onboarding-wizard/steps/store-step.tsx b/packages/vendor/src/components/onboarding-wizard/steps/store-step.tsxindex 0e46ea248..528606a62 100644--- a/packages/vendor/src/components/onboarding-wizard/steps/store-step.tsx+++ b/packages/vendor/src/components/onboarding-wizard/steps/store-step.tsx@@ -1,5 +1,7 @@-import { Button, Heading, Input, Select, Textarea } from "@medusajs/ui";+import { CheckCircleSolid, Spinner } from "@medusajs/icons";+import { Heading, Input, Select, Text, Textarea } from "@medusajs/ui";import i18n from "i18next";+import { useEffect, useState } from "react";import { useTranslation } from "react-i18next";import { useLoaderData } from "react-router-dom";import * as z from "zod";@@ -11,8 +13,15 @@ import {import { Form } from "@components/common/form";import { HandleInput } from "@components/inputs/handle-input";-import { useStore } from "@hooks/api";+import { useSellerHandleAvailability, useStore } from "@hooks/api";+import { sdk } from "@lib/client";import { onboardingLoader } from "../../../pages/onboarding/loader";+import { StepActions } from "./step-actions";+import { StepProps } from "./types";++// Mirrors Medusa's `isValidHandle`, which the seller module enforces on create.+const HANDLE_REGEX = /^[\p{Ll}\p{Lo}\p{Lm}\p{N}]+(?:-[\p{Ll}\p{Lo}\p{Lm}\p{N}]+)*$/u;+const HANDLE_CHECK_DEBOUNCE_MS = 400;const StoreStepSchema = z.object({name: z.string().min(1, i18n.t("onboarding.wizard.validation.nameRequired")),@@ -20,7 +29,10 @@ const StoreStepSchema = z.object({phone: z.string().optional(),currency_code: z.string().min(1, i18n.t("onboarding.wizard.validation.currencyRequired")),description: z.string().optional(),- handle: z.string().optional(),+ handle: z+ .string()+ .min(1, i18n.t("onboarding.wizard.store.handleRequired"))+ .regex(HANDLE_REGEX, i18n.t("onboarding.wizard.store.handleInvalid")),});type StoreStepValues = z.infer<typeof StoreStepSchema>;@@ -29,12 +41,25 @@ type StoreStepSubmitValues = StoreStepValues & {additional_data?: Record<string, unknown>;};-type StoreStepProps = {- onSubmit: (data: StoreStepSubmitValues) => Promise<void>;- isPending?: boolean;+type StoreStepProps = StepProps<StoreStepSubmitValues>;++const useDebouncedValue = (value: string, delay: number) => {+ const [debounced, setDebounced] = useState(value);++ useEffect(() => {+ const timeout = setTimeout(() => setDebounced(value), delay);+ return () => clearTimeout(timeout);+ }, [value, delay]);++ return debounced;};-export const StoreStep = ({ onSubmit, isPending }: StoreStepProps) => {+export const StoreStep = ({+ onSubmit,+ onSkip,+ isLast,+ isPending,+}: StoreStepProps) => {const { t } = useTranslation();const initialData = useLoaderData() as Awaited<ReturnType<typeof onboardingLoader>@@ -57,7 +82,55 @@ export const StoreStep = ({ onSubmit, isPending }: StoreStepProps) => {},});+ const handle = form.watch("handle");+ const debouncedHandle = useDebouncedValue(handle, HANDLE_CHECK_DEBOUNCE_MS);+ const canCheckHandle = HANDLE_REGEX.test(debouncedHandle);++ const { available, reason, isFetching } = useSellerHandleAvailability(+ debouncedHandle,+ { enabled: canCheckHandle },+ );++ const isCheckingHandle =+ HANDLE_REGEX.test(handle) && (handle !== debouncedHandle || isFetching);+ const isHandleAvailable =+ !isCheckingHandle && canCheckHandle && handle === debouncedHandle && available;++ useEffect(() => {+ if (isCheckingHandle || !canCheckHandle || available !== false) {+ // RHF only re-validates on change after the first submit, so a stale+ // "taken" error has to be cleared by hand.+ if (form.getFieldState("handle").error?.type === "manual") {+ form.clearErrors("handle");+ }+ return;+ }++ form.setError("handle", {+ type: "manual",+ message:+ reason === "invalid"+ ? t("onboarding.wizard.store.handleInvalid")+ : t("onboarding.wizard.store.handleTaken"),+ });+ }, [available, reason, isCheckingHandle, canCheckHandle, form, t]);+const handleSubmit = form.handleSubmit(async (data) => {+ const result = await sdk.vendor.sellers.handleAvailability.query({+ handle: data.handle,+ });++ if (!result.available) {+ form.setError("handle", {+ type: "manual",+ message:+ result.reason === "invalid"+ ? t("onboarding.wizard.store.handleInvalid")+ : t("onboarding.wizard.store.handleTaken"),+ });+ return;+ }+await onSubmit(data);});@@ -130,14 +203,43 @@ export const StoreStep = ({ onSubmit, isPending }: StoreStepProps) => {render={({ field }) => (<Form.Item><Form.Label- optionaltooltip={t("onboarding.wizard.store.handleTooltip")}>{t("onboarding.wizard.store.handle")}</Form.Label><Form.Control>- <HandleInput {...field} />+ <HandleInput+ placeholder={t("onboarding.wizard.store.handlePlaceholder")}+ data-testid="onboarding-handle-input"+ {...field}+ /></Form.Control>+ {isCheckingHandle && (+ <div+ className="text-ui-fg-muted flex items-center gap-x-1.5"+ data-testid="onboarding-handle-checking"+ >+ <Spinner className="size-3.5 animate-spin" />+ <Text size="small" leading="compact">+ {t("onboarding.wizard.store.handleChecking")}+ </Text>+ </div>+ )}+ {isHandleAvailable && (+ <div+ className="flex items-center gap-x-1.5"+ data-testid="onboarding-handle-available"+ >+ <CheckCircleSolid className="text-ui-tag-green-icon" />+ <Text+ size="small"+ leading="compact"+ className="text-ui-tag-green-text"+ >+ {t("onboarding.wizard.store.handleAvailable")}+ </Text>+ </div>+ )}<Form.ErrorMessage /></Form.Item>)}@@ -181,9 +283,11 @@ export const StoreStep = ({ onSubmit, isPending }: StoreStepProps) => {data={store}/></div>- <Button type="submit" className="w-full" isLoading={isPending}>- {t("actions.continue")}- </Button>+ <StepActions+ onSkip={onSkip}+ isLast={isLast}+ isPending={isPending || form.formState.isSubmitting}+ /></form></Form></div>diff --git a/packages/vendor/src/components/onboarding-wizard/steps/types.ts b/packages/vendor/src/components/onboarding-wizard/steps/types.tsnew file mode 100644index 000000000..5738bf716--- /dev/null+++ b/packages/vendor/src/components/onboarding-wizard/steps/types.ts@@ -0,0 +1,11 @@+export type StepSubmission = Record<string, unknown> & {+ additional_data?: Record<string, unknown>;+};++export type StepProps<TValues extends StepSubmission = StepSubmission> = {+ onSubmit: (data: TValues) => Promise<void>;+ /** Set when the step is optional; renders the Skip button. */+ onSkip?: () => void;+ isLast: boolean;+ isPending?: boolean;+};diff --git a/packages/vendor/src/components/onboarding-wizard/wizard-sidebar.tsx b/packages/vendor/src/components/onboarding-wizard/wizard-sidebar.tsxindex 8e3c44eef..8b39374d0 100644--- a/packages/vendor/src/components/onboarding-wizard/wizard-sidebar.tsx+++ b/packages/vendor/src/components/onboarding-wizard/wizard-sidebar.tsx@@ -3,10 +3,10 @@ import { ChevronLeft } from "@medusajs/icons";import { Text } from "@medusajs/ui";import { useTranslation } from "react-i18next";-import { TOTAL_STEPS } from "./constants";type WizardSidebarProps = {currentStep: number;+ totalSteps: number;onBack?: () => void;showBack?: boolean;children: ReactNode;@@ -14,6 +14,7 @@ type WizardSidebarProps = {export const WizardSidebar = ({currentStep,+ totalSteps,onBack,showBack,children,@@ -36,7 +37,7 @@ export const WizardSidebar = ({<Text size="small" className="text-ui-fg-subtle mb-1">{t("onboarding.wizard.stepOf", {current: currentStep + 1,- total: TOTAL_STEPS,+ total: totalSteps,})}</Text>{children}diff --git a/packages/vendor/src/components/onboarding-wizard/wizard-step.tsx b/packages/vendor/src/components/onboarding-wizard/wizard-step.tsxindex b7710a0f8..29e3697ae 100644--- a/packages/vendor/src/components/onboarding-wizard/wizard-step.tsx+++ b/packages/vendor/src/components/onboarding-wizard/wizard-step.tsx@@ -1,30 +1,25 @@import { ReactNode } from "react";+import { clx } from "@medusajs/ui";import { motion } from "motion/react";type WizardStepProps = {+ active: boolean;children: ReactNode;};const stepVariants = {initial: { opacity: 0, y: 12, filter: "blur(4px)" },animate: { opacity: 1, y: 0, filter: "blur(0px)" },- exit: {- opacity: 0,- y: -8,- filter: "blur(4px)",- transition: { duration: 0.2, ease: [0.23, 1, 0.32, 1] },- },};-export const WizardStep = ({ children }: WizardStepProps) => {+export const WizardStep = ({ active, children }: WizardStepProps) => {return (<motion.divvariants={stepVariants}initial="initial"- animate="animate"- exit="exit"+ animate={active ? "animate" : "initial"}transition={{ duration: 0.35, ease: [0.23, 1, 0.32, 1] }}- className="flex flex-col"+ className={clx("flex-col", active ? "flex" : "hidden")}>{children}</motion.div>diff --git a/packages/vendor/src/hooks/api/sellers.tsx b/packages/vendor/src/hooks/api/sellers.tsxindex 0041a4537..0bbb4035f 100644--- a/packages/vendor/src/hooks/api/sellers.tsx+++ b/packages/vendor/src/hooks/api/sellers.tsx@@ -51,6 +51,26 @@ export const useSeller = (return { ...data, ...rest };};+export const useSellerHandleAvailability = (+ handle: string,+ options?: Omit<+ UseQueryOptions<+ InferClientOutput<typeof sdk.vendor.sellers.handleAvailability.query>,+ ClientError+ >,+ "queryFn" | "queryKey"+ >,+) => {+ const { data, ...rest } = useQuery({+ queryKey: [...sellersQueryKeys.all, "handle-availability", handle],+ queryFn: () => sdk.vendor.sellers.handleAvailability.query({ handle }),+ staleTime: 30_000,+ ...options,+ });++ return { ...data, ...rest };+};+export const useSellers = (query?: InferClientInput<typeof sdk.vendor.sellers.query>,options?: Omit<diff --git a/packages/vendor/src/i18n/translations/$schema.json b/packages/vendor/src/i18n/translations/$schema.jsonindex bb46280d4..ae5361d43 100644--- a/packages/vendor/src/i18n/translations/$schema.json+++ b/packages/vendor/src/i18n/translations/$schema.json@@ -15263,6 +15263,21 @@"handlePlaceholder": {"type": "string"},+ "handleRequired": {+ "type": "string"+ },+ "handleInvalid": {+ "type": "string"+ },+ "handleChecking": {+ "type": "string"+ },+ "handleAvailable": {+ "type": "string"+ },+ "handleTaken": {+ "type": "string"+ },"currency": {"type": "string"},@@ -15280,6 +15295,11 @@"handle","handleTooltip","handlePlaceholder",+ "handleRequired",+ "handleInvalid",+ "handleChecking",+ "handleAvailable",+ "handleTaken","currency","selectCurrency","currencyHint"@@ -15289,6 +15309,9 @@"skip": {"type": "string"},+ "finish": {+ "type": "string"+ },"address": {"type": "object","properties": {@@ -15451,6 +15474,7 @@"steps","store","skip",+ "finish","address","company","payment",diff --git a/packages/vendor/src/i18n/translations/ar.json b/packages/vendor/src/i18n/translations/ar.jsonindex 3fb7c8c64..294a3cfce 100644--- a/packages/vendor/src/i18n/translations/ar.json+++ b/packages/vendor/src/i18n/translations/ar.json@@ -3960,7 +3960,7 @@},"register": {"title": "انضم إلى {{name}}!",- "hint": "أدخل بياناتك وأنشئ كلمة مرور لإعداد حساب المسؤول الخاص بك.",+ "hint": "أدخل بياناتك وأنشئ كلمة مرور لإعداد حساب متجرك.","companyName": "اسم الشركة","confirmPassword": "تأكيد كلمة المرور","signUp": "إنشاء حساب",diff --git a/packages/vendor/src/i18n/translations/bg.json b/packages/vendor/src/i18n/translations/bg.jsonindex 6049b7b13..ae3d332d6 100644--- a/packages/vendor/src/i18n/translations/bg.json+++ b/packages/vendor/src/i18n/translations/bg.json@@ -3960,7 +3960,7 @@},"register": {"title": "Присъединете се към {{name}}!",- "hint": "Въведете данните си и създайте парола, за да настроите администраторския си акаунт.",+ "hint": "Въведете данните си и създайте парола, за да настроите акаунта на магазина си.","companyName": "Име на компанията","confirmPassword": "Потвърдете паролата","signUp": "Регистрация",diff --git a/packages/vendor/src/i18n/translations/bs.json b/packages/vendor/src/i18n/translations/bs.jsonindex 7e19b80e0..bb9d88b5b 100644--- a/packages/vendor/src/i18n/translations/bs.json+++ b/packages/vendor/src/i18n/translations/bs.json@@ -3958,7 +3958,7 @@},"register": {"title": "Pridružite se {{name}}!",- "hint": "Unesite svoje podatke i kreirajte lozinku da biste podesili svoj administratorski račun.",+ "hint": "Unesite svoje podatke i kreirajte lozinku da biste podesili račun svoje trgovine.","companyName": "Naziv kompanije","confirmPassword": "Potvrdite lozinku","signUp": "Registruj se",diff --git a/packages/vendor/src/i18n/translations/cs.json b/packages/vendor/src/i18n/translations/cs.jsonindex 2b07e0d9d..b1f521307 100644--- a/packages/vendor/src/i18n/translations/cs.json+++ b/packages/vendor/src/i18n/translations/cs.json@@ -3956,7 +3956,7 @@},"register": {"title": "Připojte se k {{name}}!",- "hint": "Zadejte své údaje a vytvořte heslo pro nastavení svého administrátorského účtu.",+ "hint": "Zadejte své údaje a vytvořte heslo pro nastavení účtu svého obchodu.","companyName": "Název firmy","confirmPassword": "Potvrďte heslo","signUp": "Zaregistrovat se",diff --git a/packages/vendor/src/i18n/translations/de.json b/packages/vendor/src/i18n/translations/de.jsonindex e93b414eb..cb10125b7 100644--- a/packages/vendor/src/i18n/translations/de.json+++ b/packages/vendor/src/i18n/translations/de.json@@ -3961,7 +3961,7 @@},"register": {"title": "Treten Sie {{name}} bei!",- "hint": "Geben Sie Ihre Daten ein und erstellen Sie ein Passwort, um Ihr Admin-Konto einzurichten.",+ "hint": "Geben Sie Ihre Daten ein und erstellen Sie ein Passwort, um Ihr Shop-Konto einzurichten.","companyName": "Firmenname","confirmPassword": "Passwort bestätigen","signUp": "Registrieren",diff --git a/packages/vendor/src/i18n/translations/el.json b/packages/vendor/src/i18n/translations/el.jsonindex 7112dbe3d..ed124e114 100644--- a/packages/vendor/src/i18n/translations/el.json+++ b/packages/vendor/src/i18n/translations/el.json@@ -3960,7 +3960,7 @@},"register": {"title": "Γίνετε μέλος του {{name}}!",- "hint": "Εισαγάγετε τα στοιχεία σας και δημιουργήστε κωδικό πρόσβασης για να ρυθμίσετε τον λογαριασμό διαχειριστή σας.",+ "hint": "Εισαγάγετε τα στοιχεία σας και δημιουργήστε κωδικό πρόσβασης για να ρυθμίσετε τον λογαριασμό του καταστήματός σας.","companyName": "Όνομα εταιρείας","confirmPassword": "Επιβεβαίωση κωδικού πρόσβασης","signUp": "Εγγραφή",diff --git a/packages/vendor/src/i18n/translations/en.json b/packages/vendor/src/i18n/translations/en.jsonindex bbbb3842b..52614328d 100644--- a/packages/vendor/src/i18n/translations/en.json+++ b/packages/vendor/src/i18n/translations/en.json@@ -3759,7 +3759,7 @@},"register": {"title": "Join {{name}}!",- "hint": "Enter your details and create a password to set up your admin account.",+ "hint": "Enter your details and create a password to set up your store account.","companyName": "Company name","confirmPassword": "Confirm password","signUp": "Sign up",@@ -3834,13 +3834,19 @@"name": "Name","email": "Email","handle": "Handle",- "handleTooltip": "The handle becomes the URL slug for your store. Leave empty to auto-generate from the name.",+ "handleTooltip": "The handle becomes the URL slug for your store. Use lowercase letters, numbers and hyphens.","handlePlaceholder": "my-store",+ "handleRequired": "Handle is required",+ "handleInvalid": "Use lowercase letters, numbers and single hyphens",+ "handleChecking": "Checking availability…",+ "handleAvailable": "This handle is available",+ "handleTaken": "This handle is already taken","currency": "Currency","selectCurrency": "Select","currencyHint": "Cannot be changed after store is created"},"skip": "Skip",+ "finish": "Finish","address": {"title": "Enter your address","name": "Name",diff --git a/packages/vendor/src/i18n/translations/es.json b/packages/vendor/src/i18n/translations/es.jsonindex 4bb386bae..45ab48621 100644--- a/packages/vendor/src/i18n/translations/es.json+++ b/packages/vendor/src/i18n/translations/es.json@@ -3980,7 +3980,7 @@},"register": {"title": "¡Únete a {{name}}!",- "hint": "Introduce tus datos y crea una contraseña para configurar tu cuenta de administrador.",+ "hint": "Introduce tus datos y crea una contraseña para configurar la cuenta de tu tienda.","companyName": "Nombre de la empresa","confirmPassword": "Confirmar contraseña","signUp": "Regístrate",diff --git a/packages/vendor/src/i18n/translations/fa.json b/packages/vendor/src/i18n/translations/fa.jsonindex ad5b27cdd..9fb851a05 100644--- a/packages/vendor/src/i18n/translations/fa.json+++ b/packages/vendor/src/i18n/translations/fa.json@@ -3960,7 +3960,7 @@},"register": {"title": "به {{name}} بپیوندید!",- "hint": "جزئیات خود را وارد کرده و برای راهاندازی حساب مدیریت خود، رمز عبوری ایجاد کنید.",+ "hint": "جزئیات خود را وارد کرده و برای راهاندازی حساب فروشگاه خود، رمز عبوری ایجاد کنید.","companyName": "نام شرکت","confirmPassword": "تأیید رمز عبور","signUp": "ثبتنام",diff --git a/packages/vendor/src/i18n/translations/fr.json b/packages/vendor/src/i18n/translations/fr.jsonindex 343d95434..c3a17d2ee 100644--- a/packages/vendor/src/i18n/translations/fr.json+++ b/packages/vendor/src/i18n/translations/fr.json@@ -3961,7 +3961,7 @@},"register": {"title": "Rejoignez {{name}} !",- "hint": "Saisissez vos informations et créez un mot de passe pour configurer votre compte administrateur.",+ "hint": "Saisissez vos informations et créez un mot de passe pour configurer le compte de votre boutique.","companyName": "Nom de l'entreprise","confirmPassword": "Confirmer le mot de passe","signUp": "S'inscrire",diff --git a/packages/vendor/src/i18n/translations/he.json b/packages/vendor/src/i18n/translations/he.jsonindex 4642750e0..dfdbcf5b8 100644--- a/packages/vendor/src/i18n/translations/he.json+++ b/packages/vendor/src/i18n/translations/he.json@@ -3956,7 +3956,7 @@},"register": {"title": "הצטרף אל {{name}}!",- "hint": "הזן את הפרטים שלך וצור סיסמה כדי להגדיר את חשבון הניהול שלך.",+ "hint": "הזן את הפרטים שלך וצור סיסמה כדי להגדיר את חשבון החנות שלך.","companyName": "שם החברה","confirmPassword": "אשר סיסמה","signUp": "הירשם",diff --git a/packages/vendor/src/i18n/translations/hu.json b/packages/vendor/src/i18n/translations/hu.jsonindex 3465d43fb..35938f3a7 100644--- a/packages/vendor/src/i18n/translations/hu.json+++ b/packages/vendor/src/i18n/translations/hu.json@@ -3959,7 +3959,7 @@},"register": {"title": "Csatlakozzon ehhez: {{name}}!",- "hint": "Adja meg adatait, és hozzon létre jelszót az admin fiók beállításához.",+ "hint": "Adja meg adatait, és hozzon létre jelszót az áruházfiókja beállításához.","companyName": "Cégnév","confirmPassword": "Jelszó megerősítése","signUp": "Regisztráció",diff --git a/packages/vendor/src/i18n/translations/id.json b/packages/vendor/src/i18n/translations/id.jsonindex 33d3c37c4..d3d63d60a 100644--- a/packages/vendor/src/i18n/translations/id.json+++ b/packages/vendor/src/i18n/translations/id.json@@ -3956,7 +3956,7 @@},"register": {"title": "Bergabung dengan {{name}}!",- "hint": "Masukkan detail Anda dan buat kata sandi untuk mengatur akun admin Anda.",+ "hint": "Masukkan detail Anda dan buat kata sandi untuk mengatur akun toko Anda.","companyName": "Nama perusahaan","confirmPassword": "Konfirmasi kata sandi","signUp": "Daftar",diff --git a/packages/vendor/src/i18n/translations/it.json b/packages/vendor/src/i18n/translations/it.jsonindex 1e81c8f99..5e641b952 100644--- a/packages/vendor/src/i18n/translations/it.json+++ b/packages/vendor/src/i18n/translations/it.json@@ -3961,7 +3961,7 @@},"register": {"title": "Unisciti a {{name}}!",- "hint": "Inserisci i tuoi dati e crea una password per configurare il tuo account amministratore.",+ "hint": "Inserisci i tuoi dati e crea una password per configurare l'account del tuo negozio.","companyName": "Nome azienda","confirmPassword": "Conferma password","signUp": "Registrati",diff --git a/packages/vendor/src/i18n/translations/ja.json b/packages/vendor/src/i18n/translations/ja.jsonindex 4e95b1094..54cc67468 100644--- a/packages/vendor/src/i18n/translations/ja.json+++ b/packages/vendor/src/i18n/translations/ja.json@@ -3961,7 +3961,7 @@},"register": {"title": "{{name}} に参加しましょう!",- "hint": "管理者アカウントを設定するために、詳細を入力しパスワードを作成してください。",+ "hint": "ストアアカウントを設定するために、詳細を入力しパスワードを作成してください。","companyName": "会社名","confirmPassword": "パスワード(確認)","signUp": "登録する",diff --git a/packages/vendor/src/i18n/translations/ko.json b/packages/vendor/src/i18n/translations/ko.jsonindex 722be46e9..2aa032762 100644--- a/packages/vendor/src/i18n/translations/ko.json+++ b/packages/vendor/src/i18n/translations/ko.json@@ -3956,7 +3956,7 @@},"register": {"title": "{{name}}에 합류하세요!",- "hint": "관리자 계정을 설정하려면 세부 정보를 입력하고 비밀번호를 만드세요.",+ "hint": "스토어 계정을 설정하려면 세부 정보를 입력하고 비밀번호를 만드세요.","companyName": "회사명","confirmPassword": "비밀번호 확인","signUp": "가입하기",diff --git a/packages/vendor/src/i18n/translations/lt.json b/packages/vendor/src/i18n/translations/lt.jsonindex fd0f53d14..22a448796 100644--- a/packages/vendor/src/i18n/translations/lt.json+++ b/packages/vendor/src/i18n/translations/lt.json@@ -3960,7 +3960,7 @@},"register": {"title": "Prisijunkite prie „{{name}}“!",- "hint": "Įveskite savo duomenis ir sukurkite slaptažodį, kad nustatytumėte savo administratoriaus paskyrą.",+ "hint": "Įveskite savo duomenis ir sukurkite slaptažodį, kad nustatytumėte savo parduotuvės paskyrą.","companyName": "Įmonės pavadinimas","confirmPassword": "Patvirtinkite slaptažodį","signUp": "Registruotis",diff --git a/packages/vendor/src/i18n/translations/mk.json b/packages/vendor/src/i18n/translations/mk.jsonindex 90e252326..671124181 100644--- a/packages/vendor/src/i18n/translations/mk.json+++ b/packages/vendor/src/i18n/translations/mk.json@@ -3960,7 +3960,7 @@},"register": {"title": "Приклучете се на {{name}}!",- "hint": "Внесете ги вашите детали и креирајте лозинка за да ја поставите вашата администраторска сметка.",+ "hint": "Внесете ги вашите детали и креирајте лозинка за да ја поставите сметката на вашата продавница.","companyName": "Име на компанијата","confirmPassword": "Потврди лозинка","signUp": "Регистрирај се",diff --git a/packages/vendor/src/i18n/translations/mn.json b/packages/vendor/src/i18n/translations/mn.jsonindex f54f691a9..26684b9f5 100644--- a/packages/vendor/src/i18n/translations/mn.json+++ b/packages/vendor/src/i18n/translations/mn.json@@ -3960,7 +3960,7 @@},"register": {"title": "{{name}}-д нэгдээрэй!",- "hint": "Админ бүртгэлээ үүсгэхийн тулд мэдээллээ оруулж, нууц үг үүсгэнэ үү.",+ "hint": "Дэлгүүрийн бүртгэлээ үүсгэхийн тулд мэдээллээ оруулж, нууц үг үүсгэнэ үү.","companyName": "Компанийн нэр","confirmPassword": "Нууц үг баталгаажуулах","signUp": "Бүртгүүлэх",diff --git a/packages/vendor/src/i18n/translations/nl.json b/packages/vendor/src/i18n/translations/nl.jsonindex 0874f2be8..b275502a0 100644--- a/packages/vendor/src/i18n/translations/nl.json+++ b/packages/vendor/src/i18n/translations/nl.json@@ -3959,7 +3959,7 @@},"register": {"title": "Sluit je aan bij {{name}}!",- "hint": "Voer je gegevens in en maak een wachtwoord aan om je beheerdersaccount in te stellen.",+ "hint": "Voer je gegevens in en maak een wachtwoord aan om je winkelaccount in te stellen.","companyName": "Bedrijfsnaam","confirmPassword": "Wachtwoord bevestigen","signUp": "Registreren",diff --git a/packages/vendor/src/i18n/translations/ptBR.json b/packages/vendor/src/i18n/translations/ptBR.jsonindex 31103ffb9..f5538e7f8 100644--- a/packages/vendor/src/i18n/translations/ptBR.json+++ b/packages/vendor/src/i18n/translations/ptBR.json@@ -3961,7 +3961,7 @@},"register": {"title": "Junte-se a {{name}}!",- "hint": "Informe seus dados e crie uma senha para configurar sua conta de administrador.",+ "hint": "Informe seus dados e crie uma senha para configurar a conta da sua loja.","companyName": "Nome da empresa","confirmPassword": "Confirmar senha","signUp": "Cadastre-se",diff --git a/packages/vendor/src/i18n/translations/ptPT.json b/packages/vendor/src/i18n/translations/ptPT.jsonindex c20ef460a..b1f11fe12 100644--- a/packages/vendor/src/i18n/translations/ptPT.json+++ b/packages/vendor/src/i18n/translations/ptPT.json@@ -4012,7 +4012,7 @@},"register": {"title": "Junte-se a {{name}}!",- "hint": "Introduza os seus dados e crie uma palavra-passe para configurar a sua conta de administrador.",+ "hint": "Introduza os seus dados e crie uma palavra-passe para configurar a conta da sua loja.","companyName": "Nome da empresa","confirmPassword": "Confirmar palavra-passe","signUp": "Registar",diff --git a/packages/vendor/src/i18n/translations/ro.json b/packages/vendor/src/i18n/translations/ro.jsonindex 3a22853db..f7adc96cb 100644--- a/packages/vendor/src/i18n/translations/ro.json+++ b/packages/vendor/src/i18n/translations/ro.json@@ -3960,7 +3960,7 @@},"register": {"title": "Alăturați-vă {{name}}!",- "hint": "Introduceți detaliile și creați o parolă pentru a vă configura contul de administrator.",+ "hint": "Introduceți detaliile și creați o parolă pentru a configura contul magazinului dvs.","companyName": "Nume companie","confirmPassword": "Confirmă parola","signUp": "Înregistrare",diff --git a/packages/vendor/src/i18n/translations/ru.json b/packages/vendor/src/i18n/translations/ru.jsonindex cb5edf724..c48c7cc93 100644--- a/packages/vendor/src/i18n/translations/ru.json+++ b/packages/vendor/src/i18n/translations/ru.json@@ -3960,7 +3960,7 @@},"register": {"title": "Присоединяйтесь к {{name}}!",- "hint": "Введите свои данные и создайте пароль, чтобы настроить учётную запись администратора.",+ "hint": "Введите свои данные и создайте пароль, чтобы настроить учётную запись магазина.","companyName": "Название компании","confirmPassword": "Подтвердите пароль","signUp": "Зарегистрироваться",diff --git a/packages/vendor/src/i18n/translations/th.json b/packages/vendor/src/i18n/translations/th.jsonindex 17aa34e7e..a2fcecb50 100644--- a/packages/vendor/src/i18n/translations/th.json+++ b/packages/vendor/src/i18n/translations/th.json@@ -3961,7 +3961,7 @@},"register": {"title": "เข้าร่วม {{name}}!",- "hint": "กรอกรายละเอียดของคุณและสร้างรหัสผ่านเพื่อตั้งค่าบัญชีผู้ดูแลระบบ",+ "hint": "กรอกรายละเอียดของคุณและสร้างรหัสผ่านเพื่อตั้งค่าบัญชีร้านค้าของคุณ","companyName": "ชื่อบริษัท","confirmPassword": "ยืนยันรหัสผ่าน","signUp": "สมัครสมาชิก",diff --git a/packages/vendor/src/i18n/translations/tr.json b/packages/vendor/src/i18n/translations/tr.jsonindex de1dfd898..afb9f0985 100644--- a/packages/vendor/src/i18n/translations/tr.json+++ b/packages/vendor/src/i18n/translations/tr.json@@ -3960,7 +3960,7 @@},"register": {"title": "{{name}}'e katılın!",- "hint": "Yönetici hesabınızı oluşturmak için detaylarınızı girin ve bir şifre oluşturun.",+ "hint": "Mağaza hesabınızı oluşturmak için detaylarınızı girin ve bir şifre oluşturun.","companyName": "Şirket adı","confirmPassword": "Şifreyi onayla","signUp": "Kaydol",diff --git a/packages/vendor/src/i18n/translations/uk.json b/packages/vendor/src/i18n/translations/uk.jsonindex 03c31ea64..7819288d1 100644--- a/packages/vendor/src/i18n/translations/uk.json+++ b/packages/vendor/src/i18n/translations/uk.json@@ -3961,7 +3961,7 @@},"register": {"title": "Приєднуйтесь до {{name}}!",- "hint": "Введіть свої дані та створіть пароль, щоб налаштувати обліковий запис адміністратора.",+ "hint": "Введіть свої дані та створіть пароль, щоб налаштувати обліковий запис магазину.","companyName": "Назва компанії","confirmPassword": "Підтвердіть пароль","signUp": "Зареєструватися",diff --git a/packages/vendor/src/i18n/translations/vi.json b/packages/vendor/src/i18n/translations/vi.jsonindex b974fac4d..667c2f082 100644--- a/packages/vendor/src/i18n/translations/vi.json+++ b/packages/vendor/src/i18n/translations/vi.json@@ -3956,7 +3956,7 @@},"register": {"title": "Tham gia {{name}}!",- "hint": "Nhập thông tin của bạn và tạo mật khẩu để thiết lập tài khoản quản trị.",+ "hint": "Nhập thông tin của bạn và tạo mật khẩu để thiết lập tài khoản cửa hàng.","companyName": "Tên công ty","confirmPassword": "Xác nhận mật khẩu","signUp": "Đăng ký",diff --git a/packages/vendor/src/i18n/translations/zhCN.json b/packages/vendor/src/i18n/translations/zhCN.jsonindex 56581dbf0..23803b23b 100644--- a/packages/vendor/src/i18n/translations/zhCN.json+++ b/packages/vendor/src/i18n/translations/zhCN.json@@ -3956,7 +3956,7 @@},"register": {"title": "加入 {{name}}!",- "hint": "请输入您的信息并创建密码,以设置您的管理员账户。",+ "hint": "请输入您的信息并创建密码,以设置您的店铺账户。","companyName": "公司名称","confirmPassword": "确认密码","signUp": "注册",diff --git a/packages/vendor/src/i18n/translations/zhTW.json b/packages/vendor/src/i18n/translations/zhTW.jsonindex 42536a4bd..17d7d737c 100644--- a/packages/vendor/src/i18n/translations/zhTW.json+++ b/packages/vendor/src/i18n/translations/zhTW.json@@ -4012,7 +4012,7 @@},"register": {"title": "加入 {{name}}!",- "hint": "輸入您的詳細資料並建立密碼以設定您的管理帳戶。",+ "hint": "輸入您的詳細資料並建立密碼以設定您的商店帳戶。","companyName": "公司名稱","confirmPassword": "確認密碼","signUp": "註冊",diff --git a/packages/vendor/src/pages/login/login.tsx b/packages/vendor/src/pages/login/login.tsxindex dec4f07a4..cce9d3b10 100644--- a/packages/vendor/src/pages/login/login.tsx+++ b/packages/vendor/src/pages/login/login.tsx@@ -96,6 +96,7 @@ const LoginForm = () => {},onSuccess: () => {const email = form.getValues("email");+ sessionStorage.setItem("mercur_onboarding_email", email);setTimeout(() => {navigate("/store-select", {replace: true,diff --git a/packages/vendor/src/pages/store-select/store-select.tsx b/packages/vendor/src/pages/store-select/store-select.tsxindex a0daa5252..44bf086b3 100644--- a/packages/vendor/src/pages/store-select/store-select.tsx+++ b/packages/vendor/src/pages/store-select/store-select.tsx@@ -2,7 +2,7 @@ import { Children, ReactNode } from "react";import { ChevronRight, Plus, Spinner } from "@medusajs/icons";import { Avatar, Heading, StatusBadge, Text } from "@medusajs/ui";import { useTranslation } from "react-i18next";-import { useLocation, useNavigate } from "react-router-dom";+import { Navigate, useLocation, useNavigate } from "react-router-dom";import { DisplayExtensionZone, DisplayField } from "@mercurjs/dashboard-shared";@@ -139,7 +139,7 @@ const StoreSelectFooter = () => {const Root = ({ children }: { children?: ReactNode }) => {const location = useLocation();const email = (location.state as { email?: string })?.email ?? "";- const { seller_members, isLoading } = useSellers();+ const { seller_members, isLoading, isSuccess } = useSellers();if (isLoading) {return (@@ -151,6 +151,10 @@ const Root = ({ children }: { children?: ReactNode }) => {);}+ if (isSuccess && !seller_members?.length) {+ return <Navigate to="/onboarding" replace state={{ email }} />;+ }+return (<AuthLayout>{Children.count(children) > 0 ? (