1 import { HttpTypes } from "@medusajs/types"
2 import { useQueryParams } from "../../use-query-params"
3
4 type UseShippingOptionTableQueryProps = {
5 isReturn?: boolean
6 pageSize?: number
7 prefix?: string
8 }
9
10 export const useShippingOptionTableQuery = ({
11 pageSize = 10,
12 prefix,
13 }: UseShippingOptionTableQueryProps) => {
14 const queryObject = useQueryParams(
15 [
16 "offset",
17 "q",
18 "order",
19 "admin_only",
20 "is_return",
21 "created_at",
22 "updated_at",
23 "stock_location_id",
24 ],
25 prefix
26 )
27
28 const {
29 offset,
30 order,
31 q,
32 // admin_only,
33 // is_return,
34 created_at,
35 updated_at,
36 stock_location_id,
37 } = queryObject
38
39 const searchParams: HttpTypes.AdminShippingOptionListParams = {
40 limit: pageSize,
41 offset: offset ? Number(offset) : 0,
42 // TODO: We don't allow region_id in the API yet
43 // region_id: regionId,
44
45 // TODO: not supported
46 // is_return: is_return ? is_return === "true" : undefined,
47 // admin_only: admin_only ? admin_only === "true" : undefined,
48 q,
49 order,
50 stock_location_id,
51 created_at: created_at ? JSON.parse(created_at) : undefined,
52 updated_at: updated_at ? JSON.parse(updated_at) : undefined,
53 }
54
55 return {
56 searchParams,
57 raw: queryObject,
58 }
59 }