feat(dashboard, medusa, types): orders list on customer details page (#9790)
**What** - display orders list on customer details --- CLOSES CC-625
This commit is contained in:
@@ -35,6 +35,7 @@ type CustomerGroupSectionProps = {
|
||||
}
|
||||
|
||||
const PAGE_SIZE = 10
|
||||
const PREFIX = "cusgr"
|
||||
|
||||
export const CustomerGroupSection = ({
|
||||
customer,
|
||||
@@ -44,6 +45,7 @@ export const CustomerGroupSection = ({
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
|
||||
const { raw, searchParams } = useCustomerGroupTableQuery({
|
||||
pageSize: PAGE_SIZE,
|
||||
prefix: PREFIX,
|
||||
})
|
||||
|
||||
const { customer_groups, count, isLoading, isError, error } =
|
||||
@@ -72,6 +74,7 @@ export const CustomerGroupSection = ({
|
||||
enablePagination: true,
|
||||
enableRowSelection: true,
|
||||
pageSize: PAGE_SIZE,
|
||||
prefix: PREFIX,
|
||||
rowSelection: {
|
||||
state: rowSelection,
|
||||
updater: setRowSelection,
|
||||
@@ -132,6 +135,7 @@ export const CustomerGroupSection = ({
|
||||
pageSize={PAGE_SIZE}
|
||||
isLoading={isLoading}
|
||||
count={count}
|
||||
prefix={PREFIX}
|
||||
navigateTo={(row) => `/customer-groups/${row.id}`}
|
||||
filters={filters}
|
||||
search
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ArrowPath } from "@medusajs/icons"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { Button, Container, Heading } from "@medusajs/ui"
|
||||
import { Container, Heading } from "@medusajs/ui"
|
||||
import { keepPreviousData } from "@tanstack/react-query"
|
||||
import { createColumnHelper } from "@tanstack/react-table"
|
||||
import { useMemo } from "react"
|
||||
@@ -17,6 +17,7 @@ type CustomerGeneralSectionProps = {
|
||||
customer: HttpTypes.AdminCustomer
|
||||
}
|
||||
|
||||
const PREFIX = "cusord"
|
||||
const PAGE_SIZE = 10
|
||||
const DEFAULT_RELATIONS = "*customer,*items,*sales_channel"
|
||||
const DEFAULT_FIELDS =
|
||||
@@ -29,6 +30,7 @@ export const CustomerOrderSection = ({
|
||||
|
||||
const { searchParams, raw } = useOrderTableQuery({
|
||||
pageSize: PAGE_SIZE,
|
||||
prefix: PREFIX,
|
||||
})
|
||||
const { orders, count, isLoading, isError, error } = useOrders(
|
||||
{
|
||||
@@ -50,6 +52,7 @@ export const CustomerOrderSection = ({
|
||||
enablePagination: true,
|
||||
count,
|
||||
pageSize: PAGE_SIZE,
|
||||
prefix: PREFIX,
|
||||
})
|
||||
|
||||
if (isError) {
|
||||
@@ -60,11 +63,12 @@ export const CustomerOrderSection = ({
|
||||
<Container className="divide-y p-0">
|
||||
<div className="flex items-center justify-between px-6 py-4">
|
||||
<Heading level="h2">{t("orders.domain")}</Heading>
|
||||
<div className="flex items-center gap-x-2">
|
||||
<Button size="small" variant="secondary">
|
||||
{t("actions.create")}
|
||||
</Button>
|
||||
</div>
|
||||
{/*TODO: ENABLE WHEN DRAFT ORDERS ARE DONE*/}
|
||||
{/*<div className="flex items-center gap-x-2">*/}
|
||||
{/* <Button size="small" variant="secondary">*/}
|
||||
{/* {t("actions.create")}*/}
|
||||
{/* </Button>*/}
|
||||
{/*</div>*/}
|
||||
</div>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
@@ -82,6 +86,7 @@ export const CustomerOrderSection = ({
|
||||
]}
|
||||
search={true}
|
||||
queryObject={raw}
|
||||
prefix={PREFIX}
|
||||
/>
|
||||
</Container>
|
||||
)
|
||||
@@ -115,10 +120,11 @@ const useColumns = () => {
|
||||
return useMemo(
|
||||
() => [
|
||||
...base,
|
||||
columnHelper.display({
|
||||
id: "actions",
|
||||
cell: ({ row }) => <CustomerOrderActions order={row.original} />,
|
||||
}),
|
||||
// TODO: REENABLE WHEN TRANSFER OWNERSHIP IS IMPLEMENTED
|
||||
// columnHelper.display({
|
||||
// id: "actions",
|
||||
// cell: ({ row }) => <CustomerOrderActions order={row.original} />,
|
||||
// }),
|
||||
],
|
||||
[base]
|
||||
)
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useCustomer } from "../../../hooks/api/customers"
|
||||
import { CustomerGeneralSection } from "./components/customer-general-section"
|
||||
import { CustomerGroupSection } from "./components/customer-group-section"
|
||||
import { customerLoader } from "./loader"
|
||||
import { CustomerOrderSection } from "./components/customer-order-section"
|
||||
|
||||
export const CustomerDetail = () => {
|
||||
const { id } = useParams()
|
||||
@@ -40,9 +41,7 @@ export const CustomerDetail = () => {
|
||||
showMetadata
|
||||
>
|
||||
<CustomerGeneralSection customer={customer} />
|
||||
{/* <CustomerOrderSection customer={customer} />
|
||||
// TODO: re-add when order endpoints are added to api-v2
|
||||
*/}
|
||||
<CustomerOrderSection customer={customer} />
|
||||
<CustomerGroupSection customer={customer} />
|
||||
</SingleColumnPage>
|
||||
)
|
||||
|
||||
@@ -8,7 +8,8 @@ export interface AdminOrderFilters extends FindParams, BaseOrderFilters {
|
||||
sales_channel_id?: string[]
|
||||
fulfillment_status?: FulfillmentStatus[]
|
||||
payment_status?: PaymentStatus[]
|
||||
region_id?: string[]
|
||||
region_id?: string[] | string
|
||||
customer_id?: string[] | string
|
||||
q?: string
|
||||
created_at?: OperatorMap<string>
|
||||
updated_at?: OperatorMap<string>
|
||||
|
||||
@@ -51,7 +51,8 @@ export const AdminGetOrdersParams = createFindParams({
|
||||
sales_channel_id: z.array(z.string()).optional(),
|
||||
fulfillment_status: z.array(z.string()).optional(),
|
||||
payment_status: z.array(z.string()).optional(),
|
||||
region_id: z.array(z.string()).optional(),
|
||||
region_id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
customer_id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
q: z.string().optional(),
|
||||
created_at: createOperatorMap().optional(),
|
||||
updated_at: createOperatorMap().optional(),
|
||||
|
||||
Reference in New Issue
Block a user