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.

feat(admin): add seller list filters and seller detail improvements

vholik49a5812621ab
diff --git a/packages/admin/src/hooks/api/orders.tsx b/packages/admin/src/hooks/api/orders.tsx
index 194d0cdcd..84d4988ac 100644
--- a/packages/admin/src/hooks/api/orders.tsx
+++ b/packages/admin/src/hooks/api/orders.tsx
@@ -1,60 +1,60 @@
-import { ClientError } from "@mercurjs/client"
-import { CreateOrderCreditLineDTO, HttpTypes } from "@medusajs/types"
+import { ClientError, InferClientInput } from "@mercurjs/client";
+import { CreateOrderCreditLineDTO, HttpTypes } from "@medusajs/types";
import {
QueryKey,
useMutation,
UseMutationOptions,
useQuery,
UseQueryOptions,
-} from "@tanstack/react-query"
-import { sdk } from "../../lib/client"
-import { queryClient } from "../../lib/query-client"
-import { queryKeysFactory, TQueryKey } from "../../lib/query-key-factory"
-import { inventoryItemsQueryKeys } from "./inventory"
-import { reservationItemsQueryKeys } from "./reservations"
-
-const ORDERS_QUERY_KEY = "orders" as const
+} from "@tanstack/react-query";
+import { sdk } from "../../lib/client";
+import { queryClient } from "../../lib/query-client";
+import { queryKeysFactory, TQueryKey } from "../../lib/query-key-factory";
+import { inventoryItemsQueryKeys } from "./inventory";
+import { reservationItemsQueryKeys } from "./reservations";
+
+const ORDERS_QUERY_KEY = "orders" as const;
const _orderKeys = queryKeysFactory(ORDERS_QUERY_KEY) as TQueryKey<"orders"> & {
- preview: (orderId: string) => any
- changes: (orderId: string) => any
- lineItems: (orderId: string) => any
- shippingOptions: (orderId: string) => any
-}
+ preview: (orderId: string) => any;
+ changes: (orderId: string) => any;
+ lineItems: (orderId: string) => any;
+ shippingOptions: (orderId: string) => any;
+};
_orderKeys.preview = function (id: string) {
- return [this.detail(id), "preview"]
-}
+ return [this.detail(id), "preview"];
+};
_orderKeys.changes = function (id: string) {
- return [this.detail(id), "changes"]
-}
+ return [this.detail(id), "changes"];
+};
_orderKeys.lineItems = function (id: string) {
- return [this.detail(id), "lineItems"]
-}
+ return [this.detail(id), "lineItems"];
+};
_orderKeys.shippingOptions = function (id: string) {
- return [this.detail(id), "shippingOptions"]
-}
+ return [this.detail(id), "shippingOptions"];
+};
-export const ordersQueryKeys = _orderKeys
+export const ordersQueryKeys = _orderKeys;
export const useOrder = (
id: string,
- query?: Record<string, any>,
+ query?: InferClientInput<typeof sdk.admin.orders.$id.query>,
options?: Omit<
UseQueryOptions<any, ClientError, any, QueryKey>,
"queryFn" | "queryKey"
- >
+ >,
) => {
const { data, ...rest } = useQuery({
queryFn: async () => sdk.admin.orders.$id.query({ $id: id, ...query }),
queryKey: ordersQueryKeys.detail(id, query),
...options,
- })
+ });
- return { ...data, ...rest }
-}
+ return { ...data, ...rest };
+};
export const useUpdateOrder = (
id: string,
@@ -62,7 +62,7 @@ export const useUpdateOrder = (
HttpTypes.AdminOrderResponse,
ClientError,
HttpTypes.AdminUpdateOrder
- >
+ >,
) => {
return useMutation({
mutationFn: (payload: HttpTypes.AdminUpdateOrder) =>
@@ -70,22 +70,22 @@ export const useUpdateOrder = (
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.detail(id),
- })
+ });
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.changes(id),
- })
+ });
// TODO: enable when needed
// queryClient.invalidateQueries({
// queryKey: ordersQueryKeys.lists(),
// })
- options?.onSuccess?.(data, variables, context)
+ options?.onSuccess?.(data, variables, context);
},
...options,
- })
-}
+ });
+};
export const useOrderPreview = (
id: string,
@@ -98,20 +98,20 @@ export const useOrderPreview = (
QueryKey
>,
"queryFn" | "queryKey"
- >
+ >,
) => {
const { data, ...rest } = useQuery({
queryFn: async () =>
sdk.admin.orders.$id.preview.query({ $id: id, ...query }),
queryKey: ordersQueryKeys.preview(id),
...options,
- })
+ });
- return { ...data, ...rest }
-}
+ return { ...data, ...rest };
+};
export const useOrders = (
- query?: HttpTypes.AdminOrderFilters,
+ query?: InferClientInput<typeof sdk.admin.orders.query>,
options?: Omit<
UseQueryOptions<
HttpTypes.AdminOrderListResponse,
@@ -120,16 +120,16 @@ export const useOrders = (
QueryKey
>,
"queryFn" | "queryKey"
- >
+ >,
) => {
const { data, ...rest } = useQuery({
queryFn: async () => sdk.admin.orders.query({ ...query }),
queryKey: ordersQueryKeys.list(query),
...options,
- })
+ });
- return { ...data, ...rest }
-}
+ return { ...data, ...rest };
+};
export const useOrderShippingOptions = (
id: string,
@@ -142,17 +142,17 @@ export const useOrderShippingOptions = (
QueryKey
>,
"queryFn" | "queryKey"
- >
+ >,
) => {
const { data, ...rest } = useQuery({
queryFn: async () =>
sdk.admin.orders.$id.shippingOptions.query({ $id: id, ...query }),
queryKey: ordersQueryKeys.shippingOptions(id),
...options,
- })
+ });
- return { ...data, ...rest }
-}
+ return { ...data, ...rest };
+};
export const useOrderChanges = (
id: string,
@@ -165,17 +165,17 @@ export const useOrderChanges = (
QueryKey
>,
"queryFn" | "queryKey"
- >
+ >,
) => {
const { data, ...rest } = useQuery({
queryFn: async () =>
sdk.admin.orders.$id.changes.query({ $id: id, ...query }),
queryKey: ordersQueryKeys.changes(id),
...options,
- })
+ });
- return { ...data, ...rest }
-}
+ return { ...data, ...rest };
+};
export const useOrderLineItems = (
id: string,
@@ -188,17 +188,17 @@ export const useOrderLineItems = (
QueryKey
>,
"queryFn" | "queryKey"
- >
+ >,
) => {
const { data, ...rest } = useQuery({
queryFn: async () =>
sdk.admin.orders.$id.lineItems.query({ $id: id, ...query }),
queryKey: ordersQueryKeys.lineItems(id),
...options,
- })
+ });
- return { ...data, ...rest }
-}
+ return { ...data, ...rest };
+};
export const useCreateOrderFulfillment = (
orderId: string,
@@ -206,7 +206,7 @@ export const useCreateOrderFulfillment = (
HttpTypes.AdminOrderResponse,
ClientError,
HttpTypes.AdminCreateOrderFulfillment
- >
+ >,
) => {
return useMutation({
mutationFn: (payload: HttpTypes.AdminCreateOrderFulfillment) =>
@@ -214,30 +214,30 @@ export const useCreateOrderFulfillment = (
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.all,
- })
+ });
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.preview(orderId),
- })
+ });
queryClient.invalidateQueries({
queryKey: reservationItemsQueryKeys.lists(),
- })
+ });
queryClient.invalidateQueries({
queryKey: inventoryItemsQueryKeys.details(),
- })
+ });
- options?.onSuccess?.(data, variables, context)
+ options?.onSuccess?.(data, variables, context);
},
...options,
- })
-}
+ });
+};
export const useCancelOrderFulfillment = (
orderId: string,
fulfillmentId: string,
- options?: UseMutationOptions<any, ClientError, any>
+ options?: UseMutationOptions<any, ClientError, any>,
) => {
return useMutation({
mutationFn: (payload: { no_notification?: boolean }) =>
@@ -249,25 +249,25 @@ export const useCancelOrderFulfillment = (
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.all,
- })
+ });
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.preview(orderId),
- })
+ });
queryClient.invalidateQueries({
queryKey: reservationItemsQueryKeys.lists(),
- })
+ });
queryClient.invalidateQueries({
queryKey: inventoryItemsQueryKeys.details(),
- })
+ });
- options?.onSuccess?.(data, variables, context)
+ options?.onSuccess?.(data, variables, context);
},
...options,
- })
-}
+ });
+};
export const useCreateOrderShipment = (
orderId: string,
@@ -276,7 +276,7 @@ export const useCreateOrderShipment = (
{ order: HttpTypes.AdminOrder },
ClientError,
HttpTypes.AdminCreateOrderShipment
- >
+ >,
) => {
return useMutation({
mutationFn: (payload: HttpTypes.AdminCreateOrderShipment) =>
@@ -288,17 +288,17 @@ export const useCreateOrderShipment = (
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.all,
- })
+ });
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.preview(orderId),
- })
+ });
- options?.onSuccess?.(data, variables, context)
+ options?.onSuccess?.(data, variables, context);
},
...options,
- })
-}
+ });
+};
export const useMarkOrderFulfillmentAsDelivered = (
orderId: string,
@@ -307,7 +307,7 @@ export const useMarkOrderFulfillmentAsDelivered = (
{ order: HttpTypes.AdminOrder },
ClientError,
void
- >
+ >,
) => {
return useMutation({
mutationFn: () =>
@@ -318,39 +318,38 @@ export const useMarkOrderFulfillmentAsDelivered = (
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.all,
- })
+ });
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.preview(orderId),
- })
+ });
- options?.onSuccess?.(data, variables, context)
+ options?.onSuccess?.(data, variables, context);
},
...options,
- })
-}
+ });
+};
export const useCancelOrder = (
orderId: string,
- options?: UseMutationOptions<HttpTypes.AdminOrderResponse, ClientError, void>
+ options?: UseMutationOptions<HttpTypes.AdminOrderResponse, ClientError, void>,
) => {
return useMutation({
- mutationFn: () =>
- sdk.admin.orders.$id.cancel.mutate({ $id: orderId }),
+ mutationFn: () => sdk.admin.orders.$id.cancel.mutate({ $id: orderId }),
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.detail(orderId),
- })
+ });
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.preview(orderId),
- })
+ });
- options?.onSuccess?.(data, variables, context)
+ options?.onSuccess?.(data, variables, context);
},
...options,
- })
-}
+ });
+};
export const useRequestTransferOrder = (
orderId: string,
@@ -358,7 +357,7 @@ export const useRequestTransferOrder = (
HttpTypes.AdminOrderResponse,
ClientError,
HttpTypes.AdminRequestOrderTransfer
- >
+ >,
) => {
return useMutation({
mutationFn: (payload: HttpTypes.AdminRequestOrderTransfer) =>
@@ -366,21 +365,21 @@ export const useRequestTransferOrder = (
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.preview(orderId),
- })
+ });
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.changes(orderId),
- })
+ });
- options?.onSuccess?.(data, variables, context)
+ options?.onSuccess?.(data, variables, context);
},
...options,
- })
-}
+ });
+};
export const useCancelOrderTransfer = (
orderId: string,
- options?: UseMutationOptions<any, ClientError, void>
+ options?: UseMutationOptions<any, ClientError, void>,
) => {
return useMutation({
mutationFn: () =>
@@ -388,17 +387,17 @@ export const useCancelOrderTransfer = (
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.preview(orderId),
- })
+ });
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.changes(orderId),
- })
+ });
- options?.onSuccess?.(data, variables, context)
+ options?.onSuccess?.(data, variables, context);
},
...options,
- })
-}
+ });
+};
export const useCreateOrderCreditLine = (
orderId: string,
@@ -406,7 +405,7 @@ export const useCreateOrderCreditLine = (
HttpTypes.AdminOrderResponse,
ClientError,
Omit<CreateOrderCreditLineDTO, "order_id">
- >
+ >,
) => {
return useMutation({
mutationFn: (payload) =>
@@ -414,14 +413,14 @@ export const useCreateOrderCreditLine = (
onSuccess: (data, variables, context) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.details(),
- })
+ });
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.preview(orderId),
- })
+ });
- options?.onSuccess?.(data, variables, context)
+ options?.onSuccess?.(data, variables, context);
},
...options,
- })
-}
+ });
+};
diff --git a/packages/admin/src/hooks/table/filters/index.ts b/packages/admin/src/hooks/table/filters/index.ts
index d98d69493..c07f37a5f 100644
--- a/packages/admin/src/hooks/table/filters/index.ts
+++ b/packages/admin/src/hooks/table/filters/index.ts
@@ -7,6 +7,7 @@ export * from "./use-product-table-filters"
export * from "./use-product-tag-table-filters"
export * from "./use-product-type-table-filters"
export * from "./use-promotion-table-filters"
+export * from "./use-seller-table-filters"
export * from "./use-region-table-filters"
export * from "./use-shipping-option-table-filters"
export * from "./use-tax-rate-table-filters"
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
new file mode 100644
index 000000000..3b35decee
--- /dev/null
+++ b/packages/admin/src/hooks/table/filters/use-seller-table-filters.tsx
@@ -0,0 +1,38 @@
+import { useTranslation } from "react-i18next"
+import { Filter } from "../../../components/table/data-table"
+
+export const useSellerTableFilters = (): Filter[] => {
+ const { t } = useTranslation()
+
+ const statusFilter: Filter = {
+ key: "status",
+ label: t("fields.status"),
+ type: "select",
+ multiple: true,
+ options: [
+ {
+ label: t("sellers.status.pending"),
+ value: "pending",
+ },
+ {
+ label: t("sellers.status.active"),
+ value: "active",
+ },
+ {
+ label: t("sellers.status.suspended"),
+ value: "suspended",
+ },
+ ],
+ }
+
+ const dateFilters: Filter[] = [
+ { label: t("fields.createdAt"), key: "created_at" },
+ { label: t("fields.updatedAt"), key: "updated_at" },
+ ].map((f) => ({
+ key: f.key,
+ label: f.label,
+ type: "date",
+ }))
+
+ return [statusFilter, ...dateFilters]
+}
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 23f9bd79f..23f85dcc7 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,32 +1,32 @@
-import { useQueryParams } from "@hooks/use-query-params"
+import { useQueryParams } from "@hooks/use-query-params";
type UseSellersTableQueryProps = {
- prefix?: string
- pageSize?: number
-}
+ prefix?: string;
+ pageSize?: number;
+};
export const useSellersTableQuery = ({
prefix,
pageSize = 20,
}: UseSellersTableQueryProps) => {
const queryObject = useQueryParams(
- ["offset", "q", "created_at", "store_status", "order"],
- prefix
- )
+ ["offset", "q", "created_at", "status", "order"],
+ prefix,
+ );
- const { offset, created_at, store_status, q, order } = queryObject
+ const { offset, created_at, status, q, order } = queryObject;
const searchParams: Record<string, string | number | string[] | undefined> = {
limit: pageSize,
offset: offset ? Number(offset) : 0,
created_at: created_at ? JSON.parse(created_at) : undefined,
- store_status: store_status?.split(","),
+ status: status?.split(","),
q,
order: order ? order : undefined,
- }
+ };
return {
searchParams,
raw: queryObject,
- }
-}
+ };
+};
diff --git a/packages/admin/src/pages/sellers/seller-details/components/seller-details.tsx b/packages/admin/src/pages/sellers/seller-details/components/seller-details.tsx
index 355b579da..74ec7ed79 100644
--- a/packages/admin/src/pages/sellers/seller-details/components/seller-details.tsx
+++ b/packages/admin/src/pages/sellers/seller-details/components/seller-details.tsx
@@ -28,8 +28,8 @@ export const SellerDetails = () => {
showMetadata
>
<SellerGeneralSection seller={seller} />
- <SellerOrderSection />
- <SellerProductSection />
+ <SellerOrderSection sellerId={seller.id} />
+ <SellerProductSection sellerId={seller.id} />
</SingleColumnPage>
)
}
diff --git a/packages/admin/src/pages/sellers/seller-details/components/seller-general-section.tsx b/packages/admin/src/pages/sellers/seller-details/components/seller-general-section.tsx
index d360b80f3..626910cb0 100644
--- a/packages/admin/src/pages/sellers/seller-details/components/seller-general-section.tsx
+++ b/packages/admin/src/pages/sellers/seller-details/components/seller-general-section.tsx
@@ -1,4 +1,4 @@
-import { PencilSquare, User } from "@medusajs/icons"
+import { CheckCircleSolid, PencilSquare, User, XCircleSolid } from "@medusajs/icons"
import {
Container,
Heading,
@@ -45,16 +45,30 @@ export const SellerGeneralSection = ({
}
const statusText = statusTextMap[seller.status] ?? t("sellers.status.pending")
- const handleSuspend = async () => {
- const isSuspended = seller.status === SellerStatus.SUSPENDED
+ const handleStatusChange = async (newStatus: SellerStatus) => {
+ const labels: Record<SellerStatus, { title: string; description: string; success: string }> = {
+ [SellerStatus.ACTIVE]: {
+ title: "Activate account",
+ description: "Are you sure you want to activate this seller account?",
+ success: "Seller account activated",
+ },
+ [SellerStatus.SUSPENDED]: {
+ title: "Suspend account",
+ description: "Are you sure you want to suspend this seller account?",
+ success: "Seller account suspended",
+ },
+ [SellerStatus.PENDING]: {
+ title: "Set as pending",
+ description: "Are you sure you want to set this seller account as pending?",
+ success: "Seller account set to pending",
+ },
+ }
+
+ const label = labels[newStatus]
const res = await prompt({
- title: isSuspended
- ? t("sellers.status.active")
- : t("sellers.status.suspended"),
- description: isSuspended
- ? "Are you sure you want to activate this account?"
- : "Are you sure you want to suspend this account?",
+ title: label.title,
+ description: label.description,
verificationText: seller.email || seller.name || "",
confirmText: t("actions.confirm"),
cancelText: t("actions.cancel"),
@@ -65,16 +79,10 @@ export const SellerGeneralSection = ({
}
await updateSeller(
- {
- status: isSuspended ? SellerStatus.ACTIVE : SellerStatus.SUSPENDED,
- },
+ { status: newStatus },
{
onSuccess: () => {
- toast.success(
- isSuspended
- ? "Seller account activated"
- : "Seller account suspended"
- )
+ toast.success(label.success)
},
onError: (error) => {
toast.error(error.message)
@@ -83,6 +91,28 @@ export const SellerGeneralSection = ({
)
}
+ const statusActions = (() => {
+ const actions = []
+
+ if (seller.status !== SellerStatus.ACTIVE) {
+ actions.push({
+ label: "Activate account",
+ onClick: () => handleStatusChange(SellerStatus.ACTIVE),
+ icon: <CheckCircleSolid />,
+ })
+ }
+
+ if (seller.status !== SellerStatus.SUSPENDED) {
+ actions.push({
+ label: "Suspend account",
+ onClick: () => handleStatusChange(SellerStatus.SUSPENDED),
+ icon: <XCircleSolid />,
+ })
+ }
+
+ return actions
+ })()
+
return (
<Container className="divide-y p-0">
<div className="flex items-center justify-between px-6 py-4">
@@ -114,16 +144,7 @@ export const SellerGeneralSection = ({
],
},
{
- actions: [
- {
- label:
- seller.status === SellerStatus.SUSPENDED
- ? "Activate account"
- : "Suspend account",
- onClick: handleSuspend,
- icon: <User />,
- },
- ],
+ actions: statusActions,
},
]}
/>
diff --git a/packages/admin/src/pages/sellers/seller-details/components/seller-order-section.tsx b/packages/admin/src/pages/sellers/seller-details/components/seller-order-section.tsx
index 0c3c09fc8..c9d150298 100644
--- a/packages/admin/src/pages/sellers/seller-details/components/seller-order-section.tsx
+++ b/packages/admin/src/pages/sellers/seller-details/components/seller-order-section.tsx
@@ -1,24 +1,24 @@
-import { useMemo } from "react"
+import { useMemo } from "react";
-import type { AdminOrder } from "@medusajs/types"
-import { Badge, Container, Heading } from "@medusajs/ui"
-import { keepPreviousData } from "@tanstack/react-query"
-import { createColumnHelper } from "@tanstack/react-table"
-import { useTranslation } from "react-i18next"
+import type { AdminOrder } from "@medusajs/types";
+import { Badge, Container, Heading } from "@medusajs/ui";
+import { keepPreviousData } from "@tanstack/react-query";
+import { createColumnHelper } from "@tanstack/react-table";
+import { useTranslation } from "react-i18next";
-import { DateCell } from "@components/table/table-cells/common/date-cell"
-import { _DataTable } from "@components/table/data-table"
+import { DateCell } from "@components/table/table-cells/common/date-cell";
+import { _DataTable } from "@components/table/data-table";
-import { useOrders } from "../../../../hooks/api/orders"
-import { useOrderTableFilters } from "@hooks/table/filters"
-import { useOrderTableQuery } from "@hooks/table/query"
-import { useDataTable } from "@hooks/use-data-table"
-import { getStylizedAmount } from "@lib/money-amount-helpers"
+import { useOrders } from "../../../../hooks/api/orders";
+import { useOrderTableFilters } from "@hooks/table/filters";
+import { useOrderTableQuery } from "@hooks/table/query";
+import { useDataTable } from "@hooks/use-data-table";
+import { getStylizedAmount } from "@lib/money-amount-helpers";
-const PAGE_SIZE = 10
-const PREFIX = "selord"
+const PAGE_SIZE = 10;
+const PREFIX = "selord";
const DEFAULT_FIELDS =
- "id,status,display_id,created_at,email,fulfillment_status,payment_status,total,currency_code,*customer"
+ "id,status,display_id,created_at,email,fulfillment_status,payment_status,total,currency_code,*customer";
const getOrderStatusBadgeColor = (status: string) => {
const colors: Record<string, "orange" | "green" | "red" | "grey"> = {
@@ -28,28 +28,27 @@ const getOrderStatusBadgeColor = (status: string) => {
archived: "grey",
requires_action: "orange",
draft: "grey",
- }
- return colors[status] || "grey"
-}
+ };
+ return colors[status] || "grey";
+};
const getPaymentStatusBadgeColor = (status: string) => {
- const colors: Record<string, "orange" | "green" | "red" | "blue" | "grey"> =
- {
- captured: "green",
- paid: "green",
- partially_captured: "orange",
- awaiting: "orange",
- authorized: "blue",
- partially_authorized: "blue",
- pending: "orange",
- refunded: "red",
- partially_refunded: "orange",
- canceled: "red",
- not_paid: "grey",
- requires_action: "orange",
- }
- return colors[status] || "grey"
-}
+ const colors: Record<string, "orange" | "green" | "red" | "blue" | "grey"> = {
+ captured: "green",
+ paid: "green",
+ partially_captured: "orange",
+ awaiting: "orange",
+ authorized: "blue",
+ partially_authorized: "blue",
+ pending: "orange",
+ refunded: "red",
+ partially_refunded: "orange",
+ canceled: "red",
+ not_paid: "grey",
+ requires_action: "orange",
+ };
+ return colors[status] || "grey";
+};
const getFulfillmentStatusBadgeColor = (status: string) => {
const colors: Record<string, "orange" | "green" | "red" | "grey"> = {
@@ -64,35 +63,34 @@ const getFulfillmentStatusBadgeColor = (status: string) => {
returned: "red",
partially_returned: "orange",
requires_action: "orange",
- }
- return colors[status] || "grey"
-}
+ };
+ return colors[status] || "grey";
+};
const formatStatus = (status: string) =>
- status
- .replace(/_/g, " ")
- .replace(/\b\w/g, (c) => c.toUpperCase())
+ status.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
-export const SellerOrderSection = () => {
- const { t } = useTranslation()
+export const SellerOrderSection = ({ sellerId }: { sellerId: string }) => {
+ const { t } = useTranslation();
const { searchParams, raw } = useOrderTableQuery({
pageSize: PAGE_SIZE,
prefix: PREFIX,
- })
+ });
const { orders, count, isLoading, isError, error } = useOrders(
{
fields: DEFAULT_FIELDS,
+ seller_id: sellerId,
...searchParams,
},
{
placeholderData: keepPreviousData,
- }
- )
+ },
+ );
- const columns = useColumns()
- const filters = useOrderTableFilters()
+ const columns = useColumns();
+ const filters = useOrderTableFilters();
const { table } = useDataTable({
data: orders ?? [],
@@ -101,10 +99,10 @@ export const SellerOrderSection = () => {
count,
pageSize: PAGE_SIZE,
prefix: PREFIX,
- })
+ });
if (isError) {
- throw error
+ throw error;
}
return (
@@ -131,10 +129,10 @@ export const SellerOrderSection = () => {
prefix={PREFIX}
/>
</Container>
- )
-}
+ );
+};
-const columnHelper = createColumnHelper<AdminOrder>()
+const columnHelper = createColumnHelper<AdminOrder>();
const useColumns = () => {
return useMemo(
@@ -156,7 +154,7 @@ const useColumns = () => {
return row.original.customer?.first_name &&
row.original.customer?.last_name
? `${row.original.customer?.first_name} ${row.original.customer?.last_name}`
- : row.original.customer?.email
+ : row.original.customer?.email;
},
}),
columnHelper.display({
@@ -175,24 +173,21 @@ const useColumns = () => {
id: "payment_status",
header: "Payment Status",
cell: ({ row }) => {
- const status = row.original?.payment_status
- if (!status) return "-"
+ const status = row.original?.payment_status;
+ if (!status) return "-";
return (
- <Badge
- size="2xsmall"
- color={getPaymentStatusBadgeColor(status)}
- >
+ <Badge size="2xsmall" color={getPaymentStatusBadgeColor(status)}>
{formatStatus(status)}
</Badge>
- )
+ );
},
}),
columnHelper.display({
id: "fulfillment_status",
header: "Fulfillment Status",
cell: ({ row }) => {
- const status = row.original.fulfillment_status
- if (!status) return "-"
+ const status = row.original.fulfillment_status;
+ if (!status) return "-";
return (
<Badge
size="2xsmall"
@@ -200,7 +195,7 @@ const useColumns = () => {
>
{formatStatus(status)}
</Badge>
- )
+ );
},
}),
columnHelper.display({
@@ -211,22 +206,22 @@ const useColumns = () => {
typeof row.original.total === "undefined" ||
row.original.total === null
) {
- return "-"
+ return "-";
}
const formatted = getStylizedAmount(
row.original.total,
- row.original.currency_code
- )
+ row.original.currency_code,
+ );
return (
<div className="flex h-full w-full items-center justify-start overflow-hidden text-left">
<span className="truncate">{formatted}</span>
</div>
- )
+ );
},
}),
],
- []
- )
-}
+ [],
+ );
+};
diff --git a/packages/admin/src/pages/sellers/seller-details/components/seller-product-section.tsx b/packages/admin/src/pages/sellers/seller-details/components/seller-product-section.tsx
index 9c5697214..ef7d9c010 100644
--- a/packages/admin/src/pages/sellers/seller-details/components/seller-product-section.tsx
+++ b/packages/admin/src/pages/sellers/seller-details/components/seller-product-section.tsx
@@ -22,7 +22,7 @@ const PREFIX = "selprod"
const DEFAULT_FIELDS =
"*collection,+type_id,+tag_id,+sales_channel_id,+status,+created_at,+updated_at"
-export const SellerProductSection = () => {
+export const SellerProductSection = ({ sellerId }: { sellerId: string }) => {
const { t } = useTranslation()
const { searchParams, raw } = useProductTableQuery({
@@ -33,6 +33,7 @@ export const SellerProductSection = () => {
const { products, count, isLoading, isError, error } = useProducts(
{
fields: DEFAULT_FIELDS,
+ seller_id: sellerId,
...searchParams,
},
{
diff --git a/packages/admin/src/pages/sellers/seller-list/seller-list.tsx b/packages/admin/src/pages/sellers/seller-list/seller-list.tsx
index 32f608210..c854f09c7 100644
--- a/packages/admin/src/pages/sellers/seller-list/seller-list.tsx
+++ b/packages/admin/src/pages/sellers/seller-list/seller-list.tsx
@@ -11,6 +11,7 @@ import { _DataTable } from "../../../components/table/data-table";
import { useSellers } from "../../../hooks/api/sellers";
import { useSellersTableColumns } from "../../../hooks/table/columns/use-seller-table-columns";
+import { useSellerTableFilters } from "../../../hooks/table/filters";
import { useSellersTableQuery } from "../../../hooks/table/query";
import { useDataTable } from "../../../hooks/use-data-table";
import { SellerDTO } from "@mercurjs/types";
@@ -32,6 +33,7 @@ export const SellersList = () => {
);
const columns = useColumns();
+ const filters = useSellerTableFilters();
const { table } = useDataTable({
data: sellers ?? [],
@@ -52,6 +54,7 @@ export const SellersList = () => {
columns={columns}
count={count ?? 0}
pageSize={PAGE_SIZE}
+ filters={filters}
isLoading={isLoading}
queryObject={raw}
search
diff --git a/packages/core-plugin/.mercur/_generated/index.ts b/packages/core-plugin/.mercur/_generated/index.ts
index 87eaace84..6be2c6524 100644
--- a/packages/core-plugin/.mercur/_generated/index.ts
+++ b/packages/core-plugin/.mercur/_generated/index.ts
@@ -168,7 +168,7 @@ export type Routes = {
};
};
};
- orders: typeof import("@medusajs/medusa/api/admin/orders/route") & {
+ orders: typeof import("../../src/api/admin/orders/route") & {
$id: typeof import("@medusajs/medusa/api/admin/orders/[id]/route") & {
archive: typeof import("@medusajs/medusa/api/admin/orders/[id]/archive/route");
cancel: typeof import("@medusajs/medusa/api/admin/orders/[id]/cancel/route");
@@ -227,7 +227,7 @@ export type Routes = {
$id: typeof import("@medusajs/medusa/api/admin/product-types/[id]/route");
};
productVariants: typeof import("@medusajs/medusa/api/admin/product-variants/route");
- products: typeof import("@medusajs/medusa/api/admin/products/route") & {
+ products: typeof import("../../src/api/admin/products/route") & {
$id: typeof import("@medusajs/medusa/api/admin/products/[id]/route") & {
images: {
$imageId: {