Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

Fix/admin stores qa pass (#888)

Jakub Sieradzki96355cd1ee08
diff --git a/packages/admin/src/components/common/switch-box/switch-box.tsx b/packages/admin/src/components/common/switch-box/switch-box.tsx
index 85297d496..ac51c647e 100644
--- a/packages/admin/src/components/common/switch-box/switch-box.tsx
+++ b/packages/admin/src/components/common/switch-box/switch-box.tsx
@@ -50,7 +50,7 @@ export const SwitchBox = <
<div className="bg-ui-bg-component shadow-elevation-card-rest flex items-start gap-x-3 rounded-lg p-3">
<Form.Control>
<Switch
- className="rtl:rotate-180"
+ className="mt-0.5 shrink-0 rtl:rotate-180"
dir="ltr"
{...field}
checked={value}
diff --git a/packages/admin/src/components/data-grid/components/data-grid-select-cell.tsx b/packages/admin/src/components/data-grid/components/data-grid-select-cell.tsx
index 678588b1c..188509a5e 100644
--- a/packages/admin/src/components/data-grid/components/data-grid-select-cell.tsx
+++ b/packages/admin/src/components/data-grid/components/data-grid-select-cell.tsx
@@ -1,55 +1,111 @@
-// Not currently used, re-implement or delete depending on whether there is a need for it in the future.
-
-// import { Select, clx } from "@medusajs/ui"
-// import { Controller } from "react-hook-form"
-// import { useDataGridCell } from "../hooks"
-// import { DataGridCellProps } from "../types"
-// import { DataGridCellContainer } from "./data-grid-cell-container"
-
-// interface DataGridSelectCellProps<TData, TValue = any>
-// extends DataGridCellProps<TData, TValue> {
-// options: { label: string; value: string }[]
-// }
-
-// export const DataGridSelectCell = <TData, TValue = any>({
-// context,
-// options,
-// field,
-// }: DataGridSelectCellProps<TData, TValue>) => {
-// const { control, attributes, container } = useDataGridCell({
-// field,
-// context,
-// })
-
-// return (
-// <Controller
-// control={control}
-// name={field}
-// render={({ field: { onChange, ref, ...field } }) => {
-// return (
-// <DataGridCellContainer {...container}>
-// <Select {...field} onValueChange={onChange}>
-// <Select.Trigger
-// {...attributes}
-// ref={ref}
-// className={clx(
-// "h-full w-full rounded-none bg-transparent px-4 py-2.5 shadow-none",
-// "hover:bg-transparent focus:shadow-none data-[state=open]:!shadow-none"
-// )}
-// >
-// <Select.Value />
-// </Select.Trigger>
-// <Select.Content>
-// {options.map((option) => (
-// <Select.Item key={option.value} value={option.value}>
-// {option.label}
-// </Select.Item>
-// ))}
-// </Select.Content>
-// </Select>
-// </DataGridCellContainer>
-// )
-// }}
-// />
-// )
-// }
+import { Select, clx } from "@medusajs/ui"
+import { Controller, ControllerRenderProps } from "react-hook-form"
+
+import { useCombinedRefs } from "../../../hooks/use-combined-refs"
+import { useDataGridCell, useDataGridCellError } from "../hooks"
+import { DataGridCellProps, InputProps } from "../types"
+import { DataGridCellContainer } from "./data-grid-cell-container"
+
+type Option = {
+ label: string
+ value: string
+}
+
+type DataGridSelectCellProps<TData, TValue = any> = DataGridCellProps<
+ TData,
+ TValue
+> & {
+ options: Option[]
+ placeholder?: string
+}
+
+export const DataGridSelectCell = <TData, TValue = any>({
+ context,
+ options,
+ placeholder,
+}: DataGridSelectCellProps<TData, TValue>) => {
+ const { field, control, renderProps } = useDataGridCell({ context })
+ const errorProps = useDataGridCellError({ context })
+
+ const { container, input } = renderProps
+
+ return (
+ <Controller
+ control={control}
+ name={field}
+ render={({ field }) => (
+ <DataGridCellContainer {...container} {...errorProps}>
+ <Inner
+ field={field}
+ inputProps={input}
+ options={options}
+ placeholder={placeholder}
+ />
+ </DataGridCellContainer>
+ )}
+ />
+ )
+}
+
+const Inner = ({
+ field,
+ inputProps,
+ options,
+ placeholder,
+}: {
+ field: ControllerRenderProps<any, string>
+ inputProps: InputProps
+ options: Option[]
+ placeholder?: string
+}) => {
+ const { ref, value, onChange, onBlur, ...fieldProps } = field
+ const {
+ ref: inputRef,
+ onChange: _onInputChange,
+ onBlur: onInputBlur,
+ onFocus,
+ ...attributes
+ } = inputProps
+
+ const combinedRefs = useCombinedRefs(inputRef, ref)
+
+ const selectedOption = options.find((option) => option.value === value)
+
+ return (
+ <Select
+ value={value ?? ""}
+ onValueChange={(next) => {
+ onChange(next)
+ onBlur()
+ onInputBlur()
+ }}
+ {...fieldProps}
+ >
+ <Select.Trigger
+ ref={combinedRefs as React.Ref<HTMLButtonElement>}
+ onFocus={onFocus}
+ onBlur={() => {
+ onBlur()
+ onInputBlur()
+ }}
+ className={clx(
+ "size-full rounded-none border-0 bg-transparent px-0 text-left shadow-none",
+ "focus:shadow-none data-[state=open]:!shadow-none hover:bg-transparent"
+ )}
+ tabIndex={-1}
+ {...attributes}
+ >
+ <Select.Value placeholder={placeholder}>
+ {selectedOption?.label ?? placeholder}
+ </Select.Value>
+ </Select.Trigger>
+ <Select.Content>
+ {options.map((option) => (
+ <Select.Item key={option.value} value={option.value}>
+ {option.label}
+ </Select.Item>
+ ))}
+ </Select.Content>
+ </Select>
+ )
+}
diff --git a/packages/admin/src/components/data-grid/components/index.ts b/packages/admin/src/components/data-grid/components/index.ts
index 17aa80e6a..ca8e6139c 100644
--- a/packages/admin/src/components/data-grid/components/index.ts
+++ b/packages/admin/src/components/data-grid/components/index.ts
@@ -4,6 +4,7 @@ export { DataGridMultilineCell } from "./data-grid-multiline-cell"
export { DataGridNumberCell } from "./data-grid-number-cell"
export { DataGridReadonlyCell as DataGridReadOnlyCell } from "./data-grid-readonly-cell"
export { DataGridRoot, type DataGridRootProps } from "./data-grid-root"
+export { DataGridSelectCell } from "./data-grid-select-cell"
export { DataGridSkeleton } from "./data-grid-skeleton"
export { DataGridTextCell } from "./data-grid-text-cell"
export { DataGridExpandableTextCell } from "./data-grid-textarea-modal-cell"
diff --git a/packages/admin/src/components/data-grid/data-grid.tsx b/packages/admin/src/components/data-grid/data-grid.tsx
index ccfcb3615..733948f0e 100644
--- a/packages/admin/src/components/data-grid/data-grid.tsx
+++ b/packages/admin/src/components/data-grid/data-grid.tsx
@@ -7,6 +7,7 @@ import {
DataGridNumberCell,
DataGridReadOnlyCell,
DataGridRoot,
+ DataGridSelectCell,
DataGridSkeleton,
DataGridTextCell,
DataGridExpandableTextCell,
@@ -53,4 +54,5 @@ export const DataGrid = Object.assign(_DataGrid, {
NumberCell: DataGridNumberCell,
CurrencyCell: DataGridCurrencyCell,
ReadonlyCell: DataGridReadOnlyCell,
+ SelectCell: DataGridSelectCell,
})
diff --git a/packages/admin/src/components/data-grid/hooks/use-data-grid-cell.tsx b/packages/admin/src/components/data-grid/hooks/use-data-grid-cell.tsx
index 554639eaa..007af58f6 100644
--- a/packages/admin/src/components/data-grid/hooks/use-data-grid-cell.tsx
+++ b/packages/admin/src/components/data-grid/hooks/use-data-grid-cell.tsx
@@ -209,7 +209,7 @@ export const useDataGridCell = <TData, TValue>({
}, [anchor, coords])
const fieldWithoutOverlay = useMemo(() => {
- return type === "boolean"
+ return type === "boolean" || type === "select"
}, [type])
useEffect(() => {
diff --git a/packages/admin/src/components/data-grid/types.ts b/packages/admin/src/components/data-grid/types.ts
index 0ea240298..06c1a9929 100644
--- a/packages/admin/src/components/data-grid/types.ts
+++ b/packages/admin/src/components/data-grid/types.ts
@@ -20,6 +20,7 @@ export type DataGridColumnType =
| "number"
| "boolean"
| "togglable-number"
+ | "select"
export type DataGridCoordinates = {
row: number
diff --git a/packages/admin/src/components/layout/main-layout/main-layout.tsx b/packages/admin/src/components/layout/main-layout/main-layout.tsx
index 7e973004d..620d38642 100644
--- a/packages/admin/src/components/layout/main-layout/main-layout.tsx
+++ b/packages/admin/src/components/layout/main-layout/main-layout.tsx
@@ -8,7 +8,6 @@ import {
MagnifyingGlass,
OpenRectArrowOut,
ReceiptPercent,
- Shopping,
ShoppingCart,
Tag,
Users,
@@ -325,7 +324,7 @@ const useCoreRoutes = (): Omit<INavItem, "pathname">[] => {
],
},
{
- icon: <Shopping />,
+ icon: <BuildingStorefront />,
label: t("stores.domain"),
to: "/stores",
},
diff --git a/packages/admin/src/get-route-map.tsx b/packages/admin/src/get-route-map.tsx
index f51969b17..5830e1281 100644
--- a/packages/admin/src/get-route-map.tsx
+++ b/packages/admin/src/get-route-map.tsx
@@ -813,6 +813,10 @@ export function getRouteMap({
path: "create",
lazy: () => import("./pages/stores/store-create"),
},
+ {
+ path: "bulk-edit",
+ lazy: () => import("./pages/stores/store-bulk-edit"),
+ },
],
},
{
diff --git a/packages/admin/src/hooks/api/index.ts b/packages/admin/src/hooks/api/index.ts
index c75698e4b..25efbb76f 100644
--- a/packages/admin/src/hooks/api/index.ts
+++ b/packages/admin/src/hooks/api/index.ts
@@ -27,6 +27,7 @@ export * from "./promotions";
export * from "./refund-reasons";
export * from "./regions";
export * from "./reservations";
+export * from "./members";
export * from "./sales-channels";
export * from "./sellers";
export * from "./subscription-plans";
diff --git a/packages/admin/src/hooks/api/members.tsx b/packages/admin/src/hooks/api/members.tsx
new file mode 100644
index 000000000..d9919a8a6
--- /dev/null
+++ b/packages/admin/src/hooks/api/members.tsx
@@ -0,0 +1,22 @@
+import { useQuery } from "@tanstack/react-query";
+import type { UseQueryOptions } from "@tanstack/react-query";
+
+import { sdk } from "../../lib/client";
+import { queryKeysFactory } from "../../lib/query-key-factory";
+import type { ClientError } from "@mercurjs/client";
+
+const MEMBERS_QUERY_KEY = "members" as const;
+export const membersQueryKeys = queryKeysFactory(MEMBERS_QUERY_KEY);
+
+export const useMembers = (
+ query?: { q?: string; limit?: number; offset?: number; email?: string },
+ options?: Omit<UseQueryOptions<any, ClientError>, "queryKey" | "queryFn">,
+) => {
+ const { data, ...rest } = useQuery({
+ queryFn: () => sdk.admin.members.query(query as any),
+ queryKey: membersQueryKeys.list(query ?? {}),
+ ...options,
+ });
+
+ return { ...data, ...rest };
+};
diff --git a/packages/admin/src/hooks/api/sellers.tsx b/packages/admin/src/hooks/api/sellers.tsx
index 9186463d6..507bf8375 100644
--- a/packages/admin/src/hooks/api/sellers.tsx
+++ b/packages/admin/src/hooks/api/sellers.tsx
@@ -421,6 +421,33 @@ export const useInviteSellerMember = (
});
};
+export const useAddSellerMember = (
+ sellerId: string,
+ options?: UseMutationOptions<
+ InferClientOutput<typeof sdk.admin.sellers.$id.members.mutate>,
+ ClientError,
+ Omit<
+ InferClientInput<typeof sdk.admin.sellers.$id.members.mutate>,
+ "$id"
+ >
+ >,
+) => {
+ return useMutation({
+ mutationFn: (payload) =>
+ sdk.admin.sellers.$id.members.mutate({
+ $id: sellerId,
+ ...payload,
+ }),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({
+ queryKey: sellerMembersQueryKeys.lists(),
+ });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
+
export const useRemoveSellerMember = (
sellerId: string,
memberId: string,
@@ -446,6 +473,58 @@ export const useRemoveSellerMember = (
});
};
+export const useDeleteSellerInvite = (
+ sellerId: string,
+ options?: UseMutationOptions<
+ InferClientOutput<
+ typeof sdk.admin.sellers.$id.members.invites.$inviteId.delete
+ >,
+ ClientError,
+ { invite_id: string }
+ >,
+) => {
+ return useMutation({
+ mutationFn: ({ invite_id }) =>
+ sdk.admin.sellers.$id.members.invites.$inviteId.delete({
+ $id: sellerId,
+ $inviteId: invite_id,
+ }),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({
+ queryKey: sellerInvitesQueryKeys.lists(),
+ });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
+
+export const useResendSellerInvite = (
+ sellerId: string,
+ options?: UseMutationOptions<
+ InferClientOutput<
+ typeof sdk.admin.sellers.$id.members.invites.$inviteId.resend.mutate
+ >,
+ ClientError,
+ { invite_id: string }
+ >,
+) => {
+ return useMutation({
+ mutationFn: ({ invite_id }) =>
+ sdk.admin.sellers.$id.members.invites.$inviteId.resend.mutate({
+ $id: sellerId,
+ $inviteId: invite_id,
+ }),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({
+ queryKey: sellerInvitesQueryKeys.lists(),
+ });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
+
export const useSellerInvites = (
sellerId: string,
query?: Record<string, any>,
diff --git a/packages/admin/src/hooks/table/filters/use-seller-table-filters.tsx b/packages/admin/src/hooks/table/filters/use-seller-table-filters.tsx
index 5a5dd0dd8..ee80f12b8 100644
--- a/packages/admin/src/hooks/table/filters/use-seller-table-filters.tsx
+++ b/packages/admin/src/hooks/table/filters/use-seller-table-filters.tsx
@@ -22,10 +22,6 @@ export const useSellerTableFilters = (): Filter[] => {
label: t("stores.status.suspended"),
value: "suspended",
},
- {
- label: t("stores.status.terminated"),
- value: "terminated",
- },
],
}
diff --git a/packages/admin/src/hooks/table/query/use-sellers-table-query.tsx b/packages/admin/src/hooks/table/query/use-sellers-table-query.tsx
index 6bced43d7..a5bdafbb8 100644
--- a/packages/admin/src/hooks/table/query/use-sellers-table-query.tsx
+++ b/packages/admin/src/hooks/table/query/use-sellers-table-query.tsx
@@ -1,10 +1,17 @@
import { useQueryParams } from "@hooks/use-query-params";
+import { SellerStatus } from "@mercurjs/types";
type UseSellersTableQueryProps = {
prefix?: string;
pageSize?: number;
};
+const ACTIVE_STATUSES = [
+ SellerStatus.OPEN,
+ SellerStatus.PENDING_APPROVAL,
+ SellerStatus.SUSPENDED,
+];
+
export const useSellersTableQuery = ({
prefix,
pageSize = 20,
@@ -21,7 +28,7 @@ export const useSellersTableQuery = ({
offset: offset ? Number(offset) : 0,
created_at: created_at ? JSON.parse(created_at) : undefined,
updated_at: updated_at ? JSON.parse(updated_at) : undefined,
- status: status?.split(","),
+ status: status?.split(",") ?? ACTIVE_STATUSES,
is_premium: is_premium ? is_premium === "true" : undefined,
q,
order: order ? order : undefined,
diff --git a/packages/admin/src/i18n/translations/en.json b/packages/admin/src/i18n/translations/en.json
index d4b6a975c..a2747cbb9 100644
--- a/packages/admin/src/i18n/translations/en.json
+++ b/packages/admin/src/i18n/translations/en.json
@@ -2453,6 +2453,10 @@
"pending": "Pending",
"expired": "Expired"
},
+ "status": {
+ "active": "Active",
+ "pending": "Pending"
+ },
"roles": {
"admin": "Admin",
"developer": "Developer",
@@ -2509,6 +2513,9 @@
"banner": "Banner",
"address": {
"header": "Address",
+ "defaultName": "Headquarters",
+ "nameLabel": "Name",
+ "namePlaceholder": "Headquarters",
"empty": {
"title": "No address",
"message": "There are no records to show"
@@ -2532,11 +2539,13 @@
},
"fields": {
"countryCode": "Country",
- "holderName": "Account holder",
+ "holderName": "Account name",
"bankName": "Bank name",
"iban": "IBAN",
- "bic": "BIC / SWIFT",
+ "bic": "SWIFT / BIC",
+ "swiftBic": "SWIFT / BIC",
"routingNumber": "Routing number",
+ "achRoutingNumber": "ACH routing number",
"accountNumber": "Account number"
}
},
@@ -2547,12 +2556,12 @@
"message": "There are no records to show"
},
"edit": {
- "header": "Edit Professional Details",
- "description": "Update the professional details for this store.",
- "successToast": "Professional details updated"
+ "header": "Edit Company Details",
+ "description": "Update the company details for this store.",
+ "successToast": "Company details updated"
},
"fields": {
- "corporateName": "Corporate name",
+ "corporateName": "Company",
"registrationNumber": "Registration number",
"taxId": "Tax ID"
}
@@ -3398,6 +3407,7 @@
},
"stores": {
"domain": "Stores",
+ "handleTooltip": "The handle is used as the URL slug for the store. Leave empty to auto-generate from the name.",
"fields": {
"name": "Name",
"handle": "Handle",
@@ -3415,15 +3425,15 @@
"premium": "Featured"
},
"status": {
- "open": "Open",
- "pending_approval": "Pending Approval",
- "pendingApproval": "Pending Approval",
- "suspended": "Suspended",
+ "open": "Active",
+ "pending_approval": "Pending",
+ "pendingApproval": "Pending",
+ "suspended": "Inactive",
"terminated": "Terminated"
},
"premium": {
- "yes": "Featured",
- "no": "Standard",
+ "yes": "Yes",
+ "no": "No",
"description": "If checked, the store will be highlighted with a special badge for internal use or promotional purposes."
},
"invite": {
@@ -3433,30 +3443,56 @@
"successToast": "Invitation sent to {{email}}",
"errorToast": "Failed to send invitation"
},
+ "members": {
+ "addUser": {
+ "header": "Add User",
+ "hint": "Add new user to manage this store. You can select existing user or invite new ones.",
+ "assignSuccess": "User {{email}} assigned to the store"
+ },
+ "invite": {
+ "resendSuccess": "Invite resent to {{email}}",
+ "deleteSuccess": "Invite for {{email}} deleted",
+ "linkCopied": "Invite link copied to clipboard",
+ "copyFailed": "Failed to copy invite link",
+ "noVendorUrl": "Vendor URL is not configured on the backend (MERCUR_VENDOR_URL)"
+ }
+ },
"edit": {
"header": "Edit Store",
+ "mediaHeading": "Media",
+ "mediaTipLabel": "Tip:",
+ "mediaTipBody": "This media will be visible on the storefront.",
"successToast": "Store {{name}} was successfully updated."
},
"create": {
"tabs": {
"details": "Details",
- "users": "Users"
+ "users": "Admin"
},
- "header": "Create Store",
- "hint": "Create a new store on the marketplace.",
- "usersHeader": "Users",
- "usersHint": "Invite the store owner by email. They will receive an invitation to set up their account.",
+ "header": "Details",
+ "usersHeader": "Admin",
+ "usersHint": "Assign an admin to manage this store. Select an existing user or invite a new one.",
+ "usersHintSecondary": "Once the store is created, the selected user will receive an invitation to join.",
"ownerEmail": "Owner email",
"ownerEmailHint": "The owner will be granted the Store Administration role.",
- "successToast": "Store created successfully"
+ "successToast": "Store created successfully",
+ "validation": {
+ "nameRequired": "Please enter a name",
+ "emailRequired": "Please enter an email",
+ "emailInvalid": "Please enter a valid email",
+ "currencyRequired": "Please select a currency"
+ }
},
"request": {
"title": "Store request",
- "description": "A new store request has been submitted. Review the details, make any necessary updates, and choose whether to confirm and publish the store or suspend the request.",
- "reasonLabel": "Suspend reason",
- "reasonPlaceholder": "Optional reason for suspending this store...",
+ "description": "{{requester}} has submitted a store request. Review the details, make any necessary updates, and choose whether to confirm and publish the store or reject the request.",
"confirm": "Confirm",
- "suspend": "Suspend"
+ "reject": "Reject",
+ "confirmNoteLabel": "Approval note",
+ "rejectNoteLabel": "Rejection reason",
+ "notePlaceholder": "Optional note for the vendor...",
+ "confirmSuccess": "Store approved",
+ "rejectSuccess": "Store rejected"
},
"actions": {
"approve": {
@@ -3465,34 +3501,28 @@
"description": "Are you sure you want to approve this store?",
"success": "Store approved"
},
- "suspend": {
- "label": "Suspend",
- "title": "Suspend store",
- "description": "Are you sure you want to suspend this store?",
- "success": "Store suspended",
- "successToast": "{{count}} store(s) suspended",
- "errorToast": "Failed to suspend store(s)"
- },
- "unsuspend": {
- "label": "Unsuspend",
- "title": "Unsuspend store",
- "description": "Are you sure you want to unsuspend this store?",
- "success": "Store unsuspended",
- "successToast": "{{count}} store(s) unsuspended",
- "errorToast": "Failed to unsuspend store(s)"
- },
- "terminate": {
- "label": "Terminate",
- "title": "Terminate store",
- "description": "Are you sure you want to terminate this store?",
- "success": "Store terminated"
- },
- "unterminate": {
- "label": "Unterminate",
- "title": "Unterminate store",
- "description": "Are you sure you want to unterminate this store?",
- "success": "Store unterminated"
- }
+ "reject": {
+ "label": "Reject",
+ "title": "Reject store",
+ "description": "Are you sure you want to reject this store?",
+ "success": "Store rejected"
+ },
+ "edit": {
+ "label": "Edit"
+ },
+ "delete": {
+ "label": "Delete",
+ "title": "Delete store",
+ "description": "Are you sure you want to delete this store? This action cannot be undone.",
+ "success": "Store deleted",
+ "successToast": "{{count}} store(s) deleted",
+ "errorToast": "Failed to delete store(s)"
+ }
+ },
+ "bulkEdit": {
+ "successToast": "{{count}} store(s) updated",
+ "emptyHeading": "No stores selected",
+ "emptyDescription": "Select stores from the list to edit them here."
}
},
"messages": {
diff --git a/packages/admin/src/lib/client/client.ts b/packages/admin/src/lib/client/client.ts
index 81ec4b5a7..2a23b9f47 100644
--- a/packages/admin/src/lib/client/client.ts
+++ b/packages/admin/src/lib/client/client.ts
@@ -82,18 +82,10 @@ export const uploadFilesQuery = async (files: any[]) => {
const formData = new FormData()
for (const { file } of files) {
- formData.append('files', file)
+ formData.append("files", file)
}
- const response = await fetch(`${backendUrl}/vendor/uploads`, {
- method: 'POST',
- credentials: 'include',
- body: formData,
+ return sdk.admin.uploads.mutate({
+ fetchOptions: { body: formData },
})
-
- if (!response.ok) {
- return null
- }
-
- return response.json()
}
diff --git a/packages/admin/src/pages/stores/store-address-edit/components/store-address-edit-form.tsx b/packages/admin/src/pages/stores/store-address-edit/components/store-address-edit-form.tsx
index b1cfda0d3..479cab127 100644
--- a/packages/admin/src/pages/stores/store-address-edit/components/store-address-edit-form.tsx
+++ b/packages/admin/src/pages/stores/store-address-edit/components/store-address-edit-form.tsx
@@ -19,14 +19,13 @@ type StoreAddressEditFormProps = {
};
const StoreAddressSchema = zod.object({
- first_name: zod.string().min(1),
- last_name: zod.string().min(1),
+ name: zod.string().min(1),
address_1: zod.string().optional().or(zod.literal("")),
+ address_2: zod.string().optional().or(zod.literal("")),
city: zod.string().optional().or(zod.literal("")),
province: zod.string().optional().or(zod.literal("")),
- postal_code: zod.string().min(1),
+ postal_code: zod.string().optional().or(zod.literal("")),
country_code: zod.string().min(2).max(2),
- phone: zod.string().min(1),
});
export const StoreAddressEditForm = ({
@@ -38,14 +37,13 @@ export const StoreAddressEditForm = ({
const form = useForm<zod.infer<typeof StoreAddressSchema>>({
defaultValues: {
- first_name: address?.first_name ?? "",
- last_name: address?.last_name ?? "",
+ name: address?.name ?? "",
address_1: address?.address_1 ?? "",
+ address_2: address?.address_2 ?? "",
city: address?.city ?? "",
province: address?.province ?? "",
postal_code: address?.postal_code ?? "",
country_code: address?.country_code ?? "",
- phone: address?.phone ?? "",
},
resolver: zodResolver(StoreAddressSchema),
});
@@ -55,14 +53,13 @@ export const StoreAddressEditForm = ({
const handleSubmit = form.handleSubmit(async (values) => {
await mutateAsync(
{
- first_name: values.first_name,
- last_name: values.last_name,
+ name: values.name,
address_1: values.address_1 || null,
+ address_2: values.address_2 || null,
city: values.city || null,
province: values.province || null,
- postal_code: values.postal_code,
+ postal_code: values.postal_code || null,
country_code: values.country_code,
- phone: values.phone,
},
{
onSuccess: () => {
@@ -85,34 +82,32 @@ export const StoreAddressEditForm = ({
className="flex flex-1 flex-col overflow-hidden"
>
<RouteDrawer.Body className="flex flex-col gap-y-4 overflow-y-auto">
- <div className="grid grid-cols-2 gap-4">
- <Form.Field
- control={form.control}
- name="first_name"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.firstName")}</Form.Label>
- <Form.Control>
- <Input size="small" {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="last_name"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.lastName")}</Form.Label>
- <Form.Control>
- <Input size="small" {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- </div>
+ <Form.Field
+ control={form.control}
+ name="name"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("store.address.nameLabel")}</Form.Label>
+ <Form.Control>
+ <Input size="small" placeholder={t("store.address.namePlaceholder")} {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="country_code"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.country")}</Form.Label>
+ <Form.Control>
+ <CountrySelect {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
<Form.Field
control={form.control}
name="address_1"
@@ -126,6 +121,19 @@ export const StoreAddressEditForm = ({
</Form.Item>
)}
/>
+ <Form.Field
+ control={form.control}
+ name="address_2"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label optional>{t("fields.address2")}</Form.Label>
+ <Form.Control>
+ <Input size="small" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
<div className="grid grid-cols-2 gap-4">
<Form.Field
control={form.control}
@@ -140,27 +148,12 @@ export const StoreAddressEditForm = ({
</Form.Item>
)}
/>
- <Form.Field
- control={form.control}
- name="province"
- render={({ field }) => (
- <Form.Item>
- <Form.Label optional>{t("fields.state")}</Form.Label>
- <Form.Control>
- <Input size="small" {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- </div>
- <div className="grid grid-cols-2 gap-4">
<Form.Field
control={form.control}
name="postal_code"
render={({ field }) => (
<Form.Item>
- <Form.Label>{t("fields.postalCode")}</Form.Label>
+ <Form.Label optional>{t("fields.postalCode")}</Form.Label>
<Form.Control>
<Input size="small" {...field} />
</Form.Control>
@@ -168,26 +161,13 @@ export const StoreAddressEditForm = ({
</Form.Item>
)}
/>
- <Form.Field
- control={form.control}
- name="country_code"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.country")}</Form.Label>
- <Form.Control>
- <CountrySelect {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
</div>
<Form.Field
control={form.control}
- name="phone"
+ name="province"
render={({ field }) => (
<Form.Item>
- <Form.Label>{t("fields.phone")}</Form.Label>
+ <Form.Label optional>{t("fields.state")}</Form.Label>
<Form.Control>
<Input size="small" {...field} />
</Form.Control>
diff --git a/packages/admin/src/pages/stores/store-bulk-edit/components/store-bulk-edit-form.tsx b/packages/admin/src/pages/stores/store-bulk-edit/components/store-bulk-edit-form.tsx
new file mode 100644
index 000000000..a28ad11d5
--- /dev/null
+++ b/packages/admin/src/pages/stores/store-bulk-edit/components/store-bulk-edit-form.tsx
@@ -0,0 +1,185 @@
+import { useEffect, useMemo } from "react";
+import { useForm } from "react-hook-form";
+import { useTranslation } from "react-i18next";
+import { useSearchParams } from "react-router-dom";
+import { Button, toast } from "@medusajs/ui";
+
+import {
+ DataGrid,
+ createDataGridHelper,
+} from "@components/data-grid";
+import { RouteFocusModal, useRouteModal } from "@components/modals";
+import { KeyboundForm } from "@components/utilities/keybound-form";
+import { sdk } from "@lib/client";
+import { queryClient } from "@lib/query-client";
+import { sellersQueryKeys, useSellers } from "@hooks/api/sellers";
+import { SellerDTO, SellerStatus } from "@mercurjs/types";
+
+type FormValues = {
+ statuses: Record<string, SellerStatus>;
+};
+
+const helper = createDataGridHelper<SellerDTO, FormValues>();
+
+const useColumns = () => {
+ const { t } = useTranslation();
+
+ return useMemo(
+ () => [
+ helper.column({
+ id: "name",
+ name: t("fields.name"),
+ header: t("fields.name"),
+ cell: (context) => (
+ <DataGrid.ReadonlyCell context={context} color="normal">
+ {context.row.original.name}
+ </DataGrid.ReadonlyCell>
+ ),
+ disableHiding: true,
+ }),
+ helper.column({
+ id: "status",
+ name: t("fields.status"),
+ header: t("fields.status"),
+ type: "select",
+ field: (context) =>
+ `statuses.${context.row.original.id}` as const,
+ cell: (context) => (
+ <DataGrid.SelectCell
+ context={context}
+ options={[
+ {
+ label: t("stores.status.open"),
+ value: SellerStatus.OPEN,
+ },
+ {
+ label: t("stores.status.pendingApproval"),
+ value: SellerStatus.PENDING_APPROVAL,
+ },
+ {
+ label: t("stores.status.suspended"),
+ value: SellerStatus.SUSPENDED,
+ },
+ ]}
+ />
+ ),
+ }),
+ ],
+ [t],
+ );
+};
+
+export const StoreBulkEditForm = () => {
+ const { t } = useTranslation();
+ const [searchParams] = useSearchParams();
+ const { handleSuccess, setCloseOnEscape } = useRouteModal();
+
+ const ids = useMemo(
+ () =>
+ (searchParams.get("ids") ?? "")
+ .split(",")
+ .map((id) => id.trim())
+ .filter(Boolean),
+ [searchParams],
+ );
+
+ const { sellers, isLoading } = useSellers(
+ { id: ids, limit: ids.length || 1 },
+ { enabled: ids.length > 0 },
+ );
+
+ const form = useForm<FormValues>({
+ defaultValues: { statuses: {} },
+ });
+
+ useEffect(() => {
+ if (sellers) {
+ form.reset({
+ statuses: Object.fromEntries(
+ sellers.map((s) => [s.id, s.status as SellerStatus]),
+ ),
+ });
+ }
+ }, [sellers, form]);
+
+ const columns = useColumns();
+
+ const handleSubmit = form.handleSubmit(async ({ statuses }) => {
+ if (!sellers) return;
+
+ const updates = sellers
+ .filter((seller) => statuses[seller.id] !== seller.status)
+ .map((seller) =>
+ sdk.admin.sellers.$id.mutate({
+ $id: seller.id,
+ status: statuses[seller.id],
+ }),
+ );
+
+ if (!updates.length) {
+ handleSuccess();
+ return;
+ }
+
+ try {
+ await Promise.all(updates);
+ await queryClient.invalidateQueries({
+ queryKey: sellersQueryKeys.lists(),
+ });
+ toast.success(
+ t("stores.bulkEdit.successToast", { count: updates.length }),
+ );
+ handleSuccess();
+ } catch (error) {
+ toast.error((error as Error).message);
+ }
+ });
+
+ const { isSubmitting } = form.formState;
+
+ return (
+ <RouteFocusModal.Form form={form} data-testid="store-bulk-edit-form">
+ <KeyboundForm onSubmit={handleSubmit} className="flex size-full flex-col">
+ <RouteFocusModal.Header data-testid="store-bulk-edit-form-header" />
+ <RouteFocusModal.Body
+ className="flex flex-col overflow-hidden"
+ data-testid="store-bulk-edit-form-body"
+ >
+ <DataGrid
+ state={form}
+ columns={columns}
+ data={sellers ?? []}
+ isLoading={isLoading}
+ onEditingChange={(editing) => setCloseOnEscape(!editing)}
+ disableInteractions={isSubmitting}
+ data-testid="store-bulk-edit-data-grid"
+ />
+ </RouteFocusModal.Body>
+ <RouteFocusModal.Footer data-testid="store-bulk-edit-form-footer">
+ <div className="flex items-center justify-end gap-x-2">
+ <RouteFocusModal.Close asChild>
+ <Button
+ size="small"
+ variant="secondary"
+ type="button"
+ data-testid="store-bulk-edit-cancel-button"
+ >
+ {t("actions.cancel")}
+ </Button>
+ </RouteFocusModal.Close>
+ <Button
+ size="small"
+ type="submit"
+ isLoading={isSubmitting}
+ data-testid="store-bulk-edit-save-button"
+ >
+ {t("actions.save")}
+ </Button>
+ </div>
+ </RouteFocusModal.Footer>
+ </KeyboundForm>
+ </RouteFocusModal.Form>
+ );
+};
+
+export default StoreBulkEditForm;
diff --git a/packages/admin/src/pages/stores/store-bulk-edit/index.tsx b/packages/admin/src/pages/stores/store-bulk-edit/index.tsx
new file mode 100644
index 000000000..6217e616b
--- /dev/null
+++ b/packages/admin/src/pages/stores/store-bulk-edit/index.tsx
@@ -0,0 +1,15 @@
+import { RouteFocusModal } from "../../../components/modals";
+
+import { StoreBulkEditForm } from "./components/store-bulk-edit-form";
+
+const Root = () => (
+ <RouteFocusModal>
+ <StoreBulkEditForm />
+ </RouteFocusModal>
+);
+
+export const StoreBulkEditPage = Object.assign(Root, {
+ Form: StoreBulkEditForm,
+});
+
+export const Component = Root;
diff --git a/packages/admin/src/pages/stores/store-create/components/schema.ts b/packages/admin/src/pages/stores/store-create/components/schema.ts
index 5e904222a..036e0e006 100644
--- a/packages/admin/src/pages/stores/store-create/components/schema.ts
+++ b/packages/admin/src/pages/stores/store-create/components/schema.ts
@@ -1,12 +1,23 @@
+import i18n from "i18next";
import { z } from "zod";
export const CreateStoreSchema = z.object({
- name: z.string().min(1),
- email: z.string().email(),
- currency_code: z.string().min(1),
- description: z.string().optional().or(z.literal("")),
+ name: z
+ .string()
+ .min(1, { message: i18n.t("stores.create.validation.nameRequired") }),
+ email: z
+ .string()
+ .min(1, { message: i18n.t("stores.create.validation.emailRequired") })
+ .email({ message: i18n.t("stores.create.validation.emailInvalid") }),
+ phone: z.string().optional().or(z.literal("")),
+ currency_code: z
+ .string()
+ .min(1, { message: i18n.t("stores.create.validation.currencyRequired") }),
handle: z.string().optional().or(z.literal("")),
- member_email: z.string().email(),
+ member_email: z
+ .string()
+ .min(1, { message: i18n.t("stores.create.validation.emailRequired") })
+ .email({ message: i18n.t("stores.create.validation.emailInvalid") }),
});
export type CreateStoreSchemaType = z.infer<typeof CreateStoreSchema>;
diff --git a/packages/admin/src/pages/stores/store-create/components/store-create-details-tab.tsx b/packages/admin/src/pages/stores/store-create/components/store-create-details-tab.tsx
index 86bd0e59a..d88d20709 100644
--- a/packages/admin/src/pages/stores/store-create/components/store-create-details-tab.tsx
+++ b/packages/admin/src/pages/stores/store-create/components/store-create-details-tab.tsx
@@ -1,7 +1,8 @@
-import { Heading, Input, Select, Text, Textarea } from "@medusajs/ui";
+import { Heading, Input, Select } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
import { Form } from "../../../../components/common/form";
+import { HandleInput } from "../../../../components/inputs/handle-input";
import { useTabbedForm } from "../../../../components/tabbed-form/tabbed-form";
import { defineTabMeta } from "../../../../components/tabbed-form/types";
import { useStore } from "../../../../hooks/api";
@@ -16,13 +17,7 @@ const Root = () => {
<div className="flex flex-1 flex-col items-center overflow-y-auto px-3">
<div className="mx-auto flex w-full max-w-[720px] flex-col gap-y-8 px-px py-16">
<div>
- <Heading>{t("stores.create.header", "Create Store")}</Heading>
- <Text size="small" className="text-ui-fg-subtle">
- {t(
- "stores.create.hint",
- "Create a new store on the marketplace.",
- )}
- </Text>
+ <Heading>{t("stores.create.header")}</Heading>
</div>
<div className="flex flex-col gap-y-4">
<Form.Field
@@ -43,9 +38,11 @@ const Root = () => {
name="handle"
render={({ field }) => (
<Form.Item>
- <Form.Label optional>{t("fields.handle")}</Form.Label>
+ <Form.Label optional tooltip={t("stores.handleTooltip")}>
+ {t("fields.handle")}
+ </Form.Label>
<Form.Control>
- <Input {...field} />
+ <HandleInput {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
@@ -64,6 +61,19 @@ const Root = () => {
</Form.Item>
)}
/>
+ <Form.Field
+ control={form.control}
+ name="phone"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label optional>{t("fields.phone")}</Form.Label>
+ <Form.Control>
+ <Input type="tel" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
<Form.Field
control={form.control}
name="currency_code"
@@ -91,19 +101,6 @@ const Root = () => {
</Form.Item>
)}
/>
- <Form.Field
- control={form.control}
- name="description"
- render={({ field }) => (
- <Form.Item>
- <Form.Label optional>{t("fields.description")}</Form.Label>
- <Form.Control>
- <Textarea {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
</div>
</div>
</div>
@@ -113,7 +110,7 @@ const Root = () => {
Root._tabMeta = defineTabMeta<CreateStoreSchemaType>({
id: "details",
labelKey: "stores.create.tabs.details",
- validationFields: ["name", "email", "currency_code"],
+ validationFields: ["name", "email", "phone", "currency_code"],
});
export const StoreCreateDetailsTab = Root;
diff --git a/packages/admin/src/pages/stores/store-create/components/store-create-form.tsx b/packages/admin/src/pages/stores/store-create/components/store-create-form.tsx
index f6e6fd1a6..bd12c2527 100644
--- a/packages/admin/src/pages/stores/store-create/components/store-create-form.tsx
+++ b/packages/admin/src/pages/stores/store-create/components/store-create-form.tsx
@@ -24,8 +24,8 @@ export const StoreCreateForm = ({ children }: StoreCreateFormProps) => {
defaultValues: {
name: "",
email: "",
+ phone: "",
currency_code: "",
- description: "",
handle: "",
member_email: "",
},
@@ -39,8 +39,8 @@ export const StoreCreateForm = ({ children }: StoreCreateFormProps) => {
await createSeller({
name: values.name,
email: values.email,
+ phone: values.phone || undefined,
currency_code: values.currency_code,
- description: values.description || undefined,
handle: values.handle || undefined,
member: {
email: values.member_email,
diff --git a/packages/admin/src/pages/stores/store-create/components/store-create-users-tab.tsx b/packages/admin/src/pages/stores/store-create/components/store-create-users-tab.tsx
index 498ff6847..926a98ebd 100644
--- a/packages/admin/src/pages/stores/store-create/components/store-create-users-tab.tsx
+++ b/packages/admin/src/pages/stores/store-create/components/store-create-users-tab.tsx
@@ -14,12 +14,12 @@ const Root = () => {
<div className="flex flex-1 flex-col items-center overflow-y-auto px-3">
<div className="mx-auto flex w-full max-w-[720px] flex-col gap-y-8 px-px py-16">
<div>
- <Heading>{t("stores.create.usersHeader", "Users")}</Heading>
+ <Heading>{t("stores.create.usersHeader")}</Heading>
<Text size="small" className="text-ui-fg-subtle">
- {t(
- "stores.create.usersHint",
- "Invite the store owner by email. They will receive an invitation to set up their account.",
- )}
+ {t("stores.create.usersHint")}
+ </Text>
+ <Text size="small" className="text-ui-fg-subtle mt-1">
+ {t("stores.create.usersHintSecondary")}
</Text>
</div>
<div className="flex flex-col gap-y-4">
@@ -28,22 +28,14 @@ const Root = () => {
name="member_email"
render={({ field }) => (
<Form.Item>
- <Form.Label optional>
- {t("stores.create.ownerEmail", "Owner email")}
- </Form.Label>
+ <Form.Label>{t("fields.email")}</Form.Label>
<Form.Control>
<Input
type="email"
{...field}
- placeholder="[email protected]"
+ placeholder="[email protected]"
/>
</Form.Control>
- <Form.Hint>
- {t(
- "stores.create.ownerEmailHint",
- "The owner will be granted the Store Administration role.",
- )}
- </Form.Hint>
<Form.ErrorMessage />
</Form.Item>
)}
diff --git a/packages/admin/src/pages/stores/store-details/components/store-address-section.tsx b/packages/admin/src/pages/stores/store-details/components/store-address-section.tsx
index 94a76e33a..86f1f60b6 100644
--- a/packages/admin/src/pages/stores/store-details/components/store-address-section.tsx
+++ b/packages/admin/src/pages/stores/store-details/components/store-address-section.tsx
@@ -58,9 +58,7 @@ export const StoreAddressSection = ({ seller }: StoreAddressSectionProps) => {
</IconAvatar>
<div className="flex flex-1 flex-col">
<Text size="small" leading="compact" weight="plus">
- {[address?.first_name, address?.last_name]
- .filter(Boolean)
- .join(" ") || address?.company || formattedAddress}
+ {address?.name || t("store.address.defaultName")}
</Text>
<Text
size="small"
diff --git a/packages/admin/src/pages/stores/store-details/components/store-configuration-section.tsx b/packages/admin/src/pages/stores/store-details/components/store-configuration-section.tsx
index ee897df0b..671bee1e6 100644
--- a/packages/admin/src/pages/stores/store-details/components/store-configuration-section.tsx
+++ b/packages/admin/src/pages/stores/store-details/components/store-configuration-section.tsx
@@ -1,8 +1,6 @@
-import { PencilSquare } from "@medusajs/icons";
import { Container, Heading, Table, Text } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
-import { ActionMenu } from "../../../../components/common/action-menu";
import { DateCell } from "../../../../components/table/table-cells/common/date-cell";
import { InferClientOutput } from "@mercurjs/client";
import { sdk } from "@lib/client";
@@ -23,19 +21,6 @@ export const StoreConfigurationSection = ({
<Container className="divide-y p-0">
<div className="flex items-center justify-between px-6 py-4">
<Heading level="h2">{t("store.timeOff.header")}</Heading>
- <ActionMenu
- groups={[
- {
- actions: [
- {
- label: t("actions.edit"),
- icon: <PencilSquare />,
- to: `/stores/${seller.id}/store-closure`,
- },
- ],
- },
- ]}
- />
</div>
{hasTimeOff ? (
<Table>
diff --git a/packages/admin/src/pages/stores/store-details/components/store-detail-header.tsx b/packages/admin/src/pages/stores/store-details/components/store-detail-header.tsx
index 89d1d8169..5d4bebde9 100644
--- a/packages/admin/src/pages/stores/store-details/components/store-detail-header.tsx
+++ b/packages/admin/src/pages/stores/store-details/components/store-detail-header.tsx
@@ -2,21 +2,17 @@ import { Children, ReactNode } from "react";
import {
CheckCircleSolid,
PencilSquare,
+ Trash,
XCircleSolid,
- XMarkMini,
- ArrowUturnLeft,
} from "@medusajs/icons";
-import { Avatar, Heading, StatusBadge, toast, usePrompt } from "@medusajs/ui";
+import { Avatar, Heading, StatusBadge, Tooltip, toast, usePrompt } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
import { TFunction } from "i18next";
import { ActionMenu } from "../../../../components/common/action-menu";
import {
useApproveSeller,
- useSuspendSeller,
- useUnsuspendSeller,
useTerminateSeller,
- useUnterminateSeller,
} from "@/hooks/api/sellers";
import { InferClientOutput } from "@mercurjs/client";
import { sdk } from "@lib/client";
@@ -58,6 +54,8 @@ const getStatusLabel = (status: string, t: TFunction) => {
};
export const StoreDetailTitle = ({ seller }: StoreProps) => {
+ const { t } = useTranslation();
+
return (
<div className="flex items-center gap-x-4">
<Avatar
@@ -66,7 +64,14 @@ export const StoreDetailTitle = ({ seller }: StoreProps) => {
src={seller.logo || undefined}
fallback={seller.name.charAt(0).toUpperCase()}
/>
- <Heading>{seller.name}</Heading>
+ <div className="flex items-center gap-x-2">
+ <Heading>{seller.name}</Heading>
+ {seller.is_premium && (
+ <Tooltip content={t("stores.fields.premium")}>
+ <CheckCircleSolid className="text-ui-tag-blue-icon" />
+ </Tooltip>
+ )}
+ </div>
</div>
);
};
@@ -98,10 +103,7 @@ export const StoreDetailActions = ({
const prompt = usePrompt();
const { mutateAsync: approveSeller } = useApproveSeller(seller.id);
- const { mutateAsync: suspendSeller } = useSuspendSeller(seller.id);
- const { mutateAsync: unsuspendSeller } = useUnsuspendSeller(seller.id);
const { mutateAsync: terminateSeller } = useTerminateSeller(seller.id);
- const { mutateAsync: unterminateSeller } = useUnterminateSeller(seller.id);
const handleAction = async (
action: () => Promise<unknown>,
@@ -123,6 +125,17 @@ export const StoreDetailActions = ({
);
};
+ const deleteAction = {
+ label: t("stores.actions.delete.label"),
+ onClick: () =>
+ handleAction(() => terminateSeller(), {
+ title: t("stores.actions.delete.title"),
+ description: t("stores.actions.delete.description"),
+ success: t("stores.actions.delete.success"),
+ }),
+ icon: <Trash />,
+ };
+
const statusActions = (() => {
switch (seller.status) {
case SellerStatus.PENDING_APPROVAL:
@@ -138,65 +151,19 @@ export const StoreDetailActions = ({
icon: <CheckCircleSolid />,
},
{
- label: t("stores.actions.terminate.label"),
+ label: t("stores.actions.reject.label"),
onClick: () =>
handleAction(() => terminateSeller(), {
- title: t("stores.actions.terminate.title"),
- description: t("stores.actions.terminate.description"),
- success: t("stores.actions.terminate.success"),
+ title: t("stores.actions.reject.title"),
+ description: t("stores.actions.reject.description"),
+ success: t("stores.actions.reject.success"),
}),
icon: <XCircleSolid />,
},
];
case SellerStatus.OPEN:
- return [
- {
- label: t("stores.actions.suspend.label"),
- onClick: () =>
- handleAction(() => suspendSeller(), {
- title: t("stores.actions.suspend.title"),
- description: t("stores.actions.suspend.description"),
- success: t("stores.actions.suspend.success"),
- }),
- icon: <XMarkMini />,
- },
- ];
case SellerStatus.SUSPENDED:
- return [
- {
- label: t("stores.actions.unsuspend.label"),
- onClick: () =>
- handleAction(() => unsuspendSeller(), {
- title: t("stores.actions.unsuspend.title"),
- description: t("stores.actions.unsuspend.description"),
- success: t("stores.actions.unsuspend.success"),
- }),
- icon: <ArrowUturnLeft />,
- },
- {
- label: t("stores.actions.terminate.label"),
- onClick: () =>
- handleAction(() => terminateSeller(), {
- title: t("stores.actions.terminate.title"),
- description: t("stores.actions.terminate.description"),
- success: t("stores.actions.terminate.success"),
- }),
- icon: <XCircleSolid />,
- },
- ];
- case SellerStatus.TERMINATED:
- return [
- {
- label: t("stores.actions.unterminate.label"),
- onClick: () =>
- handleAction(() => unterminateSeller(), {
- title: t("stores.actions.unterminate.title"),
- description: t("stores.actions.unterminate.description"),
- success: t("stores.actions.unterminate.success"),
- }),
- icon: <ArrowUturnLeft />,
- },
- ];
+ return [deleteAction];
default:
return [];
}
diff --git a/packages/admin/src/pages/stores/store-details/components/store-details.tsx b/packages/admin/src/pages/stores/store-details/components/store-details.tsx
index f5ad2a8da..978de379a 100644
--- a/packages/admin/src/pages/stores/store-details/components/store-details.tsx
+++ b/packages/admin/src/pages/stores/store-details/components/store-details.tsx
@@ -24,7 +24,7 @@ import {
StoreDetailEditButton,
} from "./store-detail-header";
-const TABS = ["orders", "users", "products", "timeOff"] as const;
+const TABS = ["orders", "products", "users", "timeOff"] as const;
type Tab = (typeof TABS)[number];
diff --git a/packages/admin/src/pages/stores/store-details/components/store-general-section.tsx b/packages/admin/src/pages/stores/store-details/components/store-general-section.tsx
index eab97c182..773c875cf 100644
--- a/packages/admin/src/pages/stores/store-details/components/store-general-section.tsx
+++ b/packages/admin/src/pages/stores/store-details/components/store-general-section.tsx
@@ -76,6 +76,14 @@ export const StoreGeneralSection = ({
{seller.email || "-"}
</Text>
</div>
+ <div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
+ <Text size="small" leading="compact" weight="plus">
+ {t("fields.phone")}
+ </Text>
+ <Text size="small" leading="compact">
+ {seller.phone || "-"}
+ </Text>
+ </div>
<div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
<Text size="small" leading="compact" weight="plus">
{t("fields.website")}
@@ -97,26 +105,6 @@ export const StoreGeneralSection = ({
</Text>
</div>
</div>
- <div className="text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4">
- <Text size="small" leading="compact" weight="plus">
- {t("fields.premium")}
- </Text>
- <Text size="small" leading="compact">
- {seller.is_premium ? t("stores.premium.yes") : t("stores.premium.no")}
- </Text>
- </div>
- <div className="text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4">
- <Text size="small" leading="compact" weight="plus">
- {t("fields.createdAt")}
- </Text>
- <Text size="small" leading="compact">
- {new Date(seller.created_at).toLocaleDateString(undefined, {
- year: "numeric",
- month: "long",
- day: "numeric",
- })}
- </Text>
- </div>
</>
)}
</Container>
diff --git a/packages/admin/src/pages/stores/store-details/components/store-members-section/store-members-data-table.tsx b/packages/admin/src/pages/stores/store-details/components/store-members-section/store-members-data-table.tsx
index 650dc1d80..acaf4f3df 100644
--- a/packages/admin/src/pages/stores/store-details/components/store-members-section/store-members-data-table.tsx
+++ b/packages/admin/src/pages/stores/store-details/components/store-members-section/store-members-data-table.tsx
@@ -1,7 +1,7 @@
import { useMemo } from "react";
-import { Trash } from "@medusajs/icons";
-import { toast } from "@medusajs/ui";
+import { ArrowPath, Link as LinkIcon, Trash } from "@medusajs/icons";
+import { StatusBadge, toast } from "@medusajs/ui";
import { keepPreviousData } from "@tanstack/react-query";
import { createColumnHelper } from "@tanstack/react-table";
import { useTranslation } from "react-i18next";
@@ -11,7 +11,10 @@ import { _DataTable } from "../../../../../components/table/data-table";
import { DateCell } from "../../../../../components/table/table-cells/common/date-cell";
import {
useSellerMembers,
+ useSellerInvites,
useRemoveSellerMember,
+ useDeleteSellerInvite,
+ useResendSellerInvite,
} from "../../../../../hooks/api/sellers";
import { useMemberTableQuery } from "../../../../../hooks/table/query";
import { useDataTable } from "../../../../../hooks/use-data-table";
@@ -27,6 +30,26 @@ const ROLE_TRANSLATION_MAP: Record<string, string> = {
[SellerRole.SUPPORT]: "users.roles.support",
};
+type MemberRow = {
+ kind: "member";
+ id: string;
+ email: string;
+ role_id: string;
+ created_at: string | null;
+ member: SellerMemberDTO;
+};
+
+type InviteRow = {
+ kind: "invite";
+ id: string;
+ email: string;
+ role_id: string;
+ created_at: string | null;
+ invite_url?: string | null;
+};
+
+type UserRow = MemberRow | InviteRow;
+
type StoreMembersDataTableProps = {
sellerId: string;
};
@@ -36,21 +59,58 @@ export const StoreMembersDataTable = ({
}: StoreMembersDataTableProps) => {
const { t } = useTranslation();
- const { searchParams, raw } = useMemberTableQuery({ pageSize: PAGE_SIZE });
- const { seller_members, count, isPending, isError, error } =
- useSellerMembers(sellerId, searchParams, {
- placeholderData: keepPreviousData,
- });
+ const { raw } = useMemberTableQuery({ pageSize: PAGE_SIZE });
+ const {
+ seller_members,
+ isPending: isMembersPending,
+ isError,
+ error,
+ } = useSellerMembers(
+ sellerId,
+ { limit: 100, offset: 0 },
+ { placeholderData: keepPreviousData },
+ );
+
+ const { member_invites, isPending: isInvitesPending } =
+ useSellerInvites(sellerId);
+
+ const rows: UserRow[] = useMemo(() => {
+ const members: MemberRow[] = (
+ (seller_members as SellerMemberDTO[] | undefined) ?? []
+ ).map((m) => ({
+ kind: "member",
+ id: m.id,
+ email: m.member?.email ?? "-",
+ role_id: m.role_id,
+ created_at: m.created_at ?? null,
+ member: m,
+ }));
+
+ const invites: InviteRow[] = (
+ (member_invites as any[] | undefined) ?? []
+ )
+ .filter((invite) => !invite.accepted)
+ .map((invite) => ({
+ kind: "invite",
+ id: invite.id,
+ email: invite.email,
+ role_id: invite.role_id,
+ created_at: invite.created_at ?? null,
+ invite_url: invite.invite_url ?? null,
+ }));
+
+ return [...invites, ...members];
+ }, [seller_members, member_invites]);
const columns = useColumns(sellerId);
const { table } = useDataTable({
- data: (seller_members as SellerMemberDTO[]) ?? [],
+ data: rows,
columns,
enablePagination: true,
- count,
+ count: rows.length,
pageSize: PAGE_SIZE,
- getRowId: (row) => row.id,
+ getRowId: (row) => `${row.kind}:${row.id}`,
});
if (isError) {
@@ -61,10 +121,10 @@ export const StoreMembersDataTable = ({
<_DataTable
table={table}
columns={columns}
- count={count}
+ count={rows.length}
pageSize={PAGE_SIZE}
pagination
- isLoading={isPending}
+ isLoading={isMembersPending || isInvitesPending}
queryObject={raw}
orderBy={[
{ key: "created_at", label: t("fields.createdAt") },
@@ -77,26 +137,24 @@ export const StoreMembersDataTable = ({
);
};
-const columnHelper = createColumnHelper<SellerMemberDTO>();
+const columnHelper = createColumnHelper<UserRow>();
const useColumns = (sellerId: string) => {
const { t } = useTranslation();
return useMemo(
() => [
- columnHelper.accessor("member.email", {
+ columnHelper.accessor("email", {
header: () => (
<div className="flex h-full w-full items-center">
<span>{t("fields.email")}</span>
</div>
),
- cell: ({ row }) => {
- return (
- <div className="flex size-full items-center overflow-hidden">
- <span className="truncate">{row.original.member?.email}</span>
- </div>
- );
- },
+ cell: ({ row }) => (
+ <div className="flex size-full items-center overflow-hidden">
+ <span className="truncate">{row.original.email}</span>
+ </div>
+ ),
}),
columnHelper.accessor("role_id", {
header: () => (
@@ -116,6 +174,26 @@ const useColumns = (sellerId: string) => {
);
},
}),
+ columnHelper.display({
+ id: "status",
+ header: () => (
+ <div className="flex h-full w-full items-center">
+ <span>{t("fields.status")}</span>
+ </div>
+ ),
+ cell: ({ row }) => {
+ const isPending = row.original.kind === "invite";
+ return (
+ <div className="flex size-full items-center">
+ <StatusBadge color={isPending ? "orange" : "green"}>
+ {isPending
+ ? t("users.status.pending")
+ : t("users.status.active")}
+ </StatusBadge>
+ </div>
+ );
+ },
+ }),
columnHelper.accessor("created_at", {
header: () => (
<div className="flex h-full w-full items-center">
@@ -130,8 +208,25 @@ const useColumns = (sellerId: string) => {
columnHelper.display({
id: "actions",
cell: ({ row }) => {
+ const isAdminRole =
+ row.original.role_id === SellerRole.SELLER_ADMINISTRATION;
+
+ if (row.original.kind === "member") {
+ if (isAdminRole) return null;
+ return (
+ <MemberActions
+ member={row.original.member}
+ sellerId={sellerId}
+ />
+ );
+ }
+
return (
- <MemberActions member={row.original} sellerId={sellerId} />
+ <InviteActions
+ invite={row.original}
+ sellerId={sellerId}
+ allowDelete={!isAdminRole}
+ />
);
},
}),
@@ -140,6 +235,95 @@ const useColumns = (sellerId: string) => {
);
};
+const InviteActions = ({
+ invite,
+ sellerId,
+ allowDelete = true,
+}: {
+ invite: InviteRow;
+ sellerId: string;
+ allowDelete?: boolean;
+}) => {
+ const { t } = useTranslation();
+ const { mutateAsync: resend } = useResendSellerInvite(sellerId);
+ const { mutateAsync: deleteInvite } = useDeleteSellerInvite(sellerId);
+
+ const handleResend = async () => {
+ try {
+ await resend({ invite_id: invite.id });
+ toast.success(
+ t("stores.members.invite.resendSuccess", { email: invite.email }),
+ );
+ } catch (e) {
+ toast.error((e as Error).message);
+ }
+ };
+
+ const handleCopyLink = async () => {
+ try {
+ let url = invite.invite_url;
+ if (!url) {
+ const response = (await resend({ invite_id: invite.id })) as {
+ member_invite?: { invite_url?: string | null };
+ };
+ url = response?.member_invite?.invite_url ?? null;
+ }
+
+ if (!url) {
+ toast.error(t("stores.members.invite.noVendorUrl"));
+ return;
+ }
+
+ await navigator.clipboard.writeText(url);
+ toast.success(t("stores.members.invite.linkCopied"));
+ } catch (e) {
+ toast.error((e as Error).message);
+ }
+ };
+
+ const handleDelete = async () => {
+ try {
+ await deleteInvite({ invite_id: invite.id });
+ toast.success(
+ t("stores.members.invite.deleteSuccess", { email: invite.email }),
+ );
+ } catch (e) {
+ toast.error((e as Error).message);
+ }
+ };
+
+ const groups = [
+ {
+ actions: [
+ {
+ icon: <ArrowPath />,
+ label: t("users.resendInvite"),
+ onClick: handleResend,
+ },
+ {
+ icon: <LinkIcon />,
+ label: t("users.copyInviteLink"),
+ onClick: handleCopyLink,
+ },
+ ],
+ },
+ ];
+
+ if (allowDelete) {
+ groups.push({
+ actions: [
+ {
+ icon: <Trash />,
+ label: t("actions.delete"),
+ onClick: handleDelete,
+ },
+ ],
+ });
+ }
+
+ return <ActionMenu groups={groups} />;
+};
+
const MemberActions = ({
member,
sellerId,
diff --git a/packages/admin/src/pages/stores/store-details/components/store-request-section.tsx b/packages/admin/src/pages/stores/store-details/components/store-request-section.tsx
index c99f27269..e5166f297 100644
--- a/packages/admin/src/pages/stores/store-details/components/store-request-section.tsx
+++ b/packages/admin/src/pages/stores/store-details/components/store-request-section.tsx
@@ -23,76 +23,107 @@ type StoreRequestSectionProps = {
seller: Seller;
};
+type PendingAction = "confirm" | "reject" | null;
+
export const StoreRequestSection = ({ seller }: StoreRequestSectionProps) => {
const { t } = useTranslation();
- const [reason, setReason] = useState("");
+ const [pendingAction, setPendingAction] = useState<PendingAction>(null);
+ const [note, setNote] = useState("");
+
const { mutateAsync: approveSeller, isPending: isApproving } =
useApproveSeller(seller.id);
- const { mutateAsync: suspendSeller, isPending: isSuspending } =
+ const { mutateAsync: suspendSeller, isPending: isRejecting } =
useSuspendSeller(seller.id);
- const handleConfirm = async () => {
- try {
- await approveSeller();
- toast.success(
- t("stores.approve.successToast", "Store approved successfully"),
- );
- } catch (error) {
- toast.error((error as Error).message);
- }
+ const requesterLabel = seller.email || seller.name;
+
+ const cancel = () => {
+ setPendingAction(null);
+ setNote("");
};
- const handleReject = async () => {
+ const submit = async () => {
try {
- await suspendSeller({ reason: reason || undefined });
- toast.success(
- t("stores.suspend.successToast", "Store suspended successfully"),
- );
+ if (pendingAction === "confirm") {
+ await approveSeller();
+ toast.success(t("stores.request.confirmSuccess"));
+ } else if (pendingAction === "reject") {
+ await suspendSeller({ reason: note || undefined });
+ toast.success(t("stores.request.rejectSuccess"));
+ }
+ cancel();
} catch (error) {
toast.error((error as Error).message);
}
};
+ const isSubmitting = isApproving || isRejecting;
+
return (
<Container className="p-0">
<div className="flex items-center gap-x-3 border-b border-ui-border-base px-6 py-4">
- <ExclamationCircleSolid className="text-orange-500" />
- <Heading level="h2">
- {t("stores.request.title")}
- </Heading>
+ <ExclamationCircleSolid className="text-ui-tag-blue-icon" />
+ <Heading level="h2">{t("stores.request.title")}</Heading>
</div>
<div className="px-6 py-4">
<Text className="text-ui-fg-subtle">
- {t("stores.request.description")}
- </Text>
- </div>
- <div className="flex flex-col gap-y-2 border-t border-ui-border-base px-6 py-4">
- <Text size="small" weight="plus" className="text-ui-fg-subtle">
- {t("stores.request.reasonLabel")}
+ {t("stores.request.description", { requester: requesterLabel })}
</Text>
- <Textarea
- placeholder={t("stores.request.reasonPlaceholder")}
- value={reason}
- onChange={(e) => setReason(e.target.value)}
- />
</div>
+ {pendingAction ? (
+ <div className="flex flex-col gap-y-2 border-t border-ui-border-base px-6 py-4">
+ <Text size="small" weight="plus" className="text-ui-fg-subtle">
+ {pendingAction === "confirm"
+ ? t("stores.request.confirmNoteLabel")
+ : t("stores.request.rejectNoteLabel")}
+ </Text>
+ <Textarea
+ placeholder={t("stores.request.notePlaceholder")}
+ value={note}
+ onChange={(e) => setNote(e.target.value)}
+ />
+ </div>
+ ) : null}
<div className="flex items-center justify-end gap-x-2 rounded-b-lg border-t border-ui-border-base bg-ui-bg-subtle px-6 py-4">
- <Button
- size="small"
- variant="secondary"
- onClick={handleConfirm}
- isLoading={isApproving}
- >
- {t("stores.request.confirm")}
- </Button>
- <Button
- size="small"
- variant="secondary"
- onClick={handleReject}
- isLoading={isSuspending}
- >
- {t("stores.request.suspend")}
- </Button>
+ {pendingAction ? (
+ <>
+ <Button
+ size="small"
+ variant="secondary"
+ onClick={cancel}
+ disabled={isSubmitting}
+ >
+ {t("actions.cancel")}
+ </Button>
+ <Button
+ size="small"
+ variant={pendingAction === "reject" ? "danger" : "primary"}
+ onClick={submit}
+ isLoading={isSubmitting}
+ >
+ {pendingAction === "confirm"
+ ? t("stores.request.confirm")
+ : t("stores.request.reject")}
+ </Button>
+ </>
+ ) : (
+ <>
+ <Button
+ size="small"
+ variant="secondary"
+ onClick={() => setPendingAction("confirm")}
+ >
+ {t("stores.request.confirm")}
+ </Button>
+ <Button
+ size="small"
+ variant="secondary"
+ onClick={() => setPendingAction("reject")}
+ >
+ {t("stores.request.reject")}
+ </Button>
+ </>
+ )}
</div>
</Container>
);
diff --git a/packages/admin/src/pages/stores/store-edit/components/store-edit-form.tsx b/packages/admin/src/pages/stores/store-edit/components/store-edit-form.tsx
index f0b09f302..d5cd35f2f 100644
--- a/packages/admin/src/pages/stores/store-edit/components/store-edit-form.tsx
+++ b/packages/admin/src/pages/stores/store-edit/components/store-edit-form.tsx
@@ -1,5 +1,14 @@
import { zodResolver } from "@hookform/resolvers/zod";
-import { Button, Input, Select, Textarea, toast } from "@medusajs/ui";
+import { InformationCircleSolid } from "@medusajs/icons";
+import {
+ Button,
+ Heading,
+ Input,
+ Select,
+ Text,
+ Textarea,
+ toast,
+} from "@medusajs/ui";
import { useFieldArray, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import * as zod from "zod";
@@ -8,6 +17,7 @@ import { useCallback } from "react";
import { FileType, FileUpload } from "@components/common/file-upload";
import { Form } from "@components/common/form";
import { SwitchBox } from "@components/common/switch-box";
+import { HandleInput } from "@components/inputs/handle-input";
import { RouteDrawer, useRouteModal } from "@components/modals";
import { KeyboundForm } from "@components/utilities/keybound-form";
import { uploadFilesQuery } from "@lib/client";
@@ -15,6 +25,7 @@ import { MediaSchema } from "@pages/products/product-create/constants";
import { InferClientOutput } from "@mercurjs/client";
import { sdk } from "@lib/client";
import { useUpdateSeller } from "@hooks/api/sellers";
+import { currencies } from "@/lib/data/currencies";
import { SellerStatus } from "@mercurjs/types";
type Seller = InferClientOutput<typeof sdk.admin.sellers.$id.query>["seller"];
@@ -24,12 +35,13 @@ type StoreEditFormProps = {
};
const EditStoreSchema = zod.object({
+ status: zod.nativeEnum(SellerStatus),
name: zod.string().min(1),
- handle: zod.string().min(1),
- email: zod.string().email().optional().or(zod.literal("")),
description: zod.string().optional().or(zod.literal("")),
- website_url: zod.string().url().optional().or(zod.literal("")),
- status: zod.nativeEnum(SellerStatus),
+ handle: zod.string().optional().or(zod.literal("")),
+ email: zod.string().email().optional().or(zod.literal("")),
+ phone: zod.string().optional().or(zod.literal("")),
+ website_url: zod.string().optional().or(zod.literal("")),
is_premium: zod.boolean(),
media: zod.array(MediaSchema).optional(),
bannerMedia: zod.array(MediaSchema).optional(),
@@ -59,12 +71,13 @@ export const StoreEditForm = ({ seller }: StoreEditFormProps) => {
const form = useForm<zod.infer<typeof EditStoreSchema>>({
defaultValues: {
+ status: (seller.status as SellerStatus) ?? SellerStatus.OPEN,
name: seller.name ?? "",
+ description: seller.description ?? "",
handle: seller.handle ?? "",
email: seller.email ?? "",
- description: seller.description ?? "",
+ phone: seller.phone ?? "",
website_url: seller.website_url ?? "",
- status: (seller.status as SellerStatus) ?? SellerStatus.PENDING_APPROVAL,
is_premium: seller.is_premium ?? false,
media: seller.logo
? [{ id: "existing-logo", url: seller.logo, isThumbnail: false, file: null }]
@@ -120,12 +133,13 @@ export const StoreEditForm = ({ seller }: StoreEditFormProps) => {
await mutateAsync(
{
+ status: values.status,
name: values.name,
- handle: values.handle,
+ handle: values.handle || undefined,
email: values.email || undefined,
+ phone: values.phone || null,
description: values.description || null,
website_url: values.website_url || null,
- status: values.status,
is_premium: values.is_premium,
logo: logoUrl,
banner: bannerUrl,
@@ -185,6 +199,9 @@ export const StoreEditForm = ({ seller }: StoreEditFormProps) => {
form.setValue("bannerMedia", [{ ...files[0], isThumbnail: false }]);
};
+ const currencyCode = seller.currency_code?.toUpperCase() ?? "";
+ const currencyName = currencies[currencyCode]?.name ?? currencyCode;
+
return (
<RouteDrawer.Form form={form}>
<KeyboundForm
@@ -193,6 +210,34 @@ export const StoreEditForm = ({ seller }: StoreEditFormProps) => {
>
<RouteDrawer.Body className="flex flex-col gap-y-8 overflow-y-auto">
<div className="flex flex-col gap-y-4">
+ <Form.Field
+ control={form.control}
+ name="status"
+ render={({ field: { onChange, value, ref: _ref, ...field } }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.status")}</Form.Label>
+ <Form.Control>
+ <Select {...field} value={value} onValueChange={onChange}>
+ <Select.Trigger>
+ <Select.Value />
+ </Select.Trigger>
+ <Select.Content>
+ <Select.Item value={SellerStatus.OPEN}>
+ {t("stores.status.open")}
+ </Select.Item>
+ <Select.Item value={SellerStatus.PENDING_APPROVAL}>
+ {t("stores.status.pendingApproval")}
+ </Select.Item>
+ <Select.Item value={SellerStatus.SUSPENDED}>
+ {t("stores.status.suspended")}
+ </Select.Item>
+ </Select.Content>
+ </Select>
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
<Form.Field
control={form.control}
name="name"
@@ -208,12 +253,12 @@ export const StoreEditForm = ({ seller }: StoreEditFormProps) => {
/>
<Form.Field
control={form.control}
- name="handle"
+ name="description"
render={({ field }) => (
<Form.Item>
- <Form.Label>{t("fields.handle")}</Form.Label>
+ <Form.Label optional>{t("fields.description")}</Form.Label>
<Form.Control>
- <Input {...field} />
+ <Textarea {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
@@ -221,12 +266,14 @@ export const StoreEditForm = ({ seller }: StoreEditFormProps) => {
/>
<Form.Field
control={form.control}
- name="email"
+ name="handle"
render={({ field }) => (
<Form.Item>
- <Form.Label>{t("fields.email")}</Form.Label>
+ <Form.Label optional tooltip={t("stores.handleTooltip")}>
+ {t("fields.handle")}
+ </Form.Label>
<Form.Control>
- <Input type="email" {...field} />
+ <HandleInput {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
@@ -234,12 +281,12 @@ export const StoreEditForm = ({ seller }: StoreEditFormProps) => {
/>
<Form.Field
control={form.control}
- name="description"
+ name="email"
render={({ field }) => (
<Form.Item>
- <Form.Label optional>{t("fields.description")}</Form.Label>
+ <Form.Label>{t("fields.email")}</Form.Label>
<Form.Control>
- <Textarea {...field} />
+ <Input type="email" {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
@@ -247,12 +294,12 @@ export const StoreEditForm = ({ seller }: StoreEditFormProps) => {
/>
<Form.Field
control={form.control}
- name="website_url"
+ name="phone"
render={({ field }) => (
<Form.Item>
- <Form.Label optional>{t("fields.website")}</Form.Label>
+ <Form.Label optional>{t("fields.phone")}</Form.Label>
<Form.Control>
- <Input {...field} />
+ <Input type="tel" {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
@@ -260,30 +307,39 @@ export const StoreEditForm = ({ seller }: StoreEditFormProps) => {
/>
<Form.Field
control={form.control}
- name="status"
- render={({ field: { onChange, ref, ...field } }) => (
+ name="website_url"
+ render={({ field }) => (
<Form.Item>
- <Form.Label>{t("fields.status")}</Form.Label>
+ <Form.Label optional>{t("fields.website")}</Form.Label>
<Form.Control>
- <Select onValueChange={onChange} {...field}>
- <Select.Trigger ref={ref}>
- <Select.Value />
- </Select.Trigger>
- <Select.Content>
- {Object.values(SellerStatus).map((status) => (
- <Select.Item key={status} value={status}>
- {t(`stores.status.${status}`)}
- </Select.Item>
- ))}
- </Select.Content>
- </Select>
+ <HandleInput {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
)}
/>
+ <Form.Item>
+ <Form.Label>{t("fields.currency")}</Form.Label>
+ <Select value={currencyCode} disabled>
+ <Select.Trigger>
+ <Select.Value placeholder={currencyName}>
+ {currencyName}
+ </Select.Value>
+ </Select.Trigger>
+ <Select.Content>
+ <Select.Item value={currencyCode}>{currencyName}</Select.Item>
+ </Select.Content>
+ </Select>
+ </Form.Item>
</div>
+ <SwitchBox
+ control={form.control}
+ name="is_premium"
+ label={t("fields.premium")}
+ description={t("stores.premium.description")}
+ />
<div className="flex flex-col gap-y-4">
+ <Heading level="h2">{t("stores.edit.mediaHeading")}</Heading>
<Form.Field
name="media"
control={form.control}
@@ -342,13 +398,16 @@ export const StoreEditForm = ({ seller }: StoreEditFormProps) => {
);
}}
/>
+ <div className="bg-ui-bg-subtle flex items-start gap-x-2 rounded-lg px-3 py-2">
+ <InformationCircleSolid className="text-ui-fg-muted mt-[2px]" />
+ <Text size="small" className="text-ui-fg-subtle">
+ <span className="text-ui-fg-base font-medium">
+ {t("stores.edit.mediaTipLabel")}
+ </span>{" "}
+ {t("stores.edit.mediaTipBody")}
+ </Text>
+ </div>
</div>
- <SwitchBox
- control={form.control}
- name="is_premium"
- label={t("fields.premium")}
- description={t("stores.premium.description")}
- />
</RouteDrawer.Body>
<RouteDrawer.Footer>
<div className="flex items-center justify-end gap-x-2">
diff --git a/packages/admin/src/pages/stores/store-list/components/store-list-table/store-list-data-table.tsx b/packages/admin/src/pages/stores/store-list/components/store-list-table/store-list-data-table.tsx
index 64751694a..746dbe245 100644
--- a/packages/admin/src/pages/stores/store-list/components/store-list-table/store-list-data-table.tsx
+++ b/packages/admin/src/pages/stores/store-list/components/store-list-table/store-list-data-table.tsx
@@ -1,8 +1,9 @@
import { useMemo, useState } from "react"
import { useTranslation } from "react-i18next"
+import { useNavigate } from "react-router-dom"
import { Checkbox, toast, usePrompt } from "@medusajs/ui"
-import { PencilSquare, XCircleSolid } from "@medusajs/icons"
+import { PencilSquare, Trash } from "@medusajs/icons"
import { keepPreviousData } from "@tanstack/react-query"
import { RowSelectionState, createColumnHelper } from "@tanstack/react-table"
@@ -15,7 +16,7 @@ import { useSellersTableColumns } from "../../../../../hooks/table/columns/use-s
import { useSellerTableFilters } from "../../../../../hooks/table/filters"
import { useSellersTableQuery } from "../../../../../hooks/table/query"
import { useDataTable } from "../../../../../hooks/use-data-table"
-import { SellerDTO, SellerStatus } from "@mercurjs/types"
+import { SellerDTO } from "@mercurjs/types"
import { sdk } from "../../../../../lib/client"
import { queryClient } from "../../../../../lib/query-client"
import { sellersQueryKeys } from "../../../../../hooks/api/sellers"
@@ -25,6 +26,7 @@ const PAGE_SIZE = 10
export const StoreListDataTable = () => {
const { t } = useTranslation()
+ const navigate = useNavigate()
const [selection, setSelection] = useState<RowSelectionState>({})
const { searchParams, raw } = useSellersTableQuery({
@@ -78,22 +80,11 @@ export const StoreListDataTable = () => {
{
action: async (selection) => {
const ids = Object.keys(selection)
- try {
- await Promise.all(
- ids.map((id) =>
- sdk.admin.sellers.$id.suspend.mutate({ $id: id })
- )
- )
- toast.success(t("stores.actions.suspend.successToast", { count: ids.length }))
- } catch {
- toast.error(t("stores.actions.suspend.errorToast"))
- }
- await queryClient.invalidateQueries({
- queryKey: sellersQueryKeys.lists(),
- })
+ if (!ids.length) return
+ navigate(`bulk-edit?ids=${ids.join(",")}`)
},
- label: t("stores.actions.suspend.label"),
- shortcut: "s",
+ label: t("stores.actions.edit.label"),
+ shortcut: "e",
},
{
action: async (selection) => {
@@ -101,19 +92,19 @@ export const StoreListDataTable = () => {
try {
await Promise.all(
ids.map((id) =>
- sdk.admin.sellers.$id.unsuspend.mutate({ $id: id })
+ sdk.admin.sellers.$id.terminate.mutate({ $id: id })
)
)
- toast.success(t("stores.actions.unsuspend.successToast", { count: ids.length }))
+ toast.success(t("stores.actions.delete.successToast", { count: ids.length }))
} catch {
- toast.error(t("stores.actions.unsuspend.errorToast"))
+ toast.error(t("stores.actions.delete.errorToast"))
}
await queryClient.invalidateQueries({
queryKey: sellersQueryKeys.lists(),
})
},
- label: t("stores.actions.unsuspend.label"),
- shortcut: "u",
+ label: t("stores.actions.delete.label"),
+ shortcut: "d",
},
]}
/>
@@ -127,10 +118,10 @@ const StoreActions = ({ seller }: { seller: SellerDTO }) => {
const prompt = usePrompt()
const { mutateAsync: terminateSeller } = useTerminateSeller(seller.id)
- const handleTerminate = async () => {
+ const handleDelete = async () => {
const confirmed = await prompt({
- title: t("stores.actions.terminate.title"),
- description: t("stores.actions.terminate.description"),
+ title: t("stores.actions.delete.title"),
+ description: t("stores.actions.delete.description"),
verificationText: seller.email || seller.name,
confirmText: t("actions.confirm"),
cancelText: t("actions.cancel"),
@@ -142,7 +133,7 @@ const StoreActions = ({ seller }: { seller: SellerDTO }) => {
await terminateSeller(undefined, {
onSuccess: () => {
- toast.success(t("stores.actions.terminate.success"))
+ toast.success(t("stores.actions.delete.success"))
},
onError: (error) => {
toast.error(error.message)
@@ -160,15 +151,11 @@ const StoreActions = ({ seller }: { seller: SellerDTO }) => {
label: t("actions.edit"),
to: `/stores/${seller.id}/edit`,
},
- ...(seller.status !== SellerStatus.TERMINATED
- ? [
- {
- icon: <XCircleSolid />,
- label: t("stores.actions.terminate.label"),
- onClick: handleTerminate,
- },
- ]
- : []),
+ {
+ icon: <Trash />,
+ label: t("stores.actions.delete.label"),
+ onClick: handleDelete,
+ },
],
},
]}
diff --git a/packages/admin/src/pages/stores/store-member-invite/components/invite-member-form.tsx b/packages/admin/src/pages/stores/store-member-invite/components/invite-member-form.tsx
index a0a819750..d3f77ed20 100644
--- a/packages/admin/src/pages/stores/store-member-invite/components/invite-member-form.tsx
+++ b/packages/admin/src/pages/stores/store-member-invite/components/invite-member-form.tsx
@@ -1,34 +1,20 @@
import { zodResolver } from "@hookform/resolvers/zod";
-import {
- Button,
- Container,
- Heading,
- Input,
- Select,
- StatusBadge,
- Text,
- toast,
- Tooltip,
-} from "@medusajs/ui";
-import { createColumnHelper } from "@tanstack/react-table";
-import { format } from "date-fns";
-import { useMemo } from "react";
+import { Button, Input, Select, Text, clx, toast } from "@medusajs/ui";
+import { useMemo, useState } from "react";
import { useForm } from "react-hook-form";
-import { Trans, useTranslation } from "react-i18next";
+import { useTranslation } from "react-i18next";
import { useParams } from "react-router-dom";
import * as zod from "zod";
import { Form } from "../../../../components/common/form";
-import { RouteFocusModal } from "../../../../components/modals";
-import { _DataTable } from "../../../../components/table/data-table";
+import { RouteDrawer, useRouteModal } from "../../../../components/modals";
import { KeyboundForm } from "../../../../components/utilities/keybound-form";
+import { useMembers } from "../../../../hooks/api/members";
import {
+ useAddSellerMember,
useInviteSellerMember,
- useSellerInvites,
} from "../../../../hooks/api/sellers";
-import { useUserInviteTableQuery } from "../../../../hooks/table/query";
-import { useDataTable } from "../../../../hooks/use-data-table";
-import { MemberInviteDTO, SellerRole } from "@mercurjs/types";
+import { SellerRole } from "@mercurjs/types";
const ROLE_OPTIONS = [
{
@@ -47,21 +33,19 @@ const ROLE_OPTIONS = [
{ value: SellerRole.SUPPORT, labelKey: "users.roles.support" },
];
-const ROLE_LABEL_MAP: Record<string, string> = Object.fromEntries(
- ROLE_OPTIONS.map((r) => [r.value, r.labelKey]),
-);
-
const InviteMemberSchema = zod.object({
email: zod.string().email(),
role_id: zod.string().min(1),
});
-const PAGE_SIZE = 10;
-const PREFIX = "inv";
+type Member = { id: string; email: string };
export const InviteMemberForm = () => {
const { t } = useTranslation();
const { id } = useParams();
+ const { handleSuccess } = useRouteModal();
+
+ const [suggestionsOpen, setSuggestionsOpen] = useState(false);
const form = useForm<zod.infer<typeof InviteMemberSchema>>({
defaultValues: {
@@ -71,251 +55,147 @@ export const InviteMemberForm = () => {
resolver: zodResolver(InviteMemberSchema),
});
- const { raw, searchParams } = useUserInviteTableQuery({
- prefix: PREFIX,
- pageSize: PAGE_SIZE,
- });
+ const emailValue = form.watch("email");
- const {
- member_invites,
- count,
- isPending: isLoading,
- isError,
- error,
- } = useSellerInvites(id!, searchParams);
+ const { members } = useMembers(
+ { q: emailValue || undefined, limit: 10 },
+ { placeholderData: (prev: any) => prev },
+ );
- const columns = useColumns();
+ const memberList = useMemo(
+ () => (members as Member[] | undefined) ?? [],
+ [members],
+ );
- const { table } = useDataTable({
- data: (member_invites as MemberInviteDTO[]) ?? [],
- columns,
- count,
- enablePagination: true,
- getRowId: (row: MemberInviteDTO) => row.id,
- pageSize: PAGE_SIZE,
- prefix: PREFIX,
- });
+ const { mutateAsync: inviteMember, isPending: isInviting } =
+ useInviteSellerMember(id!);
+ const { mutateAsync: addMember, isPending: isAdding } = useAddSellerMember(
+ id!,
+ );
- const { mutateAsync, isPending } = useInviteSellerMember(id!);
+ const isPending = isInviting || isAdding;
const handleSubmit = form.handleSubmit(async (values) => {
try {
- await mutateAsync({
- email: values.email,
- role_id: values.role_id as SellerRole,
- });
- toast.success(t("users.inviteSuccess", "Invite sent successfully"));
- form.reset();
+ const matched = memberList.find(
+ (m) => m.email.toLowerCase() === values.email.toLowerCase(),
+ );
+
+ if (matched) {
+ await addMember({
+ member_id: matched.id,
+ role_id: values.role_id as SellerRole,
+ });
+ toast.success(
+ t("stores.members.addUser.assignSuccess", { email: values.email }),
+ );
+ } else {
+ await inviteMember({
+ email: values.email,
+ role_id: values.role_id as SellerRole,
+ });
+ toast.success(t("users.inviteSuccess"));
+ }
+
+ handleSuccess();
} catch (error) {
toast.error((error as Error).message);
}
});
- if (isError) {
- throw error;
- }
-
return (
- <RouteFocusModal.Form form={form}>
+ <RouteDrawer.Form form={form}>
<KeyboundForm
onSubmit={handleSubmit}
- className="flex h-full flex-col overflow-hidden"
+ className="flex flex-1 flex-col overflow-hidden"
>
- <RouteFocusModal.Header />
- <RouteFocusModal.Body className="flex flex-1 flex-col overflow-hidden">
- <div className="flex flex-1 flex-col items-center overflow-y-auto">
- <div className="flex w-full max-w-[720px] flex-col gap-y-8 px-2 py-16">
- <div>
- <Heading>{t("users.inviteUser", "Invite User")}</Heading>
- <Text size="small" className="text-ui-fg-subtle">
- {t(
- "users.inviteUserHint",
- "Invite a new user to this store.",
- )}
- </Text>
- </div>
-
- <div className="flex flex-col gap-y-4">
- <div className="grid grid-cols-2 gap-4">
- <Form.Field
- control={form.control}
- name="email"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.email")}</Form.Label>
- <Form.Control>
- <Input {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="role_id"
- render={({ field: { onChange, ref, ...field } }) => (
- <Form.Item>
- <Form.Label>{t("fields.role")}</Form.Label>
- <Form.Control>
- <Select {...field} onValueChange={onChange}>
- <Select.Trigger ref={ref}>
- <Select.Value
- placeholder={t(
- "users.selectRole",
- "Select a role",
- )}
- />
- </Select.Trigger>
- <Select.Content>
- {ROLE_OPTIONS.map((role) => (
- <Select.Item
- key={role.value}
- value={role.value}
- >
- {t(role.labelKey)}
- </Select.Item>
- ))}
- </Select.Content>
- </Select>
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
+ <RouteDrawer.Body className="flex flex-col gap-y-6 overflow-y-auto">
+ <Text size="small" className="text-ui-fg-subtle">
+ {t("stores.members.addUser.hint")}
+ </Text>
+ <Form.Field
+ control={form.control}
+ name="email"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.email")}</Form.Label>
+ <Form.Control>
+ <div className="relative">
+ <Input
+ {...field}
+ autoComplete="off"
+ onFocus={() => setSuggestionsOpen(true)}
+ onBlur={() => {
+ field.onBlur();
+ setTimeout(() => setSuggestionsOpen(false), 150);
+ }}
+ />
+ {suggestionsOpen && memberList.length > 0 && (
+ <div
+ className={clx(
+ "bg-ui-bg-base shadow-elevation-flyout border-ui-border-base absolute z-50 mt-1 flex max-h-60 w-full flex-col overflow-y-auto rounded-md border p-1",
+ )}
+ >
+ {memberList.map((member) => (
+ <button
+ key={member.id}
+ type="button"
+ onMouseDown={(e) => {
+ e.preventDefault();
+ field.onChange(member.email);
+ setSuggestionsOpen(false);
+ }}
+ className="hover:bg-ui-bg-base-hover text-ui-fg-base flex w-full items-center rounded-sm px-2 py-1.5 text-left text-sm"
+ >
+ {member.email}
+ </button>
+ ))}
+ </div>
)}
- />
- </div>
- <div className="flex items-center justify-end">
- <Button
- size="small"
- variant="secondary"
- type="submit"
- isLoading={isPending}
- >
- {t("users.sendInvite", "Send invite")}
- </Button>
- </div>
- </div>
-
- <div className="flex flex-col gap-y-4">
- <Heading level="h2">
- {t("users.pendingInvites", "Pending Invites")}
- </Heading>
- <Container className="overflow-hidden p-0">
- <_DataTable
- table={table}
- columns={columns}
- count={count}
- pageSize={PAGE_SIZE}
- pagination
- isLoading={isLoading}
- queryObject={raw}
- prefix={PREFIX}
- orderBy={[
- { key: "email", label: t("fields.email") },
- {
- key: "created_at",
- label: t("fields.createdAt"),
- },
- ]}
- />
- </Container>
- </div>
- </div>
+ </div>
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="role_id"
+ render={({ field: { onChange, ref, ...field } }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.role")}</Form.Label>
+ <Form.Control>
+ <Select {...field} onValueChange={onChange}>
+ <Select.Trigger ref={ref}>
+ <Select.Value placeholder={t("users.selectRole", "Select")} />
+ </Select.Trigger>
+ <Select.Content>
+ {ROLE_OPTIONS.map((role) => (
+ <Select.Item key={role.value} value={role.value}>
+ {t(role.labelKey)}
+ </Select.Item>
+ ))}
+ </Select.Content>
+ </Select>
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ </RouteDrawer.Body>
+ <RouteDrawer.Footer>
+ <div className="flex items-center justify-end gap-x-2">
+ <RouteDrawer.Close asChild>
+ <Button size="small" variant="secondary" type="button">
+ {t("actions.cancel")}
+ </Button>
+ </RouteDrawer.Close>
+ <Button size="small" type="submit" isLoading={isPending}>
+ {t("actions.save")}
+ </Button>
</div>
- </RouteFocusModal.Body>
+ </RouteDrawer.Footer>
</KeyboundForm>
- </RouteFocusModal.Form>
- );
-};
-
-const columnHelper = createColumnHelper<MemberInviteDTO>();
-
-const useColumns = () => {
- const { t } = useTranslation();
-
- return useMemo(
- () => [
- columnHelper.accessor("email", {
- header: t("fields.email"),
- cell: ({ getValue }) => getValue(),
- }),
- columnHelper.accessor("role_id", {
- header: t("fields.role"),
- cell: ({ getValue }) => {
- const roleId = getValue();
- const labelKey = ROLE_LABEL_MAP[roleId];
- return labelKey ? t(labelKey) : "-";
- },
- }),
- columnHelper.accessor("accepted", {
- header: t("fields.status"),
- cell: ({ getValue, row }) => {
- const accepted = getValue();
- const expired = new Date(row.original.expires_at) < new Date();
-
- if (accepted) {
- return (
- <Tooltip
- content={t("users.acceptedOnDate", {
- date: format(
- new Date(row.original.updated_at),
- "dd MMM, yyyy",
- ),
- })}
- >
- <StatusBadge color="green">
- {t("users.inviteStatus.accepted")}
- </StatusBadge>
- </Tooltip>
- );
- }
-
- if (expired) {
- return (
- <Tooltip
- content={t("users.expiredOnDate", {
- date: format(
- new Date(row.original.expires_at),
- "dd MMM, yyyy",
- ),
- })}
- >
- <StatusBadge color="red">
- {t("users.inviteStatus.expired")}
- </StatusBadge>
- </Tooltip>
- );
- }
-
- return (
- <Tooltip
- content={
- <Trans
- i18nKey={"users.validFromUntil"}
- components={[
- <span key="from" className="font-medium" />,
- <span key="until" className="font-medium" />,
- ]}
- values={{
- from: format(
- new Date(row.original.created_at),
- "dd MMM, yyyy",
- ),
- until: format(
- new Date(row.original.expires_at),
- "dd MMM, yyyy",
- ),
- }}
- />
- }
- >
- <StatusBadge color="orange">
- {t("users.inviteStatus.pending")}
- </StatusBadge>
- </Tooltip>
- );
- },
- }),
- ],
- [t],
+ </RouteDrawer.Form>
);
};
diff --git a/packages/admin/src/pages/stores/store-member-invite/index.tsx b/packages/admin/src/pages/stores/store-member-invite/index.tsx
index e3ca46e62..8f9a89cac 100644
--- a/packages/admin/src/pages/stores/store-member-invite/index.tsx
+++ b/packages/admin/src/pages/stores/store-member-invite/index.tsx
@@ -1,10 +1,20 @@
-import { RouteFocusModal } from "../../../components/modals";
+import { Heading } from "@medusajs/ui";
+import { useTranslation } from "react-i18next";
+
+import { RouteDrawer } from "../../../components/modals";
import { InviteMemberForm } from "./components/invite-member-form";
-export const Component = () => {
+const Root = () => {
+ const { t } = useTranslation();
+
return (
- <RouteFocusModal>
+ <RouteDrawer>
+ <RouteDrawer.Header>
+ <Heading>{t("stores.members.addUser.header")}</Heading>
+ </RouteDrawer.Header>
<InviteMemberForm />
- </RouteFocusModal>
+ </RouteDrawer>
);
};
+
+export const Component = Root;
diff --git a/packages/admin/src/pages/stores/store-payment-details-edit/components/store-payment-details-form.tsx b/packages/admin/src/pages/stores/store-payment-details-edit/components/store-payment-details-form.tsx
index bec7d042f..b084ad585 100644
--- a/packages/admin/src/pages/stores/store-payment-details-edit/components/store-payment-details-form.tsx
+++ b/packages/admin/src/pages/stores/store-payment-details-edit/components/store-payment-details-form.tsx
@@ -62,7 +62,7 @@ export const StorePaymentDetailsForm = ({
iban: isABA ? null : values.iban || null,
bic: isABA ? null : values.bic || null,
routing_number: isABA ? values.routing_number || null : null,
- account_number: isABA ? values.account_number || null : null,
+ account_number: values.account_number || null,
},
{
onSuccess: () => {
@@ -134,13 +134,11 @@ export const StorePaymentDetailsForm = ({
<div className="grid grid-cols-2 gap-4">
<Form.Field
control={form.control}
- name="routing_number"
+ name="account_number"
render={({ field }) => (
<Form.Item>
- <Form.Label optional>
- {t(
- "store.paymentDetails.fields.routingNumber",
- )}
+ <Form.Label>
+ {t("store.paymentDetails.fields.accountNumber")}
</Form.Label>
<Form.Control>
<Input size="small" {...field} />
@@ -151,13 +149,11 @@ export const StorePaymentDetailsForm = ({
/>
<Form.Field
control={form.control}
- name="account_number"
+ name="routing_number"
render={({ field }) => (
<Form.Item>
- <Form.Label optional>
- {t(
- "store.paymentDetails.fields.accountNumber",
- )}
+ <Form.Label>
+ {t("store.paymentDetails.fields.achRoutingNumber")}
</Form.Label>
<Form.Control>
<Input size="small" {...field} />
@@ -174,7 +170,7 @@ export const StorePaymentDetailsForm = ({
name="iban"
render={({ field }) => (
<Form.Item>
- <Form.Label optional>
+ <Form.Label>
{t("store.paymentDetails.fields.iban")}
</Form.Label>
<Form.Control>
@@ -184,13 +180,28 @@ export const StorePaymentDetailsForm = ({
</Form.Item>
)}
/>
+ <Form.Field
+ control={form.control}
+ name="account_number"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>
+ {t("store.paymentDetails.fields.accountNumber")}
+ </Form.Label>
+ <Form.Control>
+ <Input size="small" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
<Form.Field
control={form.control}
name="bic"
render={({ field }) => (
<Form.Item>
- <Form.Label optional>
- {t("store.paymentDetails.fields.bic")}
+ <Form.Label>
+ {t("store.paymentDetails.fields.swiftBic")}
</Form.Label>
<Form.Control>
<Input size="small" {...field} />
diff --git a/packages/core/.mercur/_generated/index.ts b/packages/core/.mercur/_generated/index.ts
index 8a9cab9ab..61e061d8d 100644
--- a/packages/core/.mercur/_generated/index.ts
+++ b/packages/core/.mercur/_generated/index.ts
@@ -142,7 +142,7 @@ export type Routes = {
$id: typeof import("@medusajs/medusa/api/admin/invites/[id]/route") & {
resend: typeof import("@medusajs/medusa/api/admin/invites/[id]/resend/route");
};
- accept: typeof import("@mercurjs/core/api/admin/invites/accept/route");
+ accept: typeof import("@medusajs/medusa/api/admin/invites/accept/route");
};
locales: typeof import("@medusajs/medusa/api/admin/locales/route") & {
$code: typeof import("@medusajs/medusa/api/admin/locales/[code]/route");
@@ -427,7 +427,6 @@ export type Routes = {
$id: typeof import("../../src/api/admin/payouts/[id]/route");
};
sellers: typeof import("../../src/api/admin/sellers/route") & {
- invite: typeof import("@mercurjs/core/api/admin/sellers/invite/route");
$id: typeof import("../../src/api/admin/sellers/[id]/route") & {
address: typeof import("../../src/api/admin/sellers/[id]/address/route");
approve: typeof import("../../src/api/admin/sellers/[id]/approve/route");
@@ -437,6 +436,7 @@ export type Routes = {
invites: typeof import("../../src/api/admin/sellers/[id]/members/invites/route");
};
paymentDetails: typeof import("../../src/api/admin/sellers/[id]/payment-details/route");
+ products: typeof import("../../src/api/admin/sellers/[id]/products/route");
professionalDetails: typeof import("../../src/api/admin/sellers/[id]/professional-details/route");
suspend: typeof import("../../src/api/admin/sellers/[id]/suspend/route");
terminate: typeof import("../../src/api/admin/sellers/[id]/terminate/route");
diff --git a/packages/core/src/api/admin/members/middlewares.ts b/packages/core/src/api/admin/members/middlewares.ts
new file mode 100644
index 000000000..2e436a0a6
--- /dev/null
+++ b/packages/core/src/api/admin/members/middlewares.ts
@@ -0,0 +1,18 @@
+import { MiddlewareRoute } from "@medusajs/framework/http"
+import { validateAndTransformQuery } from "@medusajs/framework"
+
+import { adminMemberListQueryConfig } from "./query-config"
+import { AdminGetMembersParams } from "./validators"
+
+export const adminMembersMiddlewares: MiddlewareRoute[] = [
+ {
+ method: ["GET"],
+ matcher: "/admin/members",
+ middlewares: [
+ validateAndTransformQuery(
+ AdminGetMembersParams,
+ adminMemberListQueryConfig.list
+ ),
+ ],
+ },
+]
diff --git a/packages/core/src/api/admin/members/query-config.ts b/packages/core/src/api/admin/members/query-config.ts
new file mode 100644
index 000000000..72a984ce3
--- /dev/null
+++ b/packages/core/src/api/admin/members/query-config.ts
@@ -0,0 +1,7 @@
+export const adminMemberListQueryConfig = {
+ list: {
+ defaults: ["id", "email", "is_active", "created_at"],
+ defaultLimit: 10,
+ isList: true,
+ },
+}
diff --git a/packages/core/src/api/admin/members/route.ts b/packages/core/src/api/admin/members/route.ts
new file mode 100644
index 000000000..b2982b4c0
--- /dev/null
+++ b/packages/core/src/api/admin/members/route.ts
@@ -0,0 +1,26 @@
+import {
+ AuthenticatedMedusaRequest,
+ MedusaResponse,
+} from "@medusajs/framework/http"
+import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
+
+export const GET = async (
+ req: AuthenticatedMedusaRequest,
+ res: MedusaResponse
+) => {
+ const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
+
+ const { data: members, metadata } = await query.graph({
+ entity: "member",
+ fields: req.queryConfig.fields,
+ filters: req.filterableFields,
+ pagination: req.queryConfig.pagination,
+ })
+
+ res.json({
+ members,
+ count: metadata!.count,
+ offset: metadata!.skip,
+ limit: metadata!.take,
+ })
+}
diff --git a/packages/core/src/api/admin/members/validators.ts b/packages/core/src/api/admin/members/validators.ts
new file mode 100644
index 000000000..a3a0fce6b
--- /dev/null
+++ b/packages/core/src/api/admin/members/validators.ts
@@ -0,0 +1,11 @@
+import { createFindParams } from "@medusajs/medusa/api/utils/validators"
+import { z } from "zod"
+
+export type AdminGetMembersParamsType = z.infer<typeof AdminGetMembersParams>
+export const AdminGetMembersParams = createFindParams({
+ limit: 10,
+ offset: 0,
+}).extend({
+ q: z.string().optional(),
+ email: z.string().optional(),
+})
diff --git a/packages/core/src/api/admin/middlewares.ts b/packages/core/src/api/admin/middlewares.ts
index bd007aee9..1d68f32c9 100644
--- a/packages/core/src/api/admin/middlewares.ts
+++ b/packages/core/src/api/admin/middlewares.ts
@@ -12,6 +12,7 @@ import { adminOrderGroupQueryConfig } from "./order-groups/query-config"
import { AdminGetOrderGroupParams } from "./order-groups/validators"
import { adminPayoutsMiddlewares } from "./payouts/middlewares"
import { adminSellersMiddlewares } from "./sellers/middlewares"
+import { adminMembersMiddlewares } from "./members/middlewares"
import { adminAttributeMiddlewares } from "./attributes/middlewares"
import { adminCommissionRatesMiddlewares } from "./commission-rates/middlewares"
import { adminSubscriptionPlanRoutesMiddlewares } from "./subscription-plans/middlewares"
@@ -67,6 +68,7 @@ export const adminMiddlewares: MiddlewareRoute[] = [
},
...adminPayoutsMiddlewares,
...adminSellersMiddlewares,
+ ...adminMembersMiddlewares,
...adminCommissionRatesMiddlewares,
...adminSubscriptionPlanRoutesMiddlewares,
{
diff --git a/packages/core/src/api/admin/sellers/[id]/members/invites/[invite_id]/resend/route.ts b/packages/core/src/api/admin/sellers/[id]/members/invites/[invite_id]/resend/route.ts
new file mode 100644
index 000000000..1414c6f55
--- /dev/null
+++ b/packages/core/src/api/admin/sellers/[id]/members/invites/[invite_id]/resend/route.ts
@@ -0,0 +1,34 @@
+import {
+ AuthenticatedMedusaRequest,
+ MedusaResponse,
+} from "@medusajs/framework/http"
+import { MercurModules } from "@mercurjs/types"
+
+import { resendMemberInviteWorkflow } from "../../../../../../../../workflows/seller"
+import SellerModuleService from "../../../../../../../../modules/seller/service"
+
+export const POST = async (
+ req: AuthenticatedMedusaRequest,
+ res: MedusaResponse
+) => {
+ const { result } = await resendMemberInviteWorkflow(req.scope).run({
+ input: {
+ invite_id: req.params.invite_id,
+ seller_id: req.params.id,
+ },
+ })
+
+ const invite = (result as any[])[0]
+ const sellerService = req.scope.resolve<SellerModuleService>(
+ MercurModules.SELLER
+ )
+
+ res.status(200).json({
+ member_invite: {
+ ...invite,
+ invite_url: invite?.token
+ ? sellerService.buildInviteUrl(invite.token)
+ : null,
+ },
+ })
+}
diff --git a/packages/core/src/api/admin/sellers/[id]/members/invites/[invite_id]/route.ts b/packages/core/src/api/admin/sellers/[id]/members/invites/[invite_id]/route.ts
new file mode 100644
index 000000000..3389b5825
--- /dev/null
+++ b/packages/core/src/api/admin/sellers/[id]/members/invites/[invite_id]/route.ts
@@ -0,0 +1,19 @@
+import {
+ AuthenticatedMedusaRequest,
+ MedusaResponse,
+} from "@medusajs/framework/http"
+
+import { deleteMemberInviteWorkflow } from "../../../../../../../workflows/seller"
+
+export const DELETE = async (
+ req: AuthenticatedMedusaRequest,
+ res: MedusaResponse
+) => {
+ await deleteMemberInviteWorkflow(req.scope).run({
+ input: {
+ invite_id: req.params.invite_id,
+ },
+ })
+
+ res.status(200).json({ id: req.params.invite_id, object: "member_invite", deleted: true })
+}
diff --git a/packages/core/src/api/admin/sellers/[id]/members/invites/route.ts b/packages/core/src/api/admin/sellers/[id]/members/invites/route.ts
index 38d3ba543..ccffb628b 100644
--- a/packages/core/src/api/admin/sellers/[id]/members/invites/route.ts
+++ b/packages/core/src/api/admin/sellers/[id]/members/invites/route.ts
@@ -3,12 +3,18 @@ import {
MedusaResponse,
} from "@medusajs/framework/http"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
+import { MercurModules } from "@mercurjs/types"
+
+import SellerModuleService from "../../../../../../modules/seller/service"
export const GET = async (
req: AuthenticatedMedusaRequest,
res: MedusaResponse
) => {
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
+ const sellerService = req.scope.resolve<SellerModuleService>(
+ MercurModules.SELLER
+ )
const { data: memberInvites, metadata } = await query.graph({
entity: "member_invite",
@@ -19,8 +25,15 @@ export const GET = async (
pagination: req.queryConfig.pagination,
})
+ const enriched = memberInvites.map((invite: any) => ({
+ ...invite,
+ invite_url: invite.token
+ ? sellerService.buildInviteUrl(invite.token)
+ : null,
+ }))
+
res.json({
- member_invites: memberInvites,
+ member_invites: enriched,
count: metadata!.count,
offset: metadata!.skip,
limit: metadata!.take,
diff --git a/packages/core/src/api/admin/sellers/query-config.ts b/packages/core/src/api/admin/sellers/query-config.ts
index 615cc4697..82b963b92 100644
--- a/packages/core/src/api/admin/sellers/query-config.ts
+++ b/packages/core/src/api/admin/sellers/query-config.ts
@@ -3,6 +3,7 @@ export const adminSellerFields = [
"name",
"handle",
"email",
+ "phone",
"description",
"logo",
"banner",
@@ -67,6 +68,7 @@ export const adminMemberInvitesQueryConfig = {
"email",
"accepted",
"role_id",
+ "token",
"expires_at",
"created_at",
"updated_at",
diff --git a/packages/core/src/api/admin/sellers/validators.ts b/packages/core/src/api/admin/sellers/validators.ts
index cd8b839a9..caf47664c 100644
--- a/packages/core/src/api/admin/sellers/validators.ts
+++ b/packages/core/src/api/admin/sellers/validators.ts
@@ -53,6 +53,7 @@ export const AdminCreateSeller = z.object({
name: z.string(),
handle: z.string().optional(),
email: z.string().email(),
+ phone: z.string().nullable().optional(),
description: z.string().nullable().optional(),
logo: z.string().url().nullable().optional(),
banner: z.string().url().nullable().optional(),
@@ -76,6 +77,7 @@ export const AdminUpdateSeller = z.object({
name: z.string().optional(),
handle: z.string().optional(),
email: z.string().email().optional(),
+ phone: z.string().nullable().optional(),
description: z.string().nullable().optional(),
logo: z.string().url().nullable().optional(),
banner: z.string().url().nullable().optional(),
@@ -118,6 +120,7 @@ export type AdminUpsertSellerAddressType = z.infer<
typeof AdminUpsertSellerAddress
>
export const AdminUpsertSellerAddress = z.object({
+ name: z.string().nullable().optional(),
company: z.string().nullable().optional(),
first_name: z.string().nullable().optional(),
last_name: z.string().nullable().optional(),
diff --git a/packages/core/src/api/utils/ensure-seller-middleware.ts b/packages/core/src/api/utils/ensure-seller-middleware.ts
index 99d000e4c..d08f37225 100644
--- a/packages/core/src/api/utils/ensure-seller-middleware.ts
+++ b/packages/core/src/api/utils/ensure-seller-middleware.ts
@@ -6,7 +6,10 @@ import {
import {
ContainerRegistrationKeys,
MedusaError,
+ Modules,
} from "@medusajs/framework/utils"
+import { IRbacModuleService } from "@medusajs/types"
+import { ensureSellerDefaultRoles } from "../../modules/seller/utils/ensure-seller-default-roles"
import { SellerContext } from "../../types/seller-context"
const SELLER_ID_HEADER = "x-seller-id"
@@ -56,10 +59,14 @@ export async function ensureSellerMiddleware(
req.seller_context = {
seller_id: sellerId,
seller_member: sellerMember,
- currency_code: sellerMember.seller.currency_code
+ currency_code: sellerMember.seller.currency_code,
} as SellerContext
if (sellerMember.role_id) {
+ const rbacService: IRbacModuleService = req.scope.resolve(Modules.RBAC)
+
+ await ensureSellerDefaultRoles(rbacService)
+
req.auth_context.app_metadata = {
...req.auth_context.app_metadata,
roles: [sellerMember.role_id],
diff --git a/packages/core/src/api/utils/index.ts b/packages/core/src/api/utils/index.ts
index 14feeb7b0..e8629bbaf 100644
--- a/packages/core/src/api/utils/index.ts
+++ b/packages/core/src/api/utils/index.ts
@@ -2,4 +2,4 @@ export * from "./unless-base-url"
export * from "./scan-unauthenticated-routes"
export * from "./ensure-seller-middleware"
export * from "./filter-by-seller-id"
-export * from "./vendor-cors-middleware"
\ No newline at end of file
+export * from "./vendor-cors-middleware"
diff --git a/packages/core/src/api/vendor/sellers/query-config.ts b/packages/core/src/api/vendor/sellers/query-config.ts
index c5268edfb..ab3bbc4c8 100644
--- a/packages/core/src/api/vendor/sellers/query-config.ts
+++ b/packages/core/src/api/vendor/sellers/query-config.ts
@@ -19,6 +19,7 @@ export const retrieveVendorSellerQueryConfig = {
"name",
"handle",
"email",
+ "phone",
"description",
"logo",
"banner",
diff --git a/packages/core/src/api/vendor/sellers/validators.ts b/packages/core/src/api/vendor/sellers/validators.ts
index c3d6ca494..d91eef004 100644
--- a/packages/core/src/api/vendor/sellers/validators.ts
+++ b/packages/core/src/api/vendor/sellers/validators.ts
@@ -19,11 +19,13 @@ export const VendorCreateSellerAccount = z.object({
name: z.string(),
handle: z.string().optional(),
email: z.string().email(),
+ phone: z.string().nullable().optional(),
member_email: z.string().email(),
description: z.string().nullable().optional(),
currency_code: z.string(),
address: z
.object({
+ name: z.string().nullable().optional(),
company: z.string().nullable().optional(),
first_name: z.string().optional(),
last_name: z.string().optional(),
@@ -62,6 +64,7 @@ export const VendorUpdateSeller = z.object({
name: z.string().optional(),
handle: z.string().optional(),
email: z.string().email().optional(),
+ phone: z.string().nullable().optional(),
description: z.string().nullable().optional(),
logo: z.string().url().nullable().optional(),
banner: z.string().url().nullable().optional(),
@@ -85,6 +88,7 @@ export const VendorUpdateMemberRole = z.object({
export type VendorUpsertSellerAddressType = z.infer<typeof VendorUpsertSellerAddress>
export const VendorUpsertSellerAddress = z.object({
+ name: z.string().nullable().optional(),
company: z.string().nullable().optional(),
first_name: z.string().nullable().optional(),
last_name: z.string().nullable().optional(),
diff --git a/packages/core/src/modules/seller/migrations/Migration20260421102419.ts b/packages/core/src/modules/seller/migrations/Migration20260421102419.ts
new file mode 100644
index 000000000..cf93013b0
--- /dev/null
+++ b/packages/core/src/modules/seller/migrations/Migration20260421102419.ts
@@ -0,0 +1,21 @@
+import { Migration } from "@medusajs/framework/mikro-orm/migrations";
+
+export class Migration20260421102419 extends Migration {
+ override async up(): Promise<void> {
+ this.addSql(
+ `alter table if exists "seller" add column if not exists "phone" text null;`
+ );
+ this.addSql(
+ `alter table if exists "seller_address" add column if not exists "name" text null;`
+ );
+ }
+
+ override async down(): Promise<void> {
+ this.addSql(
+ `alter table if exists "seller_address" drop column if exists "name";`
+ );
+ this.addSql(
+ `alter table if exists "seller" drop column if exists "phone";`
+ );
+ }
+}
diff --git a/packages/core/src/modules/seller/models/address.ts b/packages/core/src/modules/seller/models/address.ts
index 48702a500..db8b4cd8d 100644
--- a/packages/core/src/modules/seller/models/address.ts
+++ b/packages/core/src/modules/seller/models/address.ts
@@ -3,6 +3,7 @@ import Seller from "./seller"
const SellerAddress = model.define("SellerAddress", {
id: model.id({ prefix: "seladdr" }).primaryKey(),
+ name: model.text().searchable().nullable(),
company: model.text().searchable().nullable(),
first_name: model.text().searchable().nullable(),
last_name: model.text().searchable().nullable(),
diff --git a/packages/core/src/modules/seller/models/seller.ts b/packages/core/src/modules/seller/models/seller.ts
index 223ff3306..7ac01e2ab 100644
--- a/packages/core/src/modules/seller/models/seller.ts
+++ b/packages/core/src/modules/seller/models/seller.ts
@@ -13,6 +13,7 @@ const Seller = model
name: model.text().searchable(),
handle: model.text().searchable(),
email: model.text().searchable(),
+ phone: model.text().nullable(),
description: model.text().nullable(),
logo: model.text().nullable(),
banner: model.text().nullable(),
diff --git a/packages/core/src/modules/seller/service.ts b/packages/core/src/modules/seller/service.ts
index cb850760d..7062afc43 100644
--- a/packages/core/src/modules/seller/service.ts
+++ b/packages/core/src/modules/seller/service.ts
@@ -62,9 +62,18 @@ class SellerModuleService extends MedusaService({
jwt_secret:
opts.jwt_secret ??
(configManager.config.projectConfig.http.jwtSecret as string),
+ vendor_url: opts.vendor_url ?? process.env.MERCUR_VENDOR_URL ?? "",
}
}
+ buildInviteUrl(token: string): string {
+ const base = (this.options_.vendor_url ?? "").replace(/\/+$/, "")
+ if (!base || !token) {
+ return ""
+ }
+ return `${base}/invite?token=${token}`
+ }
+
@InjectTransactionManager()
// @ts-ignore
async createSellers<T extends any | any[]>(
diff --git a/packages/core/src/modules/seller/utils/ensure-seller-default-roles.ts b/packages/core/src/modules/seller/utils/ensure-seller-default-roles.ts
new file mode 100644
index 000000000..a719fdf8a
--- /dev/null
+++ b/packages/core/src/modules/seller/utils/ensure-seller-default-roles.ts
@@ -0,0 +1,119 @@
+import { IRbacModuleService, RbacRoleDTO } from "@medusajs/types"
+import { SellerRole } from "@mercurjs/types"
+
+type SellerRoleDefinition = {
+ id: SellerRole
+ name: string
+ description: string
+ policyKeys: "*" | string[]
+}
+
+export const SELLER_ROLES: SellerRoleDefinition[] = [
+ {
+ id: SellerRole.SELLER_ADMINISTRATION,
+ name: "Seller Administration",
+ description:
+ "Full access to all seller account features and settings",
+ policyKeys: "*",
+ },
+ {
+ id: SellerRole.INVENTORY_MANAGEMENT,
+ name: "Inventory Management",
+ description: "Manage offers and catalog",
+ policyKeys: [],
+ },
+ {
+ id: SellerRole.ORDER_MANAGEMENT,
+ name: "Order Management",
+ description: "View and process orders",
+ policyKeys: [],
+ },
+ {
+ id: SellerRole.ACCOUNTING,
+ name: "Accounting",
+ description: "View billing and manage payment information",
+ policyKeys: [],
+ },
+ {
+ id: SellerRole.SUPPORT,
+ name: "Support",
+ description: "Handle customer messages and view orders",
+ policyKeys: [],
+ },
+]
+
+export async function ensureSellerDefaultRoles(
+ rbacService: IRbacModuleService
+): Promise<RbacRoleDTO[]> {
+ const roleIds = SELLER_ROLES.map((role) => role.id)
+
+ const existingRoles = await rbacService.listRbacRoles({ id: roleIds })
+ const roleById = new Map(existingRoles.map((role) => [role.id, role]))
+
+ const missingRoles = SELLER_ROLES.filter((role) => !roleById.has(role.id))
+
+ if (missingRoles.length) {
+ const createdRoles = await rbacService.createRbacRoles(
+ missingRoles.map((role) => ({
+ id: role.id,
+ name: role.name,
+ description: role.description,
+ }))
+ )
+
+ createdRoles.forEach((role) => {
+ roleById.set(role.id, role)
+ })
+ }
+
+ const policies = await rbacService.listRbacPolicies({})
+ const existingRolePolicies = await rbacService.listRbacRolePolicies({
+ role_id: roleIds,
+ })
+
+ const policyByKey = new Map(policies.map((policy) => [policy.key, policy]))
+ const existingBindings = new Set(
+ existingRolePolicies.map(
+ (rolePolicy) => `${rolePolicy.role_id}:${rolePolicy.policy_id}`
+ )
+ )
+
+ const rolePoliciesToCreate: { role_id: string; policy_id: string }[] = []
+
+ for (const roleDefinition of SELLER_ROLES) {
+ const role = roleById.get(roleDefinition.id)
+
+ if (!role) {
+ continue
+ }
+
+ const targetPolicies =
+ roleDefinition.policyKeys === "*"
+ ? policies
+ : roleDefinition.policyKeys
+ .map((key) => policyByKey.get(key))
+ .filter((policy): policy is NonNullable<typeof policy> => !!policy)
+
+ for (const policy of targetPolicies) {
+ const bindingKey = `${role.id}:${policy.id}`
+
+ if (existingBindings.has(bindingKey)) {
+ continue
+ }
+
+ existingBindings.add(bindingKey)
+ rolePoliciesToCreate.push({
+ role_id: role.id,
+ policy_id: policy.id,
+ })
+ }
+ }
+
+ if (rolePoliciesToCreate.length) {
+ await rbacService.createRbacRolePolicies(rolePoliciesToCreate)
+ }
+
+ return SELLER_ROLES.map((role) => roleById.get(role.id)).filter(
+ (role): role is RbacRoleDTO => !!role
+ )
+}
diff --git a/packages/core/src/workflows/seller/steps/create-seller-default-roles.ts b/packages/core/src/workflows/seller/steps/create-seller-default-roles.ts
index 7fd82e931..92730ac28 100644
--- a/packages/core/src/workflows/seller/steps/create-seller-default-roles.ts
+++ b/packages/core/src/workflows/seller/steps/create-seller-default-roles.ts
@@ -1,42 +1,7 @@
import { Modules } from "@medusajs/framework/utils"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import { IRbacModuleService } from "@medusajs/types"
-import { SellerRole } from "@mercurjs/types"
-
-// todo: update policy keys on roles
-const SELLER_ROLES = [
- {
- id: SellerRole.SELLER_ADMINISTRATION,
- name: "Seller Administration",
- description:
- "Full access to all seller account features and settings",
- policyKeys: "*",
- },
- {
- id: SellerRole.INVENTORY_MANAGEMENT,
- name: "Inventory Management",
- description: "Manage offers and catalog",
- policyKeys: [],
- },
- {
- id: SellerRole.ORDER_MANAGEMENT,
- name: "Order Management",
- description: "View and process orders",
- policyKeys: [],
- },
- {
- id: SellerRole.ACCOUNTING,
- name: "Accounting",
- description: "View billing and manage payment information",
- policyKeys: [],
- },
- {
- id: SellerRole.SUPPORT,
- name: "Support",
- description: "Handle customer messages and view orders",
- policyKeys: [],
- },
-]
+import { ensureSellerDefaultRoles } from "../../../modules/seller/utils/ensure-seller-default-roles"
export const createSellerDefaultRolesStepId = "create-seller-default-roles"
@@ -44,69 +9,8 @@ export const createSellerDefaultRolesStep = createStep(
createSellerDefaultRolesStepId,
async (_: void, { container }) => {
const rbacService: IRbacModuleService = container.resolve(Modules.RBAC)
+ const roles = await ensureSellerDefaultRoles(rbacService)
- const existingRoles = await rbacService.listRbacRoles({
- id: SELLER_ROLES.map((r) => r.id),
- })
-
- if (existingRoles.length > 0) {
- return new StepResponse(existingRoles)
- }
-
- const createdRoles = await rbacService.createRbacRoles(
- SELLER_ROLES.map((r) => ({
- id: r.id,
- name: r.name,
- description: r.description,
- }))
- )
-
- const allPolicyKeys = [
- ...new Set(
- SELLER_ROLES.flatMap((r) =>
- r.policyKeys === "*" ? [] : r.policyKeys
- )
- ),
- ]
-
- const policies = await rbacService.listRbacPolicies(
- allPolicyKeys.length > 0 ? { key: allPolicyKeys } : {}
- )
-
- const policyByKey = new Map(policies.map((p) => [p.key, p]))
-
- const rolePolicies: { role_id: string; policy_id: string }[] = []
-
- for (let i = 0; i < SELLER_ROLES.length; i++) {
- const roleDef = SELLER_ROLES[i]
- const createdRole = createdRoles[i]
-
- if (roleDef.policyKeys === "*") {
- for (const policy of policies) {
- rolePolicies.push({
- role_id: createdRole.id,
- policy_id: policy.id,
- })
- }
- } else {
- for (const key of roleDef.policyKeys) {
- const policy = policyByKey.get(key)
- if (policy) {
- rolePolicies.push({
- role_id: createdRole.id,
- policy_id: policy.id,
- })
- }
- }
- }
- }
-
- if (rolePolicies.length > 0) {
- await rbacService.createRbacRolePolicies(rolePolicies)
- }
-
- return new StepResponse(
- createdRoles,
- )
+ return new StepResponse(roles)
},
)
diff --git a/packages/core/src/workflows/seller/workflows/accept-member-invite.ts b/packages/core/src/workflows/seller/workflows/accept-member-invite.ts
index 664d87df8..228a1f499 100644
--- a/packages/core/src/workflows/seller/workflows/accept-member-invite.ts
+++ b/packages/core/src/workflows/seller/workflows/accept-member-invite.ts
@@ -14,6 +14,7 @@ import {
upsertMembersStep,
createSellerMembersStep,
deleteMemberInviteStep,
+ createSellerDefaultRolesStep,
} from "../steps"
import { MemberInviteWorkflowEvents } from "../../events"
@@ -28,6 +29,8 @@ type AcceptMemberInviteWorkflowInput = {
export const acceptMemberInviteWorkflow = createWorkflow(
acceptMemberInviteWorkflowId,
function (input: AcceptMemberInviteWorkflowInput) {
+ createSellerDefaultRolesStep()
+
const invite = validateMemberInviteTokenStep(input.invite_token)
const members = upsertMembersStep(
diff --git a/packages/core/src/workflows/seller/workflows/create-seller-account.ts b/packages/core/src/workflows/seller/workflows/create-seller-account.ts
index 56a7e9a12..bbc4cd1fe 100644
--- a/packages/core/src/workflows/seller/workflows/create-seller-account.ts
+++ b/packages/core/src/workflows/seller/workflows/create-seller-account.ts
@@ -23,6 +23,7 @@ import {
createSellersStep,
upsertMembersStep,
createSellerMembersStep,
+ createSellerDefaultRolesStep,
} from "../steps"
import { SellerWorkflowEvents } from "../../events"
import { updateSellerAddressWorkflow } from "./update-seller-address"
@@ -44,6 +45,8 @@ type CreateSellerAccountWorkflowInput = {
export const createSellerAccountWorkflow = createWorkflow(
createSellerAccountWorkflowId,
function (input: CreateSellerAccountWorkflowInput) {
+ createSellerDefaultRolesStep()
+
const sellerData = transform(input, ({ seller }) => [
{ ...seller, status: SellerStatus.PENDING_APPROVAL },
])
diff --git a/packages/core/src/workflows/seller/workflows/delete-member-invite.ts b/packages/core/src/workflows/seller/workflows/delete-member-invite.ts
new file mode 100644
index 000000000..c55880792
--- /dev/null
+++ b/packages/core/src/workflows/seller/workflows/delete-member-invite.ts
@@ -0,0 +1,18 @@
+import { createWorkflow, WorkflowResponse } from "@medusajs/framework/workflows-sdk"
+
+import { deleteMemberInviteStep } from "../steps"
+
+export const deleteMemberInviteWorkflowId = "delete-member-invite"
+
+type DeleteMemberInviteWorkflowInput = {
+ invite_id: string
+}
+
+export const deleteMemberInviteWorkflow = createWorkflow(
+ deleteMemberInviteWorkflowId,
+ function (input: DeleteMemberInviteWorkflowInput) {
+ deleteMemberInviteStep([input.invite_id])
+
+ return new WorkflowResponse(void 0)
+ }
+)
diff --git a/packages/core/src/workflows/seller/workflows/index.ts b/packages/core/src/workflows/seller/workflows/index.ts
index 505d3db6f..e299a86f8 100644
--- a/packages/core/src/workflows/seller/workflows/index.ts
+++ b/packages/core/src/workflows/seller/workflows/index.ts
@@ -8,6 +8,8 @@ export * from "./approve-seller"
export * from "./terminate-seller"
export * from "./unterminate-seller"
export * from "./create-member-invites"
+export * from "./delete-member-invite"
+export * from "./resend-member-invite"
export * from "./accept-member-invite"
export * from "./update-member-role"
export * from "./remove-seller-member"
diff --git a/packages/core/src/workflows/seller/workflows/resend-member-invite.ts b/packages/core/src/workflows/seller/workflows/resend-member-invite.ts
new file mode 100644
index 000000000..f69a5ac29
--- /dev/null
+++ b/packages/core/src/workflows/seller/workflows/resend-member-invite.ts
@@ -0,0 +1,87 @@
+import {
+ createStep,
+ createWorkflow,
+ StepResponse,
+ transform,
+ WorkflowResponse,
+} from "@medusajs/framework/workflows-sdk"
+import { emitEventStep } from "@medusajs/medusa/core-flows"
+import { MedusaError } from "@medusajs/framework/utils"
+import { MercurModules } from "@mercurjs/types"
+
+import SellerModuleService from "../../../modules/seller/service"
+import {
+ createMemberInvitesStep,
+ deleteMemberInviteStep,
+} from "../steps"
+import { MemberInviteWorkflowEvents } from "../../events"
+
+type ResendMemberInviteWorkflowInput = {
+ invite_id: string
+ seller_id: string
+}
+
+const loadInviteStep = createStep(
+ "load-member-invite",
+ async (
+ input: { invite_id: string; seller_id: string },
+ { container }
+ ) => {
+ const service =
+ container.resolve<SellerModuleService>(MercurModules.SELLER)
+
+ const invites = await service.listMemberInvites({
+ id: input.invite_id,
+ seller_id: input.seller_id,
+ })
+
+ const invite = invites[0]
+
+ if (!invite) {
+ throw new MedusaError(
+ MedusaError.Types.NOT_FOUND,
+ `Invite ${input.invite_id} not found`
+ )
+ }
+
+ return new StepResponse({
+ email: invite.email,
+ role_id: invite.role_id,
+ seller_id: invite.seller_id,
+ })
+ }
+)
+
+export const resendMemberInviteWorkflowId = "resend-member-invite"
+
+export const resendMemberInviteWorkflow = createWorkflow(
+ resendMemberInviteWorkflowId,
+ function (input: ResendMemberInviteWorkflowInput) {
+ const existing = loadInviteStep(input)
+
+ deleteMemberInviteStep([input.invite_id])
+
+ const createInput = transform({ existing }, ({ existing }) => [
+ {
+ seller_id: existing.seller_id,
+ email: existing.email,
+ role_id: existing.role_id,
+ },
+ ])
+
+ const invites = createMemberInvitesStep(createInput)
+
+ emitEventStep({
+ eventName: MemberInviteWorkflowEvents.CREATED,
+ data: transform({ invites }, ({ invites }) =>
+ invites.map((inv) => ({
+ id: inv.id,
+ token: inv.token,
+ expires_at: inv.expires_at,
+ }))
+ ),
+ })
+
+ return new WorkflowResponse(invites)
+ }
+)
diff --git a/packages/types/src/seller/common.ts b/packages/types/src/seller/common.ts
index 2d204e660..b06990b04 100644
--- a/packages/types/src/seller/common.ts
+++ b/packages/types/src/seller/common.ts
@@ -1,6 +1,7 @@
export type SellerModuleOptions = {
invite_valid_duration?: number
jwt_secret?: string
+ vendor_url?: string
}
export enum SellerRole {
@@ -74,6 +75,7 @@ export interface UpdatePaymentDetailsDTO {
export interface SellerAddressDTO {
id: string
+ name: string | null
company: string | null
first_name: string | null
last_name: string | null
@@ -90,6 +92,7 @@ export interface SellerAddressDTO {
}
export interface CreateSellerAddressDTO {
+ name?: string | null
company?: string | null
first_name?: string | null
last_name?: string | null
@@ -104,6 +107,7 @@ export interface CreateSellerAddressDTO {
}
export interface UpdateSellerAddressDTO {
+ name?: string | null
company?: string | null
first_name?: string | null
last_name?: string | null
@@ -180,6 +184,7 @@ export interface SellerDTO {
name: string
handle: string
email: string
+ phone: string | null
description: string | null
logo: string | null
banner: string | null
diff --git a/packages/vendor/src/components/layout/auth-layout/auth-layout.tsx b/packages/vendor/src/components/layout/auth-layout/auth-layout.tsx
new file mode 100644
index 000000000..e7057be21
--- /dev/null
+++ b/packages/vendor/src/components/layout/auth-layout/auth-layout.tsx
@@ -0,0 +1,31 @@
+import { ReactNode } from "react";
+
+type AuthLayoutProps = {
+ children: ReactNode;
+};
+
+export const AuthLayout = ({ children }: AuthLayoutProps) => {
+ return (
+ <div className="flex h-dvh w-dvw overflow-hidden">
+ <div className="bg-ui-bg-base border-ui-border-base flex h-full w-full flex-col overflow-y-auto border-r lg:w-[584px] lg:shrink-0">
+ <div className="flex flex-1 flex-col p-8 lg:px-14 lg:py-12">
+ {children}
+ </div>
+ </div>
+ <div
+ className="relative hidden flex-1 items-center justify-center overflow-hidden lg:flex"
+ style={{
+ backgroundImage: "url(/onboarding/bg.svg)",
+ backgroundSize: "cover",
+ backgroundPosition: "center",
+ }}
+ >
+ <img
+ src="/onboarding/0.png"
+ alt=""
+ className="max-h-[75%] w-[75%] object-contain"
+ />
+ </div>
+ </div>
+ );
+};
diff --git a/packages/vendor/src/components/layout/auth-layout/index.ts b/packages/vendor/src/components/layout/auth-layout/index.ts
new file mode 100644
index 000000000..c945a6fcd
--- /dev/null
+++ b/packages/vendor/src/components/layout/auth-layout/index.ts
@@ -0,0 +1 @@
+export { AuthLayout } from "./auth-layout";
diff --git a/packages/vendor/src/components/onboarding-wizard/hooks/use-onboarding.ts b/packages/vendor/src/components/onboarding-wizard/hooks/use-onboarding.ts
index 578ae985d..eada388d0 100644
--- a/packages/vendor/src/components/onboarding-wizard/hooks/use-onboarding.ts
+++ b/packages/vendor/src/components/onboarding-wizard/hooks/use-onboarding.ts
@@ -2,18 +2,21 @@ import { useState, useCallback, useRef } from "react";
import { useNavigate } from "react-router-dom";
import { toast } from "@medusajs/ui";
-import { useCreateSellerAccount } from "@hooks/api";
+import { useCreateSellerAccount, useLogout } from "@hooks/api";
+import { queryClient } from "@lib/query-client";
import { TOTAL_STEPS } from "../constants";
type StoreData = {
name: string;
email: string;
+ phone?: string;
currency_code: string;
description?: string;
handle?: string;
};
type AddressData = {
+ name?: string;
address_1?: string;
address_2?: string;
postal_code?: string;
@@ -56,6 +59,7 @@ export const useOnboarding = (memberEmail: string) => {
const { mutateAsync: createSeller, isPending: isCreating } =
useCreateSellerAccount();
+ const { mutateAsync: logout } = useLogout();
const isPending = isCreating || isSubmitting;
@@ -119,11 +123,13 @@ export const useOnboarding = (memberEmail: string) => {
name: storeData.name,
handle: storeData.handle || undefined,
email: storeData.email,
+ phone: storeData.phone || undefined,
member_email: memberEmail,
currency_code: storeData.currency_code.toLowerCase(),
description: storeData.description || undefined,
address: addressData
? {
+ name: addressData.name || undefined,
address_1: addressData.address_1 || undefined,
address_2: addressData.address_2 || undefined,
postal_code: addressData.postal_code || undefined,
@@ -149,9 +155,7 @@ export const useOnboarding = (memberEmail: string) => {
routing_number: isUS
? paymentData.routing_number || null
: null,
- account_number: isUS
- ? null
- : paymentData.account_number || null,
+ account_number: paymentData.account_number || null,
}
: undefined,
});
@@ -159,14 +163,23 @@ export const useOnboarding = (memberEmail: string) => {
const newSellerId = result.seller.id;
setSellerId(newSellerId);
- navigate("/store-select", { replace: true });
+ // 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");
+
+ navigate("/login", { replace: true });
} catch (error: any) {
toast.error(error.message);
} finally {
setIsSubmitting(false);
}
},
- [createSeller, memberEmail, navigate],
+ [createSeller, logout, memberEmail, navigate],
);
// Step 4: Payment — create seller with everything and finish
diff --git a/packages/vendor/src/components/onboarding-wizard/steps/address-step.tsx b/packages/vendor/src/components/onboarding-wizard/steps/address-step.tsx
index 7815fa683..9227ed8cc 100644
--- a/packages/vendor/src/components/onboarding-wizard/steps/address-step.tsx
+++ b/packages/vendor/src/components/onboarding-wizard/steps/address-step.tsx
@@ -9,6 +9,7 @@ import { Form } from "@components/common/form";
import { CountrySelect } from "@components/inputs/country-select/country-select";
const AddressStepSchema = z.object({
+ name: z.string().min(1, i18n.t("onboarding.wizard.validation.nameRequired")),
address_1: z.string().optional(),
address_2: z.string().optional(),
postal_code: z.string().optional(),
@@ -31,6 +32,7 @@ export const AddressStep = ({ onSubmit, onSkip, isPending }: AddressStepProps) =
const form = useForm<AddressStepValues>({
resolver: zodResolver(AddressStepSchema),
defaultValues: {
+ name: "",
address_1: "",
address_2: "",
postal_code: "",
@@ -53,6 +55,24 @@ export const AddressStep = ({ onSubmit, onSkip, isPending }: AddressStepProps) =
<Form {...form}>
<form onSubmit={handleSubmit} className="flex flex-col gap-y-6">
<div className="flex flex-col gap-y-4">
+ <Form.Field
+ control={form.control}
+ name="name"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>
+ {t("onboarding.wizard.address.name")}
+ </Form.Label>
+ <Form.Control>
+ <Input
+ placeholder={t("onboarding.wizard.address.namePlaceholder")}
+ {...field}
+ />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
<Form.Field
control={form.control}
name="address_1"
diff --git a/packages/vendor/src/components/onboarding-wizard/steps/store-step.tsx b/packages/vendor/src/components/onboarding-wizard/steps/store-step.tsx
index 7ecb9801d..5e67282af 100644
--- a/packages/vendor/src/components/onboarding-wizard/steps/store-step.tsx
+++ b/packages/vendor/src/components/onboarding-wizard/steps/store-step.tsx
@@ -14,6 +14,7 @@ import { onboardingLoader } from "../../../pages/onboarding/loader";
const StoreStepSchema = z.object({
name: z.string().min(1, i18n.t("onboarding.wizard.validation.nameRequired")),
email: z.string().email(i18n.t("onboarding.wizard.validation.emailInvalid")),
+ phone: z.string().optional(),
currency_code: z.string().min(1, i18n.t("onboarding.wizard.validation.currencyRequired")),
description: z.string().optional(),
handle: z.string().optional(),
@@ -38,6 +39,7 @@ export const StoreStep = ({ onSubmit, isPending }: StoreStepProps) => {
defaultValues: {
name: "",
email: "",
+ phone: "",
currency_code: "",
description: "",
handle: "",
@@ -83,6 +85,19 @@ export const StoreStep = ({ onSubmit, isPending }: StoreStepProps) => {
</Form.Item>
)}
/>
+ <Form.Field
+ control={form.control}
+ name="phone"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label optional>{t("fields.phone")}</Form.Label>
+ <Form.Control>
+ <Input type="tel" autoComplete="tel" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
<Form.Field
control={form.control}
name="description"
@@ -103,7 +118,10 @@ export const StoreStep = ({ onSubmit, isPending }: StoreStepProps) => {
name="handle"
render={({ field }) => (
<Form.Item>
- <Form.Label optional>
+ <Form.Label
+ optional
+ tooltip={t("onboarding.wizard.store.handleTooltip")}
+ >
{t("onboarding.wizard.store.handle")}
</Form.Label>
<Form.Control>
diff --git a/packages/vendor/src/i18n/translations/en.json b/packages/vendor/src/i18n/translations/en.json
index 6135c60ac..88dc080c9 100644
--- a/packages/vendor/src/i18n/translations/en.json
+++ b/packages/vendor/src/i18n/translations/en.json
@@ -2686,6 +2686,7 @@
"domain": "Seller",
"manageYourStoresDetails": "Manage your seller's details",
"editStore": "Edit seller",
+ "handleTooltip": "The handle becomes the URL slug for your store. Leave empty to auto-generate from the name.",
"profileCompletion": {
"title": "Complete store profile",
"steps": {
@@ -2746,6 +2747,9 @@
},
"address": {
"header": "Address",
+ "defaultName": "Headquarters",
+ "nameLabel": "Name",
+ "namePlaceholder": "Headquarters",
"empty": {
"title": "No address",
"message": "There are no records to show"
@@ -2789,7 +2793,7 @@
"successToast": "Professional details updated"
},
"fields": {
- "corporateName": "Corporate name",
+ "corporateName": "Company",
"registrationNumber": "Registration number",
"taxId": "Tax ID"
}
@@ -3160,26 +3164,27 @@
}
},
"storeSelect": {
- "title": "Choose a store",
- "subtitle": "These are all your available stores",
- "pendingApproval": "Pending approval",
+ "title": "Select a store",
+ "subtitle": "Choose a store to continue.",
+ "pendingApproval": "Pending",
"addNewStore": "Add new store",
"status": {
- "open": "Open",
- "pendingApproval": "Pending approval",
- "suspended": "Suspended",
+ "open": "Active",
+ "pendingApproval": "Pending",
+ "suspended": "Inactive",
"terminated": "Terminated"
}
},
"login": {
- "forgotPassword": "Forgot password? - <0>Reset</0>",
- "title": "Welcome to {{name}}",
- "hint": "Sign in to access the vendor hub",
- "notSellerYet": "Not a seller yet? - <0>Create an account</0>"
+ "forgotPassword": "Forgot password? <0>Reset</0>",
+ "title": "Welcome back!",
+ "hint": "Log in to your vendor account.",
+ "submit": "Log in",
+ "notSellerYet": "Not a seller yet? <0>Create an account</0>"
},
"register": {
- "title": "Start selling on {{name}}",
- "hint": "Create account to get started",
+ "title": "Create your vendor account",
+ "hint": "Start selling on {{name}}.",
"companyName": "Company name",
"confirmPassword": "Confirm password",
"signUp": "Sign up",
@@ -3224,7 +3229,7 @@
"professionalSubtitle": "Professional seller information",
"isProfessional": "Professional seller",
"isProfessionalDescription": "Register as a business entity",
- "corporateName": "Corporate name",
+ "corporateName": "Company",
"registrationNumber": "Registration number",
"taxId": "Tax ID",
"completeSetup": "Complete setup"
@@ -3248,6 +3253,7 @@
"name": "Name",
"email": "Email",
"handle": "Handle",
+ "handleTooltip": "The handle becomes the URL slug for your store. Leave empty to auto-generate from the name.",
"handlePlaceholder": "my-store",
"currency": "Currency",
"selectCurrency": "Select",
@@ -3256,6 +3262,8 @@
"skip": "Skip",
"address": {
"title": "Enter your address",
+ "name": "Name",
+ "namePlaceholder": "Headquarters",
"address": "Address",
"address2": "Apartment, suite, etc.",
"postalCode": "Postal Code",
@@ -3266,7 +3274,7 @@
"company": {
"title": "Enter your company details",
"subtitle": "Professional seller information",
- "corporateName": "Corporate name",
+ "corporateName": "Company",
"registrationNumber": "Registration number",
"taxId": "Tax ID"
},
@@ -3569,7 +3577,7 @@
"company": "Company",
"phone": "Phone",
"metadata": "Metadata",
- "selectCountry": "Select country",
+ "selectCountry": "Select",
"products": "Products",
"variants": "Variants",
"orders": "Orders",
diff --git a/packages/vendor/src/pages/login/login.tsx b/packages/vendor/src/pages/login/login.tsx
index 860c92378..875e19757 100644
--- a/packages/vendor/src/pages/login/login.tsx
+++ b/packages/vendor/src/pages/login/login.tsx
@@ -8,6 +8,7 @@ import * as z from "zod";
import { Form } from "@components/common/form";
import AvatarBox from "@components/common/logo-box/avatar-box";
+import { AuthLayout } from "@components/layout/auth-layout";
import { useSignInWithEmailPass } from "@hooks/api";
import { isFetchError } from "@lib/is-fetch-error";
import config from "virtual:mercur/config";
@@ -25,9 +26,9 @@ const LoginHeader = () => {
const { t } = useTranslation();
return (
- <div className="mb-4 flex flex-col items-center">
- <Heading>{t("login.title", { name: config.name ?? "Mercur" })}</Heading>
- <Text size="small" className="text-ui-fg-subtle text-center">
+ <div className="mb-6 flex flex-col">
+ <Heading>{t("login.title")}</Heading>
+ <Text size="small" className="text-ui-fg-subtle">
{t("login.hint")}
</Text>
</div>
@@ -99,77 +100,64 @@ const LoginForm = () => {
form.formState.errors.password?.message;
return (
- <div className="flex w-full flex-col gap-y-3">
- <Form {...form}>
- <form onSubmit={handleSubmit} className="flex w-full flex-col gap-y-6">
- <div className="flex flex-col gap-y-2">
- <Form.Field
- control={form.control}
- name="email"
- render={({ field }) => {
- return (
- <Form.Item>
- <Form.Control>
- <Input
- autoComplete="email"
- {...field}
- className="bg-ui-bg-field-component"
- placeholder={t("fields.email")}
- />
- </Form.Control>
- </Form.Item>
- );
- }}
- />
- <Form.Field
- control={form.control}
- name="password"
- render={({ field }) => {
- return (
- <Form.Item>
- <Form.Control>
- <Input
- type="password"
- autoComplete="current-password"
- {...field}
- className="bg-ui-bg-field-component"
- placeholder={t("fields.password")}
- />
- </Form.Control>
- </Form.Item>
- );
- }}
- />
- {validationError && (
- <div className="mt-6 text-center">
- <Hint className="inline-flex" variant={"error"}>
- {validationError}
- </Hint>
- </div>
+ <Form {...form}>
+ <form onSubmit={handleSubmit} className="flex w-full flex-col gap-y-6">
+ <div className="flex flex-col gap-y-4">
+ <Form.Field
+ control={form.control}
+ name="email"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.email")}</Form.Label>
+ <Form.Control>
+ <Input autoComplete="email" {...field} />
+ </Form.Control>
+ </Form.Item>
)}
- {serverError && (
- <Alert
- className="bg-ui-bg-base items-center p-2"
- dismissible
- variant="error"
- >
- {serverError}
- </Alert>
+ />
+ <Form.Field
+ control={form.control}
+ name="password"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.password")}</Form.Label>
+ <Form.Control>
+ <Input
+ type="password"
+ autoComplete="current-password"
+ {...field}
+ />
+ </Form.Control>
+ </Form.Item>
)}
- </div>
- <Button className="w-full" type="submit" isLoading={isPending}>
- Sign In
- </Button>
- </form>
- </Form>
- </div>
+ />
+ {validationError && (
+ <Hint className="inline-flex" variant="error">
+ {validationError}
+ </Hint>
+ )}
+ {serverError && (
+ <Alert
+ className="bg-ui-bg-base items-center p-2"
+ dismissible
+ variant="error"
+ >
+ {serverError}
+ </Alert>
+ )}
+ </div>
+ <Button className="w-full" type="submit" isLoading={isPending}>
+ {t("login.submit")}
+ </Button>
+ </form>
+ </Form>
);
};
const LoginFooter = () => {
return (
- <div className="flex flex-col items-center">
- <span className="text-ui-fg-muted txt-small my-6">
+ <div className="mt-auto flex flex-col gap-y-2">
+ <span className="text-ui-fg-muted txt-small">
<Trans
i18nKey="login.forgotPassword"
components={[
@@ -201,20 +189,20 @@ const LoginFooter = () => {
const Root = ({ children }: { children?: ReactNode }) => {
return (
- <div className="bg-ui-bg-subtle flex min-h-dvh w-dvw items-center justify-center">
- <div className="m-4 flex w-full max-w-[280px] flex-col items-center">
- {Children.count(children) > 0 ? (
- children
- ) : (
- <>
- <LoginLogo />
+ <AuthLayout>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <LoginLogo />
+ <div className="mt-8">
<LoginHeader />
<LoginForm />
- <LoginFooter />
- </>
- )}
- </div>
- </div>
+ </div>
+ <LoginFooter />
+ </>
+ )}
+ </AuthLayout>
);
};
diff --git a/packages/vendor/src/pages/register/register.tsx b/packages/vendor/src/pages/register/register.tsx
index 6101e50fb..b475fa613 100644
--- a/packages/vendor/src/pages/register/register.tsx
+++ b/packages/vendor/src/pages/register/register.tsx
@@ -12,6 +12,7 @@ import * as z from "zod"
import { Form } from "@components/common/form"
import AvatarBox from "@components/common/logo-box/avatar-box"
+import { AuthLayout } from "@components/layout/auth-layout"
import { useFeatureFlags, useSignUpWithEmailPass } from "@hooks/api"
import { RegisterSchema } from "./register-schema"
@@ -24,10 +25,10 @@ const RegisterHeader = () => {
const { t } = useTranslation()
return (
- <div className="mb-4 flex flex-col items-center">
- <Heading>{t("register.title", { name: config.name ?? "Mercur" })}</Heading>
- <Text size="small" className="text-ui-fg-subtle text-center">
- {t("register.hint")}
+ <div className="mb-6 flex flex-col">
+ <Heading>{t("register.title")}</Heading>
+ <Text size="small" className="text-ui-fg-subtle">
+ {t("register.hint", { name: config.name ?? "Mercur" })}
</Text>
</div>
)
@@ -47,8 +48,7 @@ const RegisterForm = () => {
},
})
- const { mutateAsync: signUp, isPending } =
- useSignUpWithEmailPass()
+ const { mutateAsync: signUp, isPending } = useSignUpWithEmailPass()
const handleSubmit = form.handleSubmit(async ({ email, password }) => {
setServerError(null)
@@ -56,9 +56,7 @@ const RegisterForm = () => {
await signUp({ email, password })
navigate("/onboarding", { state: { email } })
} catch (error: any) {
- setServerError(
- error?.message || t("register.error")
- )
+ setServerError(error?.message || t("register.error"))
}
})
@@ -70,85 +68,70 @@ const RegisterForm = () => {
const displayError = validationError || serverError
return (
- <div className="flex w-full flex-col items-center">
- <Form {...form}>
- <form
- onSubmit={handleSubmit}
- className="flex w-full flex-col gap-y-6"
- >
- <div className="flex flex-col gap-y-2">
- <Form.Field
- control={form.control}
- name="email"
- render={({ field }) => (
- <Form.Item>
- <Form.Control>
- <Input
- autoComplete="email"
- {...field}
- className="bg-ui-bg-field-component"
- placeholder={t("fields.email")}
- />
- </Form.Control>
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="password"
- render={({ field }) => (
- <Form.Item>
- <Form.Control>
- <Input
- type="password"
- autoComplete="new-password"
- {...field}
- className="bg-ui-bg-field-component"
- placeholder={t("fields.password")}
- />
- </Form.Control>
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="confirmPassword"
- render={({ field }) => (
- <Form.Item>
- <Form.Control>
- <Input
- type="password"
- autoComplete="new-password"
- {...field}
- className="bg-ui-bg-field-component"
- placeholder={t("register.confirmPassword")}
- />
- </Form.Control>
- </Form.Item>
- )}
- />
- {displayError && (
- <div className="mt-6 text-center">
- <Hint className="inline-flex" variant={"error"}>
- {displayError}
- </Hint>
- </div>
+ <Form {...form}>
+ <form onSubmit={handleSubmit} className="flex w-full flex-col gap-y-6">
+ <div className="flex flex-col gap-y-4">
+ <Form.Field
+ control={form.control}
+ name="email"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.email")}</Form.Label>
+ <Form.Control>
+ <Input autoComplete="email" {...field} />
+ </Form.Control>
+ </Form.Item>
)}
- </div>
- <Button className="w-full" type="submit" isLoading={isPending}>
- {t("actions.continue")}
- </Button>
- </form>
- </Form>
- <RegisterFooter />
- </div>
+ />
+ <Form.Field
+ control={form.control}
+ name="password"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.password")}</Form.Label>
+ <Form.Control>
+ <Input
+ type="password"
+ autoComplete="new-password"
+ {...field}
+ />
+ </Form.Control>
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="confirmPassword"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("register.confirmPassword")}</Form.Label>
+ <Form.Control>
+ <Input
+ type="password"
+ autoComplete="new-password"
+ {...field}
+ />
+ </Form.Control>
+ </Form.Item>
+ )}
+ />
+ {displayError && (
+ <Hint className="inline-flex" variant="error">
+ {displayError}
+ </Hint>
+ )}
+ </div>
+ <Button className="w-full" type="submit" isLoading={isPending}>
+ {t("actions.continue")}
+ </Button>
+ </form>
+ </Form>
)
}
const RegisterFooter = () => {
return (
- <div className="flex w-full flex-col items-center">
- <div className="my-6 h-px w-full border-b border-dotted" />
+ <div className="mt-auto">
<span className="text-ui-fg-muted txt-small">
<Trans
i18nKey="register.alreadySeller"
@@ -156,7 +139,7 @@ const RegisterFooter = () => {
<Link
key="login-link"
to="/login"
- className="txt-small text-ui-fg-base transition-fg hover:text-ui-fg-base-hover focus-visible:text-ui-fg-base-hover font-medium outline-none"
+ className="text-ui-fg-interactive transition-fg hover:text-ui-fg-interactive-hover focus-visible:text-ui-fg-interactive-hover font-medium outline-none"
/>,
]}
/>
@@ -181,19 +164,20 @@ const Root = ({ children }: { children?: ReactNode }) => {
}
return (
- <div className="bg-ui-bg-subtle flex min-h-dvh w-dvw items-center justify-center">
- <div className="m-4 flex w-full max-w-[280px] flex-col items-center">
- {Children.count(children) > 0 ? (
- children
- ) : (
- <>
- <RegisterLogo />
+ <AuthLayout>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <RegisterLogo />
+ <div className="mt-8">
<RegisterHeader />
<RegisterForm />
- </>
- )}
- </div>
- </div>
+ </div>
+ <RegisterFooter />
+ </>
+ )}
+ </AuthLayout>
)
}
diff --git a/packages/vendor/src/pages/settings/store/_components/store-address-section.tsx b/packages/vendor/src/pages/settings/store/_components/store-address-section.tsx
index 89e25ba08..92a58dbd3 100644
--- a/packages/vendor/src/pages/settings/store/_components/store-address-section.tsx
+++ b/packages/vendor/src/pages/settings/store/_components/store-address-section.tsx
@@ -54,9 +54,7 @@ export const StoreAddressSection = ({ seller }: StoreAddressSectionProps) => {
</IconAvatar>
<div className="flex flex-1 flex-col">
<Text size="small" leading="compact" weight="plus">
- {[address?.first_name, address?.last_name]
- .filter(Boolean)
- .join(" ") || address?.company || formattedAddress}
+ {address?.name || t("store.address.defaultName")}
</Text>
<Text
size="small"
diff --git a/packages/vendor/src/pages/settings/store/_components/store-detail-header.tsx b/packages/vendor/src/pages/settings/store/_components/store-detail-header.tsx
index 1c188c657..cf2a8c27f 100644
--- a/packages/vendor/src/pages/settings/store/_components/store-detail-header.tsx
+++ b/packages/vendor/src/pages/settings/store/_components/store-detail-header.tsx
@@ -1,6 +1,6 @@
import { Children, ReactNode } from "react";
import { PencilSquare } from "@medusajs/icons";
-import { Avatar, Heading, StatusBadge } from "@medusajs/ui";
+import { Avatar, Badge, Heading, StatusBadge } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
import { ActionMenu } from "@components/common/action-menu";
@@ -42,6 +42,8 @@ const getStatusLabel = (status: string, t: TFunction) => {
};
export const StoreDetailTitle = ({ seller }: StoreProps) => {
+ const { t } = useTranslation();
+
return (
<div className="flex items-center gap-x-4">
<Avatar
@@ -50,7 +52,14 @@ export const StoreDetailTitle = ({ seller }: StoreProps) => {
src={seller.logo || undefined}
fallback={seller.name.charAt(0).toUpperCase()}
/>
- <Heading>{seller.name}</Heading>
+ <div className="flex items-center gap-x-2">
+ <Heading>{seller.name}</Heading>
+ {seller.is_premium && (
+ <Badge size="2xsmall" color="purple">
+ {t("fields.premium")}
+ </Badge>
+ )}
+ </div>
</div>
);
};
diff --git a/packages/vendor/src/pages/settings/store/_components/store-general-section.tsx b/packages/vendor/src/pages/settings/store/_components/store-general-section.tsx
index e2889b065..8ca650010 100644
--- a/packages/vendor/src/pages/settings/store/_components/store-general-section.tsx
+++ b/packages/vendor/src/pages/settings/store/_components/store-general-section.tsx
@@ -71,6 +71,14 @@ export const StoreGeneralSection = ({
{seller.email || "-"}
</Text>
</div>
+ <div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
+ <Text size="small" leading="compact" weight="plus">
+ {t("fields.phone")}
+ </Text>
+ <Text size="small" leading="compact">
+ {seller.phone || "-"}
+ </Text>
+ </div>
<div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
<Text size="small" leading="compact" weight="plus">
{t("fields.website")}
@@ -92,26 +100,6 @@ export const StoreGeneralSection = ({
</Text>
</div>
</div>
- <div className="text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4">
- <Text size="small" leading="compact" weight="plus">
- {t("fields.premium")}
- </Text>
- <Text size="small" leading="compact">
- {seller.is_premium ? t("general.yes") : t("general.no")}
- </Text>
- </div>
- <div className="text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4">
- <Text size="small" leading="compact" weight="plus">
- {t("fields.createdAt")}
- </Text>
- <Text size="small" leading="compact">
- {new Date(seller.created_at).toLocaleDateString(undefined, {
- year: "numeric",
- month: "long",
- day: "numeric",
- })}
- </Text>
- </div>
</>
)}
</Container>
diff --git a/packages/vendor/src/pages/settings/store/_components/store-time-off-section.tsx b/packages/vendor/src/pages/settings/store/_components/store-time-off-section.tsx
index 3e94fd7c5..899376cae 100644
--- a/packages/vendor/src/pages/settings/store/_components/store-time-off-section.tsx
+++ b/packages/vendor/src/pages/settings/store/_components/store-time-off-section.tsx
@@ -154,10 +154,6 @@ export const StoreTimeOffSection = ({ seller }: StoreTimeOffSectionProps) => {
heading={t("store.timeOff.header")}
enableSearch={false}
enablePagination={false}
- action={{
- to: "store-closure",
- label: t("actions.create"),
- }}
/>
</Container>
);
diff --git a/packages/vendor/src/pages/settings/store/address/store-address-form.tsx b/packages/vendor/src/pages/settings/store/address/store-address-form.tsx
index c35b09ac5..d547eef2d 100644
--- a/packages/vendor/src/pages/settings/store/address/store-address-form.tsx
+++ b/packages/vendor/src/pages/settings/store/address/store-address-form.tsx
@@ -16,14 +16,13 @@ type StoreAddressFormProps = {
};
const StoreAddressSchema = zod.object({
- first_name: zod.string().min(1),
- last_name: zod.string().min(1),
+ name: zod.string().min(1),
address_1: zod.string().optional().or(zod.literal("")),
+ address_2: zod.string().optional().or(zod.literal("")),
city: zod.string().optional().or(zod.literal("")),
province: zod.string().optional().or(zod.literal("")),
- postal_code: zod.string().min(1),
+ postal_code: zod.string().optional().or(zod.literal("")),
country_code: zod.string().min(2).max(2),
- phone: zod.string().min(1),
});
export const StoreAddressForm = ({ seller }: StoreAddressFormProps) => {
@@ -33,14 +32,13 @@ export const StoreAddressForm = ({ seller }: StoreAddressFormProps) => {
const form = useForm<zod.infer<typeof StoreAddressSchema>>({
defaultValues: {
- first_name: address?.first_name ?? "",
- last_name: address?.last_name ?? "",
+ name: address?.name ?? "",
address_1: address?.address_1 ?? "",
+ address_2: address?.address_2 ?? "",
city: address?.city ?? "",
province: address?.province ?? "",
postal_code: address?.postal_code ?? "",
country_code: address?.country_code ?? "",
- phone: address?.phone ?? "",
},
resolver: zodResolver(StoreAddressSchema),
});
@@ -50,14 +48,13 @@ export const StoreAddressForm = ({ seller }: StoreAddressFormProps) => {
const handleSubmit = form.handleSubmit(async (values) => {
await mutateAsync(
{
- first_name: values.first_name,
- last_name: values.last_name,
+ name: values.name,
address_1: values.address_1 || null,
+ address_2: values.address_2 || null,
city: values.city || null,
province: values.province || null,
- postal_code: values.postal_code,
+ postal_code: values.postal_code || null,
country_code: values.country_code,
- phone: values.phone,
},
{
onSuccess: () => {
@@ -80,34 +77,36 @@ export const StoreAddressForm = ({ seller }: StoreAddressFormProps) => {
className="flex flex-1 flex-col overflow-hidden"
>
<RouteDrawer.Body className="flex flex-col gap-y-4 overflow-y-auto">
- <div className="grid grid-cols-2 gap-4">
- <Form.Field
- control={form.control}
- name="first_name"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.firstName")}</Form.Label>
- <Form.Control>
- <Input size="small" {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="last_name"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.lastName")}</Form.Label>
- <Form.Control>
- <Input size="small" {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- </div>
+ <Form.Field
+ control={form.control}
+ name="name"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("store.address.nameLabel")}</Form.Label>
+ <Form.Control>
+ <Input
+ size="small"
+ placeholder={t("store.address.namePlaceholder")}
+ {...field}
+ />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="country_code"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.country")}</Form.Label>
+ <Form.Control>
+ <CountrySelect {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
<Form.Field
control={form.control}
name="address_1"
@@ -121,6 +120,19 @@ export const StoreAddressForm = ({ seller }: StoreAddressFormProps) => {
</Form.Item>
)}
/>
+ <Form.Field
+ control={form.control}
+ name="address_2"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label optional>{t("fields.address2")}</Form.Label>
+ <Form.Control>
+ <Input size="small" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
<div className="grid grid-cols-2 gap-4">
<Form.Field
control={form.control}
@@ -135,27 +147,12 @@ export const StoreAddressForm = ({ seller }: StoreAddressFormProps) => {
</Form.Item>
)}
/>
- <Form.Field
- control={form.control}
- name="province"
- render={({ field }) => (
- <Form.Item>
- <Form.Label optional>{t("fields.state")}</Form.Label>
- <Form.Control>
- <Input size="small" {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- </div>
- <div className="grid grid-cols-2 gap-4">
<Form.Field
control={form.control}
name="postal_code"
render={({ field }) => (
<Form.Item>
- <Form.Label>{t("fields.postalCode")}</Form.Label>
+ <Form.Label optional>{t("fields.postalCode")}</Form.Label>
<Form.Control>
<Input size="small" {...field} />
</Form.Control>
@@ -163,26 +160,13 @@ export const StoreAddressForm = ({ seller }: StoreAddressFormProps) => {
</Form.Item>
)}
/>
- <Form.Field
- control={form.control}
- name="country_code"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.country")}</Form.Label>
- <Form.Control>
- <CountrySelect {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
</div>
<Form.Field
control={form.control}
- name="phone"
+ name="province"
render={({ field }) => (
<Form.Item>
- <Form.Label>{t("fields.phone")}</Form.Label>
+ <Form.Label optional>{t("fields.state")}</Form.Label>
<Form.Control>
<Input size="small" {...field} />
</Form.Control>
diff --git a/packages/vendor/src/pages/settings/store/edit/_components/edit-store-form.tsx b/packages/vendor/src/pages/settings/store/edit/_components/edit-store-form.tsx
index 7d56fdc90..001da753d 100644
--- a/packages/vendor/src/pages/settings/store/edit/_components/edit-store-form.tsx
+++ b/packages/vendor/src/pages/settings/store/edit/_components/edit-store-form.tsx
@@ -7,6 +7,7 @@ import { useCallback } from "react";
import { FileType, FileUpload } from "@components/common/file-upload";
import { Form } from "@components/common/form";
+import { HandleInput } from "@components/inputs/handle-input";
import { RouteDrawer, useRouteModal } from "@components/modals";
import { KeyboundForm } from "@components/utilities/keybound-form";
import { uploadFilesQuery } from "@lib/client";
@@ -18,10 +19,11 @@ type EditStoreFormProps = HttpTypes.StoreSellerResponse;
const EditStoreSchema = zod.object({
name: zod.string().min(1),
- handle: zod.string().min(1),
+ handle: zod.string().optional().or(zod.literal("")),
email: zod.string().email().optional().or(zod.literal("")),
+ phone: zod.string().optional().or(zod.literal("")),
description: zod.string().optional().or(zod.literal("")),
- website_url: zod.string().url().optional().or(zod.literal("")),
+ website_url: zod.string().optional().or(zod.literal("")),
media: zod.array(MediaSchema).optional(),
bannerMedia: zod.array(MediaSchema).optional(),
});
@@ -53,6 +55,7 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
name: seller.name ?? "",
handle: seller.handle ?? "",
email: seller.email ?? "",
+ phone: seller.phone ?? "",
description: seller.description ?? "",
website_url: seller.website_url ?? "",
media: seller.logo
@@ -110,8 +113,9 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
await mutateAsync(
{
name: values.name,
- handle: values.handle,
+ handle: values.handle || undefined,
email: values.email || undefined,
+ phone: values.phone || null,
description: values.description || null,
website_url: values.website_url || null,
logo: logoUrl,
@@ -196,9 +200,11 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
name="handle"
render={({ field }) => (
<Form.Item>
- <Form.Label>{t("fields.handle")}</Form.Label>
+ <Form.Label optional tooltip={t("store.handleTooltip")}>
+ {t("fields.handle")}
+ </Form.Label>
<Form.Control>
- <Input {...field} />
+ <HandleInput {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
@@ -217,6 +223,19 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
</Form.Item>
)}
/>
+ <Form.Field
+ control={form.control}
+ name="phone"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label optional>{t("fields.phone")}</Form.Label>
+ <Form.Control>
+ <Input type="tel" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
<Form.Field
control={form.control}
name="description"
@@ -237,7 +256,7 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
<Form.Item>
<Form.Label optional>{t("fields.website")}</Form.Label>
<Form.Control>
- <Input placeholder="https://example.com" {...field} />
+ <HandleInput {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
diff --git a/packages/vendor/src/pages/settings/store/store-detail-page.tsx b/packages/vendor/src/pages/settings/store/store-detail-page.tsx
index bd8d0623e..172e704f8 100644
--- a/packages/vendor/src/pages/settings/store/store-detail-page.tsx
+++ b/packages/vendor/src/pages/settings/store/store-detail-page.tsx
@@ -1,6 +1,5 @@
import React, { Children, ReactNode } from "react";
-import { InformationCircleSolid } from "@medusajs/icons";
-import { Alert, Button, Container, Heading, Text } from "@medusajs/ui";
+import { Alert, Text } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
import components from "virtual:mercur/components";
@@ -41,8 +40,6 @@ const Root = ({ children }: { children?: ReactNode }) => {
throw error;
}
- const isPendingApproval = seller.status === SellerStatus.PENDING_APPROVAL;
-
const statusAlert = (() => {
switch (seller.status) {
case SellerStatus.SUSPENDED:
@@ -70,24 +67,6 @@ const Root = ({ children }: { children?: ReactNode }) => {
const StatusBanner = () => (
<>
- {isPendingApproval && (
- <Container className="p-0">
- <div className="flex items-center gap-x-3 px-6 py-4 border-b border-ui-border-base">
- <InformationCircleSolid className="text-ui-fg-interactive" />
- <Heading level="h2">{t("store.alert.pendingApproval.title")}</Heading>
- </div>
- <div className="px-6 py-4">
- <Text size="small" className="text-ui-fg-subtle">
- {t("store.alert.pendingApproval.description")}
- </Text>
- </div>
- <div className="flex justify-end px-6 py-4 border-t border-ui-border-base bg-ui-bg-subtle rounded-b-lg">
- <Button variant="secondary" size="small">
- {t("actions.cancel")}
- </Button>
- </div>
- </Container>
- )}
{StoreSetup && <StoreSetup seller={seller} />}
{statusAlert && (
<Alert variant={statusAlert.variant} dismissible className="p-5">
diff --git a/packages/vendor/src/pages/store-select/store-select.tsx b/packages/vendor/src/pages/store-select/store-select.tsx
index 704f1eb12..87b55cc48 100644
--- a/packages/vendor/src/pages/store-select/store-select.tsx
+++ b/packages/vendor/src/pages/store-select/store-select.tsx
@@ -1,16 +1,18 @@
+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 AvatarBox from "@components/common/logo-box/avatar-box";
+import { AuthLayout } from "@components/layout/auth-layout";
import { useSelectSeller, useSellers } from "@hooks/api";
import { SellerMemberDTO, SellerStatus } from "@mercurjs/types";
const getSellerStatusBadge = (
status: string,
t: (key: string) => string,
-): { color: "green" | "orange" | "red" | "grey"; label: string } => {
+): { color: "green" | "orange" | "red" | "grey"; label: string } | null => {
switch (status) {
case SellerStatus.OPEN:
return { color: "green", label: t("storeSelect.status.open") };
@@ -22,7 +24,7 @@ const getSellerStatusBadge = (
case SellerStatus.SUSPENDED:
return { color: "red", label: t("storeSelect.status.suspended") };
case SellerStatus.TERMINATED:
- return { color: "grey", label: t("storeSelect.status.terminated") };
+ return null;
default:
return { color: "grey", label: status };
}
@@ -36,9 +38,9 @@ const StoreSelectHeader = () => {
const { t } = useTranslation();
return (
- <div className="mb-4 flex flex-col items-center">
+ <div className="mb-6 flex flex-col">
<Heading>{t("storeSelect.title")}</Heading>
- <Text size="small" className="text-ui-fg-subtle text-center">
+ <Text size="small" className="text-ui-fg-subtle">
{t("storeSelect.subtitle")}
</Text>
</div>
@@ -63,38 +65,45 @@ const StoreSelectList = ({
return (
<div className="shadow-elevation-card-rest bg-ui-bg-base flex w-full flex-col divide-y rounded-lg">
- {seller_members?.map((member) => {
- const seller = member.seller;
- const badge = getSellerStatusBadge(seller.status, t);
+ {seller_members
+ ?.filter((member) => member.seller.status !== SellerStatus.TERMINATED)
+ .map((member) => {
+ const seller = member.seller;
+ const badge = getSellerStatusBadge(seller.status, t);
- return (
- <button
- key={seller.id}
- onClick={() => handleSelect(seller.id)}
- className="transition-fg flex items-center gap-x-3 px-4 py-3 first:rounded-t-lg enabled:hover:bg-ui-bg-base-hover disabled:cursor-not-allowed disabled:opacity-60"
- >
- <Avatar
- variant="squared"
- size="small"
- fallback={seller.name.charAt(0).toUpperCase()}
- />
- <div className="flex flex-1 flex-col items-start">
- <Text size="small" weight="plus" leading="compact">
- {seller.name}
- </Text>
- <Text
- size="xsmall"
- className="text-ui-fg-subtle"
- leading="compact"
- >
- {seller.handle}
- </Text>
- </div>
- <StatusBadge color={badge.color}>{badge.label}</StatusBadge>
- <ChevronRight className="text-ui-fg-muted" />
- </button>
- );
- })}
+ return (
+ <button
+ key={seller.id}
+ onClick={() => handleSelect(seller.id)}
+ className="transition-fg flex items-center gap-x-3 px-4 py-3 first:rounded-t-lg enabled:hover:bg-ui-bg-base-hover disabled:cursor-not-allowed disabled:opacity-60"
+ >
+ <Avatar
+ variant="squared"
+ size="small"
+ src={seller.logo || undefined}
+ fallback={seller.name.charAt(0).toUpperCase()}
+ />
+ <div className="flex flex-1 flex-col items-start">
+ <Text size="small" weight="plus" leading="compact">
+ {seller.name}
+ </Text>
+ {seller.handle ? (
+ <Text
+ size="xsmall"
+ className="text-ui-fg-subtle"
+ leading="compact"
+ >
+ /{seller.handle}
+ </Text>
+ ) : null}
+ </div>
+ {badge ? (
+ <StatusBadge color={badge.color}>{badge.label}</StatusBadge>
+ ) : null}
+ <ChevronRight className="text-ui-fg-muted" />
+ </button>
+ );
+ })}
<button
onClick={() => navigate("/onboarding", { state: { email } })}
className="hover:bg-ui-bg-base-hover transition-fg flex items-center justify-center gap-x-2 rounded-b-lg px-4 py-3"
@@ -112,31 +121,39 @@ const StoreSelectFooter = () => {
return null;
};
-const Root = () => {
+const Root = ({ children }: { children?: ReactNode }) => {
const location = useLocation();
const email = (location.state as { email?: string })?.email ?? "";
const { seller_members, isLoading } = useSellers();
if (isLoading) {
return (
- <div className="bg-ui-bg-subtle flex min-h-dvh w-dvw items-center justify-center">
- <Spinner className="text-ui-fg-muted animate-spin" />
- </div>
+ <AuthLayout>
+ <div className="flex flex-1 items-center justify-center">
+ <Spinner className="text-ui-fg-muted animate-spin" />
+ </div>
+ </AuthLayout>
);
}
return (
- <div className="bg-ui-bg-subtle flex min-h-dvh w-dvw items-center justify-center">
- <div className="flex w-[380px] flex-col items-center">
- <StoreSelectLogo />
- <StoreSelectHeader />
- <StoreSelectList
- seller_members={seller_members ?? []}
- email={email}
- />
- <StoreSelectFooter />
- </div>
- </div>
+ <AuthLayout>
+ {Children.count(children) > 0 ? (
+ children
+ ) : (
+ <>
+ <StoreSelectLogo />
+ <div className="mt-8">
+ <StoreSelectHeader />
+ <StoreSelectList
+ seller_members={seller_members ?? []}
+ email={email}
+ />
+ </div>
+ <StoreSelectFooter />
+ </>
+ )}
+ </AuthLayout>
);
};