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