@instockng/api-client 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/enum-types.d.ts +8 -0
  2. package/dist/enum-types.js +5 -0
  3. package/dist/fetchers/carts.js +5 -0
  4. package/dist/hooks/admin/abandoned-carts.js +12 -8
  5. package/dist/hooks/admin/brands.js +15 -10
  6. package/dist/hooks/admin/customers.js +3 -2
  7. package/dist/hooks/admin/delivery-zones.js +24 -16
  8. package/dist/hooks/admin/discount-codes.js +24 -16
  9. package/dist/hooks/admin/inventory.js +15 -10
  10. package/dist/hooks/admin/orders.js +18 -12
  11. package/dist/hooks/admin/products.js +15 -10
  12. package/dist/hooks/admin/stats.js +3 -2
  13. package/dist/hooks/admin/variants.js +18 -12
  14. package/dist/hooks/admin/warehouses.js +15 -10
  15. package/dist/hooks/useApiConfig.d.ts +2 -1
  16. package/dist/hooks/useApiConfig.js +2 -2
  17. package/dist/provider.d.ts +7 -4
  18. package/dist/provider.js +5 -3
  19. package/dist/types.d.ts +1 -0
  20. package/package.json +1 -1
  21. package/dist/apps/backend/src/generated/zod/index.d.ts +0 -1114
  22. package/dist/apps/backend/src/generated/zod/index.js +0 -670
  23. package/dist/apps/backend/src/http-app.d.ts +0 -40
  24. package/dist/apps/backend/src/http-app.js +0 -106
  25. package/dist/apps/backend/src/lib/brand-response.d.ts +0 -14
  26. package/dist/apps/backend/src/lib/brand-response.js +0 -8
  27. package/dist/apps/backend/src/lib/cart-helpers.d.ts +0 -280
  28. package/dist/apps/backend/src/lib/cart-helpers.js +0 -93
  29. package/dist/apps/backend/src/lib/cart-recovery.d.ts +0 -30
  30. package/dist/apps/backend/src/lib/cart-recovery.js +0 -147
  31. package/dist/apps/backend/src/lib/cart-response.d.ts +0 -121
  32. package/dist/apps/backend/src/lib/cart-response.js +0 -150
  33. package/dist/apps/backend/src/lib/clerk.d.ts +0 -18
  34. package/dist/apps/backend/src/lib/clerk.js +0 -167
  35. package/dist/apps/backend/src/lib/delivery-zone-response.d.ts +0 -62
  36. package/dist/apps/backend/src/lib/delivery-zone-response.js +0 -24
  37. package/dist/apps/backend/src/lib/discount-code-response.d.ts +0 -42
  38. package/dist/apps/backend/src/lib/discount-code-response.js +0 -19
  39. package/dist/apps/backend/src/lib/discount.d.ts +0 -20
  40. package/dist/apps/backend/src/lib/discount.js +0 -35
  41. package/dist/apps/backend/src/lib/inventory.d.ts +0 -26
  42. package/dist/apps/backend/src/lib/inventory.js +0 -160
  43. package/dist/apps/backend/src/lib/meta-capi.d.ts +0 -48
  44. package/dist/apps/backend/src/lib/meta-capi.js +0 -120
  45. package/dist/apps/backend/src/lib/openapi.d.ts +0 -36
  46. package/dist/apps/backend/src/lib/openapi.js +0 -69
  47. package/dist/apps/backend/src/lib/order-recovery.d.ts +0 -367
  48. package/dist/apps/backend/src/lib/order-recovery.js +0 -373
  49. package/dist/apps/backend/src/lib/order-response.d.ts +0 -136
  50. package/dist/apps/backend/src/lib/order-response.js +0 -61
  51. package/dist/apps/backend/src/lib/pricing.d.ts +0 -39
  52. package/dist/apps/backend/src/lib/pricing.js +0 -62
  53. package/dist/apps/backend/src/lib/prisma.d.ts +0 -9
  54. package/dist/apps/backend/src/lib/prisma.js +0 -30
  55. package/dist/apps/backend/src/lib/product-response.d.ts +0 -82
  56. package/dist/apps/backend/src/lib/product-response.js +0 -29
  57. package/dist/apps/backend/src/lib/utils.d.ts +0 -32
  58. package/dist/apps/backend/src/lib/utils.js +0 -63
  59. package/dist/apps/backend/src/middleware/clerk-auth.d.ts +0 -8
  60. package/dist/apps/backend/src/middleware/clerk-auth.js +0 -89
  61. package/dist/apps/backend/src/middleware/cors.d.ts +0 -8
  62. package/dist/apps/backend/src/middleware/cors.js +0 -11
  63. package/dist/apps/backend/src/notifications/producers/meta-capi-producer.d.ts +0 -55
  64. package/dist/apps/backend/src/notifications/producers/meta-capi-producer.js +0 -125
  65. package/dist/apps/backend/src/notifications/producers/order-notification.d.ts +0 -9
  66. package/dist/apps/backend/src/notifications/producers/order-notification.js +0 -18
  67. package/dist/apps/backend/src/notifications/producers/prospect-recovery-notification.d.ts +0 -10
  68. package/dist/apps/backend/src/notifications/producers/prospect-recovery-notification.js +0 -11
  69. package/dist/apps/backend/src/routes/admin/abandoned-carts.d.ts +0 -605
  70. package/dist/apps/backend/src/routes/admin/abandoned-carts.js +0 -194
  71. package/dist/apps/backend/src/routes/admin/brands.d.ts +0 -175
  72. package/dist/apps/backend/src/routes/admin/brands.js +0 -118
  73. package/dist/apps/backend/src/routes/admin/customers.d.ts +0 -306
  74. package/dist/apps/backend/src/routes/admin/customers.js +0 -39
  75. package/dist/apps/backend/src/routes/admin/delivery-zones.d.ts +0 -438
  76. package/dist/apps/backend/src/routes/admin/delivery-zones.js +0 -300
  77. package/dist/apps/backend/src/routes/admin/discount-codes.d.ts +0 -478
  78. package/dist/apps/backend/src/routes/admin/discount-codes.js +0 -418
  79. package/dist/apps/backend/src/routes/admin/inventory.d.ts +0 -273
  80. package/dist/apps/backend/src/routes/admin/inventory.js +0 -189
  81. package/dist/apps/backend/src/routes/admin/orders.d.ts +0 -1478
  82. package/dist/apps/backend/src/routes/admin/orders.js +0 -503
  83. package/dist/apps/backend/src/routes/admin/products.d.ts +0 -860
  84. package/dist/apps/backend/src/routes/admin/products.js +0 -107
  85. package/dist/apps/backend/src/routes/admin/stats.d.ts +0 -288
  86. package/dist/apps/backend/src/routes/admin/stats.js +0 -55
  87. package/dist/apps/backend/src/routes/admin/variants.d.ts +0 -239
  88. package/dist/apps/backend/src/routes/admin/variants.js +0 -173
  89. package/dist/apps/backend/src/routes/admin/warehouses.d.ts +0 -373
  90. package/dist/apps/backend/src/routes/admin/warehouses.js +0 -123
  91. package/dist/apps/backend/src/routes/public/brands.d.ts +0 -40
  92. package/dist/apps/backend/src/routes/public/brands.js +0 -38
  93. package/dist/apps/backend/src/routes/public/carts.d.ts +0 -2655
  94. package/dist/apps/backend/src/routes/public/carts.js +0 -631
  95. package/dist/apps/backend/src/routes/public/delivery-zones.d.ts +0 -35
  96. package/dist/apps/backend/src/routes/public/delivery-zones.js +0 -62
  97. package/dist/apps/backend/src/routes/public/orders.d.ts +0 -323
  98. package/dist/apps/backend/src/routes/public/orders.js +0 -160
  99. package/dist/apps/backend/src/routes/public/products.d.ts +0 -449
  100. package/dist/apps/backend/src/routes/public/products.js +0 -133
  101. package/dist/apps/backend/src/types/index.d.ts +0 -42
  102. package/dist/apps/backend/src/types/index.js +0 -2
  103. package/dist/apps/backend/src/validators/brand.d.ts +0 -17
  104. package/dist/apps/backend/src/validators/brand.js +0 -15
  105. package/dist/apps/backend/src/validators/delivery-zone.d.ts +0 -31
  106. package/dist/apps/backend/src/validators/delivery-zone.js +0 -51
  107. package/dist/apps/backend/src/validators/discount-code.d.ts +0 -74
  108. package/dist/apps/backend/src/validators/discount-code.js +0 -50
  109. package/dist/apps/backend/src/validators/inventory.d.ts +0 -20
  110. package/dist/apps/backend/src/validators/inventory.js +0 -15
  111. package/dist/apps/backend/src/validators/order.d.ts +0 -87
  112. package/dist/apps/backend/src/validators/order.js +0 -61
  113. package/dist/apps/backend/src/validators/product.d.ts +0 -18
  114. package/dist/apps/backend/src/validators/product.js +0 -19
  115. package/dist/apps/backend/src/validators/variant.d.ts +0 -19
  116. package/dist/apps/backend/src/validators/variant.js +0 -19
  117. package/dist/apps/backend/src/validators/warehouse.d.ts +0 -15
  118. package/dist/apps/backend/src/validators/warehouse.js +0 -15
  119. package/dist/packages/api-client/src/backend-types.d.ts +0 -10
  120. package/dist/packages/api-client/src/backend-types.js +0 -10
  121. package/dist/packages/api-client/src/client.d.ts +0 -20
  122. package/dist/packages/api-client/src/client.js +0 -40
  123. package/dist/packages/api-client/src/fetchers/brands.d.ts +0 -25
  124. package/dist/packages/api-client/src/fetchers/brands.js +0 -26
  125. package/dist/packages/api-client/src/fetchers/carts.d.ts +0 -2335
  126. package/dist/packages/api-client/src/fetchers/carts.js +0 -169
  127. package/dist/packages/api-client/src/fetchers/delivery-zones.d.ts +0 -28
  128. package/dist/packages/api-client/src/fetchers/delivery-zones.js +0 -26
  129. package/dist/packages/api-client/src/fetchers/index.d.ts +0 -22
  130. package/dist/packages/api-client/src/fetchers/index.js +0 -22
  131. package/dist/packages/api-client/src/fetchers/orders.d.ts +0 -283
  132. package/dist/packages/api-client/src/fetchers/orders.js +0 -44
  133. package/dist/packages/api-client/src/fetchers/products.d.ts +0 -386
  134. package/dist/packages/api-client/src/fetchers/products.js +0 -42
  135. package/dist/packages/api-client/src/hooks/admin/abandoned-carts.d.ts +0 -535
  136. package/dist/packages/api-client/src/hooks/admin/abandoned-carts.js +0 -83
  137. package/dist/packages/api-client/src/hooks/admin/brands.d.ts +0 -79
  138. package/dist/packages/api-client/src/hooks/admin/brands.js +0 -108
  139. package/dist/packages/api-client/src/hooks/admin/customers.d.ts +0 -278
  140. package/dist/packages/api-client/src/hooks/admin/customers.js +0 -26
  141. package/dist/packages/api-client/src/hooks/admin/delivery-zones.d.ts +0 -270
  142. package/dist/packages/api-client/src/hooks/admin/delivery-zones.js +0 -176
  143. package/dist/packages/api-client/src/hooks/admin/discount-codes.d.ts +0 -299
  144. package/dist/packages/api-client/src/hooks/admin/discount-codes.js +0 -165
  145. package/dist/packages/api-client/src/hooks/admin/index.d.ts +0 -16
  146. package/dist/packages/api-client/src/hooks/admin/index.js +0 -16
  147. package/dist/packages/api-client/src/hooks/admin/inventory.d.ts +0 -224
  148. package/dist/packages/api-client/src/hooks/admin/inventory.js +0 -107
  149. package/dist/packages/api-client/src/hooks/admin/orders.d.ts +0 -1380
  150. package/dist/packages/api-client/src/hooks/admin/orders.js +0 -175
  151. package/dist/packages/api-client/src/hooks/admin/products.d.ts +0 -374
  152. package/dist/packages/api-client/src/hooks/admin/products.js +0 -89
  153. package/dist/packages/api-client/src/hooks/admin/stats.d.ts +0 -277
  154. package/dist/packages/api-client/src/hooks/admin/stats.js +0 -25
  155. package/dist/packages/api-client/src/hooks/admin/variants.d.ts +0 -115
  156. package/dist/packages/api-client/src/hooks/admin/variants.js +0 -127
  157. package/dist/packages/api-client/src/hooks/admin/warehouses.d.ts +0 -277
  158. package/dist/packages/api-client/src/hooks/admin/warehouses.js +0 -108
  159. package/dist/packages/api-client/src/hooks/public/brands.d.ts +0 -33
  160. package/dist/packages/api-client/src/hooks/public/brands.js +0 -30
  161. package/dist/packages/api-client/src/hooks/public/carts.d.ts +0 -2405
  162. package/dist/packages/api-client/src/hooks/public/carts.js +0 -213
  163. package/dist/packages/api-client/src/hooks/public/delivery-zones.d.ts +0 -34
  164. package/dist/packages/api-client/src/hooks/public/delivery-zones.js +0 -28
  165. package/dist/packages/api-client/src/hooks/public/index.d.ts +0 -10
  166. package/dist/packages/api-client/src/hooks/public/index.js +0 -10
  167. package/dist/packages/api-client/src/hooks/public/orders.d.ts +0 -302
  168. package/dist/packages/api-client/src/hooks/public/orders.js +0 -50
  169. package/dist/packages/api-client/src/hooks/public/products.d.ts +0 -398
  170. package/dist/packages/api-client/src/hooks/public/products.js +0 -47
  171. package/dist/packages/api-client/src/hooks/use-query-unwrapped.d.ts +0 -20
  172. package/dist/packages/api-client/src/hooks/use-query-unwrapped.js +0 -22
  173. package/dist/packages/api-client/src/hooks/useApiConfig.d.ts +0 -12
  174. package/dist/packages/api-client/src/hooks/useApiConfig.js +0 -14
  175. package/dist/packages/api-client/src/index.d.ts +0 -20
  176. package/dist/packages/api-client/src/index.js +0 -25
  177. package/dist/packages/api-client/src/provider.d.ts +0 -36
  178. package/dist/packages/api-client/src/provider.js +0 -54
  179. package/dist/packages/api-client/src/rpc-client.d.ts +0 -9035
  180. package/dist/packages/api-client/src/rpc-client.js +0 -78
  181. package/dist/packages/api-client/src/rpc-types.d.ts +0 -76
  182. package/dist/packages/api-client/src/rpc-types.js +0 -7
  183. package/dist/packages/api-client/src/types.d.ts +0 -37
  184. package/dist/packages/api-client/src/types.js +0 -16
  185. package/dist/packages/api-client/src/utils/query-keys.d.ts +0 -106
  186. package/dist/packages/api-client/src/utils/query-keys.js +0 -108
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Enum types extracted from RPC responses
3
+ * These are re-exported in types.ts
4
+ */
5
+ import type { AdminOrderFull, PublicCartResponse } from './rpc-types';
6
+ export type OrderStatus = AdminOrderFull['status'];
7
+ export type ProspectReason = NonNullable<AdminOrderFull['prospectReason']>;
8
+ export type PaymentMethod = PublicCartResponse['availablePaymentMethods'][number];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Enum types extracted from RPC responses
3
+ * These are re-exported in types.ts
4
+ */
5
+ export {};
@@ -51,6 +51,7 @@ export async function updateCart(cartId, data) {
51
51
  const clients = createRpcClients(API_URL);
52
52
  const res = await clients.carts[':id'].$patch({
53
53
  param: { id: cartId },
54
+ // @ts-expect-error - Hono RPC type inference issue
54
55
  json: data,
55
56
  });
56
57
  if (!res.ok) {
@@ -72,6 +73,7 @@ export async function addCartItem(cartId, sku, quantity, fbc, fbp) {
72
73
  const clients = createRpcClients(API_URL);
73
74
  const res = await clients.carts[':id'].items.$post({
74
75
  param: { id: cartId },
76
+ // @ts-expect-error - Hono RPC type inference issue
75
77
  json: { sku, quantity, fbc, fbp },
76
78
  });
77
79
  if (!res.ok) {
@@ -91,6 +93,7 @@ export async function updateCartItem(cartId, itemId, quantity) {
91
93
  const clients = createRpcClients(API_URL);
92
94
  const res = await clients.carts[':id'].items[':itemId'].$patch({
93
95
  param: { id: cartId, itemId },
96
+ // @ts-expect-error - Hono RPC type inference issue
94
97
  json: { quantity },
95
98
  });
96
99
  if (!res.ok) {
@@ -126,6 +129,7 @@ export async function applyDiscount(cartId, code) {
126
129
  const clients = createRpcClients(API_URL);
127
130
  const res = await clients.carts[':id']['apply-discount'].$post({
128
131
  param: { id: cartId },
132
+ // @ts-expect-error - Hono RPC type inference issue
129
133
  json: { code },
130
134
  });
131
135
  if (!res.ok) {
@@ -160,6 +164,7 @@ export async function checkoutCart(cartId, checkoutData) {
160
164
  const clients = createRpcClients(API_URL);
161
165
  const res = await clients.carts[':id'].checkout.$post({
162
166
  param: { id: cartId },
167
+ // @ts-expect-error - Hono RPC type inference issue
163
168
  json: checkoutData,
164
169
  });
165
170
  if (!res.ok) {
@@ -10,12 +10,13 @@ import { useApiConfig } from '../useApiConfig';
10
10
  * Hook to list abandoned carts using admin RPC
11
11
  */
12
12
  export function useListAbandonedCarts(params, options) {
13
- const { baseURL, authToken } = useApiConfig();
13
+ const { baseURL, getAuthToken } = useApiConfig();
14
14
  return useQueryUnwrapped({
15
15
  queryKey: queryKeys.admin.abandonedCarts.list(params),
16
16
  queryFn: async () => {
17
+ const token = await getAuthToken();
17
18
  const clients = createAdminRpcClients(baseURL);
18
- const res = await clients.abandonedCarts.index.$get({ query: params }, authHeaders(authToken));
19
+ const res = await clients.abandonedCarts.index.$get({ query: params }, authHeaders(token));
19
20
  if (!res.ok)
20
21
  throw new Error(`Failed to fetch abandoned carts: ${res.statusText}`);
21
22
  return res.json();
@@ -27,12 +28,13 @@ export function useListAbandonedCarts(params, options) {
27
28
  * Hook to get abandoned cart statistics using admin RPC
28
29
  */
29
30
  export function useGetAbandonedCartStats(params, options) {
30
- const { baseURL, authToken } = useApiConfig();
31
+ const { baseURL, getAuthToken } = useApiConfig();
31
32
  return useQueryUnwrapped({
32
33
  queryKey: queryKeys.admin.abandonedCarts.stats(params?.brandId),
33
34
  queryFn: async () => {
35
+ const token = await getAuthToken();
34
36
  const clients = createAdminRpcClients(baseURL);
35
- const res = await clients.abandonedCarts.stats.$get({ query: params }, authHeaders(authToken));
37
+ const res = await clients.abandonedCarts.stats.$get({ query: params }, authHeaders(token));
36
38
  if (!res.ok)
37
39
  throw new Error(`Failed to fetch abandoned cart stats: ${res.statusText}`);
38
40
  return res.json();
@@ -44,12 +46,13 @@ export function useGetAbandonedCartStats(params, options) {
44
46
  * Hook to get specific abandoned cart details using admin RPC
45
47
  */
46
48
  export function useGetAbandonedCart(cartId, options) {
47
- const { baseURL, authToken } = useApiConfig();
49
+ const { baseURL, getAuthToken } = useApiConfig();
48
50
  return useQueryUnwrapped({
49
51
  queryKey: queryKeys.admin.abandonedCarts.detail(cartId),
50
52
  queryFn: async () => {
53
+ const token = await getAuthToken();
51
54
  const clients = createAdminRpcClients(baseURL);
52
- const res = await clients.abandonedCarts[':id'].$get({ param: { id: cartId } }, authHeaders(authToken));
55
+ const res = await clients.abandonedCarts[':id'].$get({ param: { id: cartId } }, authHeaders(token));
53
56
  if (!res.ok)
54
57
  throw new Error(`Failed to fetch abandoned cart: ${res.statusText}`);
55
58
  return res.json();
@@ -61,12 +64,13 @@ export function useGetAbandonedCart(cartId, options) {
61
64
  * Hook to clean up expired carts using admin RPC
62
65
  */
63
66
  export function useCleanupExpiredCarts(options) {
64
- const { baseURL, authToken } = useApiConfig();
67
+ const { baseURL, getAuthToken } = useApiConfig();
65
68
  const queryClient = useQueryClient();
66
69
  return useMutation({
67
70
  mutationFn: async () => {
71
+ const token = await getAuthToken();
68
72
  const clients = createAdminRpcClients(baseURL);
69
- const res = await clients.abandonedCarts.cleanup.$post({}, authHeaders(authToken));
73
+ const res = await clients.abandonedCarts.cleanup.$post({}, authHeaders(token));
70
74
  if (!res.ok)
71
75
  throw new Error(`Failed to cleanup expired carts: ${res.statusText}`);
72
76
  return res.json();
@@ -10,12 +10,13 @@ import { useApiConfig } from '../useApiConfig';
10
10
  * Hook to list all brands using admin RPC
11
11
  */
12
12
  export function useListBrands(options) {
13
- const { baseURL, authToken } = useApiConfig();
13
+ const { baseURL, getAuthToken } = useApiConfig();
14
14
  return useQueryUnwrapped({
15
15
  queryKey: queryKeys.admin.brands.list(),
16
16
  queryFn: async () => {
17
+ const token = await getAuthToken();
17
18
  const clients = createAdminRpcClients(baseURL);
18
- const res = await clients.brands.index.$get({}, authHeaders(authToken));
19
+ const res = await clients.brands.index.$get({}, authHeaders(token));
19
20
  if (!res.ok)
20
21
  throw new Error(`Failed to fetch brands: ${res.statusText}`);
21
22
  return res.json();
@@ -27,12 +28,13 @@ export function useListBrands(options) {
27
28
  * Hook to get brand by ID using admin RPC
28
29
  */
29
30
  export function useGetBrand(brandId, options) {
30
- const { baseURL, authToken } = useApiConfig();
31
+ const { baseURL, getAuthToken } = useApiConfig();
31
32
  return useQueryUnwrapped({
32
33
  queryKey: queryKeys.admin.brands.detail(brandId),
33
34
  queryFn: async () => {
35
+ const token = await getAuthToken();
34
36
  const clients = createAdminRpcClients(baseURL);
35
- const res = await clients.brands[':id'].$get({ param: { id: brandId } }, authHeaders(authToken));
37
+ const res = await clients.brands[':id'].$get({ param: { id: brandId } }, authHeaders(token));
36
38
  if (!res.ok)
37
39
  throw new Error(`Failed to fetch brand: ${res.statusText}`);
38
40
  return res.json();
@@ -44,12 +46,13 @@ export function useGetBrand(brandId, options) {
44
46
  * Hook to create a brand using admin RPC
45
47
  */
46
48
  export function useCreateBrand(options) {
47
- const { baseURL, authToken } = useApiConfig();
49
+ const { baseURL, getAuthToken } = useApiConfig();
48
50
  const queryClient = useQueryClient();
49
51
  return useMutation({
50
52
  mutationFn: async (data) => {
53
+ const token = await getAuthToken();
51
54
  const clients = createAdminRpcClients(baseURL);
52
- const res = await clients.brands.index.$post({ json: data }, authHeaders(authToken));
55
+ const res = await clients.brands.index.$post({ json: data }, authHeaders(token));
53
56
  if (!res.ok)
54
57
  throw new Error(`Failed to create brand: ${res.statusText}`);
55
58
  return res.json();
@@ -64,12 +67,13 @@ export function useCreateBrand(options) {
64
67
  * Hook to update a brand using admin RPC
65
68
  */
66
69
  export function useUpdateBrand(brandId, options) {
67
- const { baseURL, authToken } = useApiConfig();
70
+ const { baseURL, getAuthToken } = useApiConfig();
68
71
  const queryClient = useQueryClient();
69
72
  return useMutation({
70
73
  mutationFn: async (data) => {
74
+ const token = await getAuthToken();
71
75
  const clients = createAdminRpcClients(baseURL);
72
- const res = await clients.brands[':id'].$patch({ json: data, param: { id: brandId } }, authHeaders(authToken));
76
+ const res = await clients.brands[':id'].$patch({ json: data, param: { id: brandId } }, authHeaders(token));
73
77
  if (!res.ok)
74
78
  throw new Error(`Failed to update brand: ${res.statusText}`);
75
79
  return res.json();
@@ -85,12 +89,13 @@ export function useUpdateBrand(brandId, options) {
85
89
  * Hook to delete a brand using admin RPC
86
90
  */
87
91
  export function useDeleteBrand(brandId, options) {
88
- const { baseURL, authToken } = useApiConfig();
92
+ const { baseURL, getAuthToken } = useApiConfig();
89
93
  const queryClient = useQueryClient();
90
94
  return useMutation({
91
95
  mutationFn: async () => {
96
+ const token = await getAuthToken();
92
97
  const clients = createAdminRpcClients(baseURL);
93
- const res = await clients.brands[':id'].$delete({ param: { id: brandId } }, authHeaders(authToken));
98
+ const res = await clients.brands[':id'].$delete({ param: { id: brandId } }, authHeaders(token));
94
99
  if (!res.ok)
95
100
  throw new Error(`Failed to delete brand: ${res.statusText}`);
96
101
  return res.json();
@@ -9,12 +9,13 @@ import { useApiConfig } from '../useApiConfig';
9
9
  * Hook to get customer order history by phone using admin RPC
10
10
  */
11
11
  export function useGetCustomerHistory(phone, options) {
12
- const { baseURL, authToken } = useApiConfig();
12
+ const { baseURL, getAuthToken } = useApiConfig();
13
13
  return useQueryUnwrapped({
14
14
  queryKey: queryKeys.admin.customers.history(phone),
15
15
  queryFn: async () => {
16
+ const token = await getAuthToken();
16
17
  const clients = createAdminRpcClients(baseURL);
17
- const res = await clients.customers.history.$get({ query: { phone } }, authHeaders(authToken));
18
+ const res = await clients.customers.history.$get({ query: { phone } }, authHeaders(token));
18
19
  if (!res.ok)
19
20
  throw new Error(`Failed to fetch customer history: ${res.statusText}`);
20
21
  return res.json();
@@ -11,12 +11,13 @@ import { useApiConfig } from '../useApiConfig';
11
11
  * Hook to list all states using admin RPC
12
12
  */
13
13
  export function useListStates(options) {
14
- const { baseURL, authToken } = useApiConfig();
14
+ const { baseURL, getAuthToken } = useApiConfig();
15
15
  return useQueryUnwrapped({
16
16
  queryKey: queryKeys.admin.deliveryZones.states.list(),
17
17
  queryFn: async () => {
18
+ const token = await getAuthToken();
18
19
  const clients = createAdminRpcClients(baseURL);
19
- const res = await clients.deliveryZones.states.$get({}, authHeaders(authToken));
20
+ const res = await clients.deliveryZones.states.$get({}, authHeaders(token));
20
21
  if (!res.ok)
21
22
  throw new Error(`Failed to fetch states: ${res.statusText}`);
22
23
  return res.json();
@@ -28,12 +29,13 @@ export function useListStates(options) {
28
29
  * Hook to create a state using admin RPC
29
30
  */
30
31
  export function useCreateState(options) {
31
- const { baseURL, authToken } = useApiConfig();
32
+ const { baseURL, getAuthToken } = useApiConfig();
32
33
  const queryClient = useQueryClient();
33
34
  return useMutation({
34
35
  mutationFn: async (data) => {
36
+ const token = await getAuthToken();
35
37
  const clients = createAdminRpcClients(baseURL);
36
- const res = await clients.deliveryZones.states.$post({ json: data }, authHeaders(authToken));
38
+ const res = await clients.deliveryZones.states.$post({ json: data }, authHeaders(token));
37
39
  if (!res.ok)
38
40
  throw new Error(`Failed to create state: ${res.statusText}`);
39
41
  return res.json();
@@ -48,12 +50,13 @@ export function useCreateState(options) {
48
50
  * Hook to update a state using admin RPC
49
51
  */
50
52
  export function useUpdateState(stateId, options) {
51
- const { baseURL, authToken } = useApiConfig();
53
+ const { baseURL, getAuthToken } = useApiConfig();
52
54
  const queryClient = useQueryClient();
53
55
  return useMutation({
54
56
  mutationFn: async (data) => {
57
+ const token = await getAuthToken();
55
58
  const clients = createAdminRpcClients(baseURL);
56
- const res = await clients.deliveryZones.states[':id'].$patch({ json: data, param: { id: stateId } }, authHeaders(authToken));
59
+ const res = await clients.deliveryZones.states[':id'].$patch({ json: data, param: { id: stateId } }, authHeaders(token));
57
60
  if (!res.ok)
58
61
  throw new Error(`Failed to update state: ${res.statusText}`);
59
62
  return res.json();
@@ -69,12 +72,13 @@ export function useUpdateState(stateId, options) {
69
72
  * Hook to delete a state using admin RPC
70
73
  */
71
74
  export function useDeleteState(stateId, options) {
72
- const { baseURL, authToken } = useApiConfig();
75
+ const { baseURL, getAuthToken } = useApiConfig();
73
76
  const queryClient = useQueryClient();
74
77
  return useMutation({
75
78
  mutationFn: async () => {
79
+ const token = await getAuthToken();
76
80
  const clients = createAdminRpcClients(baseURL);
77
- const res = await clients.deliveryZones.states[':id'].$delete({ param: { id: stateId } }, authHeaders(authToken));
81
+ const res = await clients.deliveryZones.states[':id'].$delete({ param: { id: stateId } }, authHeaders(token));
78
82
  if (!res.ok)
79
83
  throw new Error(`Failed to delete state: ${res.statusText}`);
80
84
  return res.json();
@@ -91,12 +95,13 @@ export function useDeleteState(stateId, options) {
91
95
  * Hook to list delivery zones using admin RPC
92
96
  */
93
97
  export function useListDeliveryZones(params, options) {
94
- const { baseURL, authToken } = useApiConfig();
98
+ const { baseURL, getAuthToken } = useApiConfig();
95
99
  return useQueryUnwrapped({
96
100
  queryKey: queryKeys.admin.deliveryZones.zones.list(params),
97
101
  queryFn: async () => {
102
+ const token = await getAuthToken();
98
103
  const clients = createAdminRpcClients(baseURL);
99
- const res = await clients.deliveryZones.zones.$get({ query: params }, authHeaders(authToken));
104
+ const res = await clients.deliveryZones.zones.$get({ query: params }, authHeaders(token));
100
105
  if (!res.ok)
101
106
  throw new Error(`Failed to fetch delivery zones: ${res.statusText}`);
102
107
  return res.json();
@@ -108,12 +113,13 @@ export function useListDeliveryZones(params, options) {
108
113
  * Hook to create a delivery zone using admin RPC
109
114
  */
110
115
  export function useCreateDeliveryZone(options) {
111
- const { baseURL, authToken } = useApiConfig();
116
+ const { baseURL, getAuthToken } = useApiConfig();
112
117
  const queryClient = useQueryClient();
113
118
  return useMutation({
114
119
  mutationFn: async (data) => {
120
+ const token = await getAuthToken();
115
121
  const clients = createAdminRpcClients(baseURL);
116
- const res = await clients.deliveryZones.zones.$post({ json: data }, authHeaders(authToken));
122
+ const res = await clients.deliveryZones.zones.$post({ json: data }, authHeaders(token));
117
123
  if (!res.ok)
118
124
  throw new Error(`Failed to create delivery zone: ${res.statusText}`);
119
125
  return res.json();
@@ -129,12 +135,13 @@ export function useCreateDeliveryZone(options) {
129
135
  * Hook to update a delivery zone using admin RPC
130
136
  */
131
137
  export function useUpdateDeliveryZone(zoneId, options) {
132
- const { baseURL, authToken } = useApiConfig();
138
+ const { baseURL, getAuthToken } = useApiConfig();
133
139
  const queryClient = useQueryClient();
134
140
  return useMutation({
135
141
  mutationFn: async (data) => {
142
+ const token = await getAuthToken();
136
143
  const clients = createAdminRpcClients(baseURL);
137
- const res = await clients.deliveryZones.zones[':id'].$patch({ json: data, param: { id: zoneId } }, authHeaders(authToken));
144
+ const res = await clients.deliveryZones.zones[':id'].$patch({ json: data, param: { id: zoneId } }, authHeaders(token));
138
145
  if (!res.ok)
139
146
  throw new Error(`Failed to update delivery zone: ${res.statusText}`);
140
147
  return res.json();
@@ -150,12 +157,13 @@ export function useUpdateDeliveryZone(zoneId, options) {
150
157
  * Hook to delete a delivery zone using admin RPC
151
158
  */
152
159
  export function useDeleteDeliveryZone(zoneId, options) {
153
- const { baseURL, authToken } = useApiConfig();
160
+ const { baseURL, getAuthToken } = useApiConfig();
154
161
  const queryClient = useQueryClient();
155
162
  return useMutation({
156
163
  mutationFn: async () => {
164
+ const token = await getAuthToken();
157
165
  const clients = createAdminRpcClients(baseURL);
158
- const res = await clients.deliveryZones.zones[':id'].$delete({ param: { id: zoneId } }, authHeaders(authToken));
166
+ const res = await clients.deliveryZones.zones[':id'].$delete({ param: { id: zoneId } }, authHeaders(token));
159
167
  if (!res.ok)
160
168
  throw new Error(`Failed to delete delivery zone: ${res.statusText}`);
161
169
  return res.json();
@@ -10,12 +10,13 @@ import { useApiConfig } from '../useApiConfig';
10
10
  * Hook to list discount codes using admin RPC
11
11
  */
12
12
  export function useListDiscountCodes(params, options) {
13
- const { baseURL, authToken } = useApiConfig();
13
+ const { baseURL, getAuthToken } = useApiConfig();
14
14
  return useQueryUnwrapped({
15
15
  queryKey: queryKeys.admin.discountCodes.list(params),
16
16
  queryFn: async () => {
17
+ const token = await getAuthToken();
17
18
  const clients = createAdminRpcClients(baseURL);
18
- const res = await clients.discountCodes.index.$get({ query: params }, authHeaders(authToken));
19
+ const res = await clients.discountCodes.index.$get({ query: params }, authHeaders(token));
19
20
  if (!res.ok)
20
21
  throw new Error(`Failed to fetch discount codes: ${res.statusText}`);
21
22
  return res.json();
@@ -27,12 +28,13 @@ export function useListDiscountCodes(params, options) {
27
28
  * Hook to get discount code by ID using admin RPC
28
29
  */
29
30
  export function useGetDiscountCode(codeId, options) {
30
- const { baseURL, authToken } = useApiConfig();
31
+ const { baseURL, getAuthToken } = useApiConfig();
31
32
  return useQueryUnwrapped({
32
33
  queryKey: queryKeys.admin.discountCodes.detail(codeId),
33
34
  queryFn: async () => {
35
+ const token = await getAuthToken();
34
36
  const clients = createAdminRpcClients(baseURL);
35
- const res = await clients.discountCodes[':id'].$get({ param: { id: codeId } }, authHeaders(authToken));
37
+ const res = await clients.discountCodes[':id'].$get({ param: { id: codeId } }, authHeaders(token));
36
38
  if (!res.ok)
37
39
  throw new Error(`Failed to fetch discount code: ${res.statusText}`);
38
40
  return res.json();
@@ -44,12 +46,13 @@ export function useGetDiscountCode(codeId, options) {
44
46
  * Hook to create a discount code using admin RPC
45
47
  */
46
48
  export function useCreateDiscountCode(options) {
47
- const { baseURL, authToken } = useApiConfig();
49
+ const { baseURL, getAuthToken } = useApiConfig();
48
50
  const queryClient = useQueryClient();
49
51
  return useMutation({
50
52
  mutationFn: async (data) => {
53
+ const token = await getAuthToken();
51
54
  const clients = createAdminRpcClients(baseURL);
52
- const res = await clients.discountCodes.index.$post({ json: data }, authHeaders(authToken));
55
+ const res = await clients.discountCodes.index.$post({ json: data }, authHeaders(token));
53
56
  if (!res.ok)
54
57
  throw new Error(`Failed to create discount code: ${res.statusText}`);
55
58
  return res.json();
@@ -64,12 +67,13 @@ export function useCreateDiscountCode(options) {
64
67
  * Hook to update a discount code using admin RPC
65
68
  */
66
69
  export function useUpdateDiscountCode(codeId, options) {
67
- const { baseURL, authToken } = useApiConfig();
70
+ const { baseURL, getAuthToken } = useApiConfig();
68
71
  const queryClient = useQueryClient();
69
72
  return useMutation({
70
73
  mutationFn: async (data) => {
74
+ const token = await getAuthToken();
71
75
  const clients = createAdminRpcClients(baseURL);
72
- const res = await clients.discountCodes[':id'].$patch({ json: data, param: { id: codeId } }, authHeaders(authToken));
76
+ const res = await clients.discountCodes[':id'].$patch({ json: data, param: { id: codeId } }, authHeaders(token));
73
77
  if (!res.ok)
74
78
  throw new Error(`Failed to update discount code: ${res.statusText}`);
75
79
  return res.json();
@@ -85,12 +89,13 @@ export function useUpdateDiscountCode(codeId, options) {
85
89
  * Hook to delete a discount code using admin RPC
86
90
  */
87
91
  export function useDeleteDiscountCode(codeId, options) {
88
- const { baseURL, authToken } = useApiConfig();
92
+ const { baseURL, getAuthToken } = useApiConfig();
89
93
  const queryClient = useQueryClient();
90
94
  return useMutation({
91
95
  mutationFn: async () => {
96
+ const token = await getAuthToken();
92
97
  const clients = createAdminRpcClients(baseURL);
93
- const res = await clients.discountCodes[':id'].$delete({ param: { id: codeId } }, authHeaders(authToken));
98
+ const res = await clients.discountCodes[':id'].$delete({ param: { id: codeId } }, authHeaders(token));
94
99
  if (!res.ok)
95
100
  throw new Error(`Failed to delete discount code: ${res.statusText}`);
96
101
  return res.json();
@@ -105,12 +110,13 @@ export function useDeleteDiscountCode(codeId, options) {
105
110
  * Hook to get discount code analytics using admin RPC
106
111
  */
107
112
  export function useGetDiscountCodeAnalytics(codeId, options) {
108
- const { baseURL, authToken } = useApiConfig();
113
+ const { baseURL, getAuthToken } = useApiConfig();
109
114
  return useQueryUnwrapped({
110
115
  queryKey: queryKeys.admin.discountCodes.analytics(codeId),
111
116
  queryFn: async () => {
117
+ const token = await getAuthToken();
112
118
  const clients = createAdminRpcClients(baseURL);
113
- const res = await clients.discountCodes[':id'].analytics.$get({ param: { id: codeId } }, authHeaders(authToken));
119
+ const res = await clients.discountCodes[':id'].analytics.$get({ param: { id: codeId } }, authHeaders(token));
114
120
  if (!res.ok)
115
121
  throw new Error(`Failed to fetch discount code analytics: ${res.statusText}`);
116
122
  return res.json();
@@ -122,12 +128,13 @@ export function useGetDiscountCodeAnalytics(codeId, options) {
122
128
  * Hook to bulk generate discount codes using admin RPC
123
129
  */
124
130
  export function useBulkGenerateDiscountCodes(options) {
125
- const { baseURL, authToken } = useApiConfig();
131
+ const { baseURL, getAuthToken } = useApiConfig();
126
132
  const queryClient = useQueryClient();
127
133
  return useMutation({
128
134
  mutationFn: async (data) => {
135
+ const token = await getAuthToken();
129
136
  const clients = createAdminRpcClients(baseURL);
130
- const res = await clients.discountCodes['bulk-generate'].$post({ json: data }, authHeaders(authToken));
137
+ const res = await clients.discountCodes['bulk-generate'].$post({ json: data }, authHeaders(token));
131
138
  if (!res.ok)
132
139
  throw new Error(`Failed to bulk generate discount codes: ${res.statusText}`);
133
140
  return res.json();
@@ -142,12 +149,13 @@ export function useBulkGenerateDiscountCodes(options) {
142
149
  * Hook to get discount code overview stats using admin RPC
143
150
  */
144
151
  export function useGetDiscountCodeOverviewStats(options) {
145
- const { baseURL, authToken } = useApiConfig();
152
+ const { baseURL, getAuthToken } = useApiConfig();
146
153
  return useQueryUnwrapped({
147
154
  queryKey: queryKeys.admin.discountCodes.overviewStats(),
148
155
  queryFn: async () => {
156
+ const token = await getAuthToken();
149
157
  const clients = createAdminRpcClients(baseURL);
150
- const res = await clients.discountCodes.stats.overview.$get({}, authHeaders(authToken));
158
+ const res = await clients.discountCodes.stats.overview.$get({}, authHeaders(token));
151
159
  if (!res.ok)
152
160
  throw new Error(`Failed to fetch discount code overview stats: ${res.statusText}`);
153
161
  return res.json();
@@ -10,12 +10,13 @@ import { useApiConfig } from '../useApiConfig';
10
10
  * Hook to get inventory overview using admin RPC
11
11
  */
12
12
  export function useListInventory(params, options) {
13
- const { baseURL, authToken } = useApiConfig();
13
+ const { baseURL, getAuthToken } = useApiConfig();
14
14
  return useQueryUnwrapped({
15
15
  queryKey: queryKeys.admin.inventory.list(params),
16
16
  queryFn: async () => {
17
+ const token = await getAuthToken();
17
18
  const clients = createAdminRpcClients(baseURL);
18
- const res = await clients.inventory.index.$get({ query: params }, authHeaders(authToken));
19
+ const res = await clients.inventory.index.$get({ query: params }, authHeaders(token));
19
20
  if (!res.ok)
20
21
  throw new Error(`Failed to fetch inventory: ${res.statusText}`);
21
22
  return res.json();
@@ -27,12 +28,13 @@ export function useListInventory(params, options) {
27
28
  * Hook to adjust inventory using admin RPC
28
29
  */
29
30
  export function useAdjustInventory(options) {
30
- const { baseURL, authToken } = useApiConfig();
31
+ const { baseURL, getAuthToken } = useApiConfig();
31
32
  const queryClient = useQueryClient();
32
33
  return useMutation({
33
34
  mutationFn: async (data) => {
35
+ const token = await getAuthToken();
34
36
  const clients = createAdminRpcClients(baseURL);
35
- const res = await clients.inventory.adjust.$post({ json: data }, authHeaders(authToken));
37
+ const res = await clients.inventory.adjust.$post({ json: data }, authHeaders(token));
36
38
  if (!res.ok)
37
39
  throw new Error(`Failed to adjust inventory: ${res.statusText}`);
38
40
  return res.json();
@@ -49,12 +51,13 @@ export function useAdjustInventory(options) {
49
51
  * Hook to transfer inventory between warehouses using admin RPC
50
52
  */
51
53
  export function useTransferInventory(options) {
52
- const { baseURL, authToken } = useApiConfig();
54
+ const { baseURL, getAuthToken } = useApiConfig();
53
55
  const queryClient = useQueryClient();
54
56
  return useMutation({
55
57
  mutationFn: async (data) => {
58
+ const token = await getAuthToken();
56
59
  const clients = createAdminRpcClients(baseURL);
57
- const res = await clients.inventory.transfer.$post({ json: data }, authHeaders(authToken));
60
+ const res = await clients.inventory.transfer.$post({ json: data }, authHeaders(token));
58
61
  if (!res.ok)
59
62
  throw new Error(`Failed to transfer inventory: ${res.statusText}`);
60
63
  return res.json();
@@ -70,12 +73,13 @@ export function useTransferInventory(options) {
70
73
  * Hook to get inventory transaction history using admin RPC
71
74
  */
72
75
  export function useGetInventoryTransactions(params, options) {
73
- const { baseURL, authToken } = useApiConfig();
76
+ const { baseURL, getAuthToken } = useApiConfig();
74
77
  return useQueryUnwrapped({
75
78
  queryKey: queryKeys.admin.inventory.transactions(params),
76
79
  queryFn: async () => {
80
+ const token = await getAuthToken();
77
81
  const clients = createAdminRpcClients(baseURL);
78
- const res = await clients.inventory.transactions.$get({ query: params }, authHeaders(authToken));
82
+ const res = await clients.inventory.transactions.$get({ query: params }, authHeaders(token));
79
83
  if (!res.ok)
80
84
  throw new Error(`Failed to fetch inventory transactions: ${res.statusText}`);
81
85
  return res.json();
@@ -87,12 +91,13 @@ export function useGetInventoryTransactions(params, options) {
87
91
  * Hook to get low stock alerts using admin RPC
88
92
  */
89
93
  export function useGetLowStockVariants(params, options) {
90
- const { baseURL, authToken } = useApiConfig();
94
+ const { baseURL, getAuthToken } = useApiConfig();
91
95
  return useQueryUnwrapped({
92
96
  queryKey: queryKeys.admin.inventory.lowStock(params?.brandId),
93
97
  queryFn: async () => {
98
+ const token = await getAuthToken();
94
99
  const clients = createAdminRpcClients(baseURL);
95
- const res = await clients.inventory['low-stock'].$get({ query: params }, authHeaders(authToken));
100
+ const res = await clients.inventory['low-stock'].$get({ query: params }, authHeaders(token));
96
101
  if (!res.ok)
97
102
  throw new Error(`Failed to fetch low stock alerts: ${res.statusText}`);
98
103
  return res.json();
@@ -20,12 +20,13 @@ import { useApiConfig } from '../useApiConfig';
20
20
  * ```
21
21
  */
22
22
  export function useListOrders(options) {
23
- const { baseURL, authToken } = useApiConfig();
23
+ const { baseURL, getAuthToken } = useApiConfig();
24
24
  return useQueryUnwrapped({
25
25
  queryKey: queryKeys.admin.orders.list(),
26
26
  queryFn: async () => {
27
+ const token = await getAuthToken();
27
28
  const clients = createAdminRpcClients(baseURL);
28
- const res = await clients.orders.index.$get({}, authHeaders(authToken));
29
+ const res = await clients.orders.index.$get({}, authHeaders(token));
29
30
  if (!res.ok) {
30
31
  throw new Error(`Failed to fetch orders: ${res.statusText}`);
31
32
  }
@@ -46,12 +47,13 @@ export function useListOrders(options) {
46
47
  * ```
47
48
  */
48
49
  export function useGetOrder(orderId, options) {
49
- const { baseURL, authToken } = useApiConfig();
50
+ const { baseURL, getAuthToken } = useApiConfig();
50
51
  return useQueryUnwrapped({
51
52
  queryKey: queryKeys.admin.orders.detail(orderId),
52
53
  queryFn: async () => {
54
+ const token = await getAuthToken();
53
55
  const clients = createAdminRpcClients(baseURL);
54
- const res = await clients.orders[':id'].$get({ param: { id: orderId } }, authHeaders(authToken));
56
+ const res = await clients.orders[':id'].$get({ param: { id: orderId } }, authHeaders(token));
55
57
  if (!res.ok) {
56
58
  throw new Error(`Failed to fetch order: ${res.statusText}`);
57
59
  }
@@ -76,12 +78,13 @@ export function useGetOrder(orderId, options) {
76
78
  * ```
77
79
  */
78
80
  export function useCreateOrder(options) {
79
- const { baseURL, authToken } = useApiConfig();
81
+ const { baseURL, getAuthToken } = useApiConfig();
80
82
  const queryClient = useQueryClient();
81
83
  return useMutation({
82
84
  mutationFn: async (data) => {
85
+ const token = await getAuthToken();
83
86
  const clients = createAdminRpcClients(baseURL);
84
- const res = await clients.orders.index.$post({ json: data }, authHeaders(authToken));
87
+ const res = await clients.orders.index.$post({ json: data }, authHeaders(token));
85
88
  if (!res.ok) {
86
89
  throw new Error(`Failed to create order: ${res.statusText}`);
87
90
  }
@@ -100,12 +103,13 @@ export function useCreateOrder(options) {
100
103
  * @param options - React Query mutation options
101
104
  */
102
105
  export function useUpdateOrder(orderId, options) {
103
- const { baseURL, authToken } = useApiConfig();
106
+ const { baseURL, getAuthToken } = useApiConfig();
104
107
  const queryClient = useQueryClient();
105
108
  return useMutation({
106
109
  mutationFn: async (data) => {
110
+ const token = await getAuthToken();
107
111
  const clients = createAdminRpcClients(baseURL);
108
- const res = await clients.orders[':id'].$patch({ param: { id: orderId }, json: data }, authHeaders(authToken));
112
+ const res = await clients.orders[':id'].$patch({ param: { id: orderId }, json: data }, authHeaders(token));
109
113
  if (!res.ok) {
110
114
  throw new Error(`Failed to update order: ${res.statusText}`);
111
115
  }
@@ -125,12 +129,13 @@ export function useUpdateOrder(orderId, options) {
125
129
  * @param options - React Query mutation options
126
130
  */
127
131
  export function useUpdateOrderStatus(orderId, options) {
128
- const { baseURL, authToken } = useApiConfig();
132
+ const { baseURL, getAuthToken } = useApiConfig();
129
133
  const queryClient = useQueryClient();
130
134
  return useMutation({
131
135
  mutationFn: async (data) => {
136
+ const token = await getAuthToken();
132
137
  const clients = createAdminRpcClients(baseURL);
133
- const res = await clients.orders[':id'].status.$patch({ param: { id: orderId }, json: data }, authHeaders(authToken));
138
+ const res = await clients.orders[':id'].status.$patch({ param: { id: orderId }, json: data }, authHeaders(token));
134
139
  if (!res.ok) {
135
140
  throw new Error(`Failed to update order status: ${res.statusText}`);
136
141
  }
@@ -150,12 +155,13 @@ export function useUpdateOrderStatus(orderId, options) {
150
155
  * @param options - React Query mutation options
151
156
  */
152
157
  export function useDeleteOrder(orderId, options) {
153
- const { baseURL, authToken } = useApiConfig();
158
+ const { baseURL, getAuthToken } = useApiConfig();
154
159
  const queryClient = useQueryClient();
155
160
  return useMutation({
156
161
  mutationFn: async () => {
162
+ const token = await getAuthToken();
157
163
  const clients = createAdminRpcClients(baseURL);
158
- const res = await clients.orders[':id'].$delete({ param: { id: orderId } }, authHeaders(authToken));
164
+ const res = await clients.orders[':id'].$delete({ param: { id: orderId } }, authHeaders(token));
159
165
  if (!res.ok) {
160
166
  throw new Error(`Failed to delete order: ${res.statusText}`);
161
167
  }