feat(dashboard): basic Order UI (#7225)

**WHAT**
- rudimentary list and details pages
- fix Order<>Promotion link
- fix Order<>SalesChannel link

**NOTE**
- displaying basic info since we don't have Fulfillments & Payments linked ATM
- `disaply_id` needs to be added to order
- `tax_rate` needs to be added to order

---


https://github.com/medusajs/medusa/assets/16856471/cd4e98c7-345e-4193-8c1e-ad4ed1584993



Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
Frane Polić
2024-05-07 09:28:42 +02:00
committed by GitHub
parent 0430e63b0b
commit 39c3f6d92a
40 changed files with 1953 additions and 81 deletions

View File

@@ -0,0 +1,40 @@
import { QueryKey, useQuery, UseQueryOptions } from "@tanstack/react-query"
import { queryKeysFactory } from "../../lib/query-key-factory"
import { client } from "../../lib/client"
const ORDERS_QUERY_KEY = "orders" as const
export const ordersQueryKeys = queryKeysFactory(ORDERS_QUERY_KEY)
export const useOrder = (
id: string,
query?: Record<string, any>,
options?: Omit<
UseQueryOptions<any, Error, any, QueryKey>,
"queryFn" | "queryKey"
>
) => {
const { data, ...rest } = useQuery({
queryFn: () => client.orders.retrieve(id, query),
queryKey: ordersQueryKeys.detail(id, query),
...options,
})
return { ...data, ...rest }
}
export const useOrders = (
query?: Record<string, any>,
options?: Omit<
UseQueryOptions<any, Error, any, QueryKey>,
"queryFn" | "queryKey"
>
) => {
const { data, ...rest } = useQuery({
queryFn: () => client.orders.list(query),
queryKey: ordersQueryKeys.list(query),
...options,
})
return { ...data, ...rest }
}

View File

@@ -1,18 +1,19 @@
import { useAdminRegions, useAdminSalesChannels } from "medusa-react"
import { useTranslation } from "react-i18next"
import type { Filter } from "../../../components/table/data-table"
import { useRegions } from "../../api/regions"
import { useSalesChannels } from "../../api/sales-channels"
export const useOrderTableFilters = (): Filter[] => {
const { t } = useTranslation()
const { regions } = useAdminRegions({
const { regions } = useRegions({
limit: 1000,
fields: "id,name",
expand: "",
})
const { sales_channels } = useAdminSalesChannels({
const { sales_channels } = useSalesChannels({
limit: 1000,
fields: "id,name",
expand: "",
@@ -145,8 +146,9 @@ export const useOrderTableFilters = (): Filter[] => {
filters = [
...filters,
paymentStatusFilter,
fulfillmentStatusFilter,
// TODO: enable when Payment, Fulfillments <> Orders are linked
// paymentStatusFilter,
// fulfillmentStatusFilter,
...dateFilters,
]