@instockng/api-client 1.0.5 → 1.0.7
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.
- package/dist/apps/backend/src/lib/meta-capi.d.ts +1 -1
- package/dist/apps/backend/src/lib/meta-capi.js +1 -1
- package/dist/apps/backend/src/lib/order-recovery.d.ts +86 -0
- package/dist/apps/backend/src/lib/order-recovery.js +7 -2
- package/dist/apps/backend/src/notifications/producers/meta-capi-producer.d.ts +7 -0
- package/dist/apps/backend/src/notifications/producers/meta-capi-producer.js +41 -0
- package/dist/apps/backend/src/routes/admin/orders.d.ts +310 -20
- package/dist/apps/backend/src/routes/admin/orders.js +26 -2
- package/dist/apps/backend/src/routes/public/orders.d.ts +288 -6
- package/dist/apps/backend/src/routes/public/orders.js +1 -1
- package/dist/apps/backend/src/validators/order.d.ts +6 -37
- package/dist/apps/backend/src/validators/order.js +6 -7
- package/dist/enum-types.d.ts +8 -0
- package/dist/enum-types.js +5 -0
- package/dist/fetchers/carts.js +5 -0
- package/dist/fetchers/orders.d.ts +258 -1
- package/dist/hooks/admin/abandoned-carts.js +12 -8
- package/dist/hooks/admin/brands.js +15 -10
- package/dist/hooks/admin/customers.js +3 -2
- package/dist/hooks/admin/delivery-zones.js +24 -16
- package/dist/hooks/admin/discount-codes.js +24 -16
- package/dist/hooks/admin/inventory.js +15 -10
- package/dist/hooks/admin/orders.d.ts +285 -3
- package/dist/hooks/admin/orders.js +24 -15
- package/dist/hooks/admin/products.js +15 -10
- package/dist/hooks/admin/stats.js +3 -2
- package/dist/hooks/admin/variants.js +18 -12
- package/dist/hooks/admin/warehouses.js +15 -10
- package/dist/hooks/public/orders.d.ts +258 -1
- package/dist/hooks/useApiConfig.d.ts +2 -1
- package/dist/hooks/useApiConfig.js +2 -2
- package/dist/packages/api-client/src/enum-types.d.ts +8 -0
- package/dist/packages/api-client/src/enum-types.js +5 -0
- package/dist/packages/api-client/src/fetchers/carts.js +5 -0
- package/dist/packages/api-client/src/fetchers/orders.d.ts +258 -1
- package/dist/packages/api-client/src/hooks/admin/orders.d.ts +285 -3
- package/dist/packages/api-client/src/hooks/admin/orders.js +7 -4
- package/dist/packages/api-client/src/hooks/public/orders.d.ts +258 -1
- package/dist/packages/api-client/src/rpc-client.d.ts +891 -319
- package/dist/packages/api-client/src/types.d.ts +1 -4
- package/dist/packages/api-client/src/utils/query-keys.d.ts +1 -1
- package/dist/packages/api-client/src/utils/query-keys.js +1 -1
- package/dist/provider.d.ts +7 -4
- package/dist/provider.js +5 -3
- package/dist/rpc-client.d.ts +891 -319
- package/dist/types.d.ts +1 -0
- package/dist/utils/query-keys.d.ts +1 -1
- package/dist/utils/query-keys.js +1 -1
- package/package.json +1 -1
|
@@ -10,12 +10,13 @@ import { useApiConfig } from '../useApiConfig';
|
|
|
10
10
|
* Hook to search variants across all products using admin RPC
|
|
11
11
|
*/
|
|
12
12
|
export function useSearchVariants(params, options) {
|
|
13
|
-
const { baseURL,
|
|
13
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
14
14
|
return useQueryUnwrapped({
|
|
15
15
|
queryKey: queryKeys.admin.variants.search(params),
|
|
16
16
|
queryFn: async () => {
|
|
17
|
+
const token = await getAuthToken();
|
|
17
18
|
const clients = createAdminRpcClients(baseURL);
|
|
18
|
-
const res = await clients.variants.index.$get({ query: params }, authHeaders(
|
|
19
|
+
const res = await clients.variants.index.$get({ query: params }, authHeaders(token));
|
|
19
20
|
if (!res.ok)
|
|
20
21
|
throw new Error(`Failed to search variants: ${res.statusText}`);
|
|
21
22
|
return res.json();
|
|
@@ -27,12 +28,13 @@ export function useSearchVariants(params, options) {
|
|
|
27
28
|
* Hook to list variants for a specific product using admin RPC
|
|
28
29
|
*/
|
|
29
30
|
export function useListProductVariants(productId, options) {
|
|
30
|
-
const { baseURL,
|
|
31
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
31
32
|
return useQueryUnwrapped({
|
|
32
33
|
queryKey: queryKeys.admin.variants.byProduct(productId),
|
|
33
34
|
queryFn: async () => {
|
|
35
|
+
const token = await getAuthToken();
|
|
34
36
|
const clients = createAdminRpcClients(baseURL);
|
|
35
|
-
const res = await clients.variants.products[':productId'].variants.$get({ param: { productId } }, authHeaders(
|
|
37
|
+
const res = await clients.variants.products[':productId'].variants.$get({ param: { productId } }, authHeaders(token));
|
|
36
38
|
if (!res.ok)
|
|
37
39
|
throw new Error(`Failed to fetch product variants: ${res.statusText}`);
|
|
38
40
|
return res.json();
|
|
@@ -44,12 +46,13 @@ export function useListProductVariants(productId, options) {
|
|
|
44
46
|
* Hook to create a variant for a product using admin RPC
|
|
45
47
|
*/
|
|
46
48
|
export function useCreateVariant(productId, options) {
|
|
47
|
-
const { baseURL,
|
|
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.variants.products[':productId'].variants.$post({ json: data, param: { productId } }, authHeaders(
|
|
55
|
+
const res = await clients.variants.products[':productId'].variants.$post({ json: data, param: { productId } }, authHeaders(token));
|
|
53
56
|
if (!res.ok)
|
|
54
57
|
throw new Error(`Failed to create variant: ${res.statusText}`);
|
|
55
58
|
return res.json();
|
|
@@ -65,12 +68,13 @@ export function useCreateVariant(productId, options) {
|
|
|
65
68
|
* Hook to update a variant using admin RPC
|
|
66
69
|
*/
|
|
67
70
|
export function useUpdateVariant(variantId, options) {
|
|
68
|
-
const { baseURL,
|
|
71
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
69
72
|
const queryClient = useQueryClient();
|
|
70
73
|
return useMutation({
|
|
71
74
|
mutationFn: async (data) => {
|
|
75
|
+
const token = await getAuthToken();
|
|
72
76
|
const clients = createAdminRpcClients(baseURL);
|
|
73
|
-
const res = await clients.variants[':id'].$patch({ json: data, param: { id: variantId } }, authHeaders(
|
|
77
|
+
const res = await clients.variants[':id'].$patch({ json: data, param: { id: variantId } }, authHeaders(token));
|
|
74
78
|
if (!res.ok)
|
|
75
79
|
throw new Error(`Failed to update variant: ${res.statusText}`);
|
|
76
80
|
return res.json();
|
|
@@ -86,12 +90,13 @@ export function useUpdateVariant(variantId, options) {
|
|
|
86
90
|
* Hook to get variant inventory across all warehouses using admin RPC
|
|
87
91
|
*/
|
|
88
92
|
export function useGetVariantInventory(variantId, options) {
|
|
89
|
-
const { baseURL,
|
|
93
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
90
94
|
return useQueryUnwrapped({
|
|
91
95
|
queryKey: queryKeys.admin.variants.inventory(variantId),
|
|
92
96
|
queryFn: async () => {
|
|
97
|
+
const token = await getAuthToken();
|
|
93
98
|
const clients = createAdminRpcClients(baseURL);
|
|
94
|
-
const res = await clients.variants[':id'].inventory.$get({ param: { id: variantId } }, authHeaders(
|
|
99
|
+
const res = await clients.variants[':id'].inventory.$get({ param: { id: variantId } }, authHeaders(token));
|
|
95
100
|
if (!res.ok)
|
|
96
101
|
throw new Error(`Failed to fetch variant inventory: ${res.statusText}`);
|
|
97
102
|
return res.json();
|
|
@@ -103,12 +108,13 @@ export function useGetVariantInventory(variantId, options) {
|
|
|
103
108
|
* Hook to delete a variant using admin RPC
|
|
104
109
|
*/
|
|
105
110
|
export function useDeleteVariant(variantId, options) {
|
|
106
|
-
const { baseURL,
|
|
111
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
107
112
|
const queryClient = useQueryClient();
|
|
108
113
|
return useMutation({
|
|
109
114
|
mutationFn: async () => {
|
|
115
|
+
const token = await getAuthToken();
|
|
110
116
|
const clients = createAdminRpcClients(baseURL);
|
|
111
|
-
const res = await clients.variants[':id'].$delete({ param: { id: variantId } }, authHeaders(
|
|
117
|
+
const res = await clients.variants[':id'].$delete({ param: { id: variantId } }, authHeaders(token));
|
|
112
118
|
if (!res.ok)
|
|
113
119
|
throw new Error(`Failed to delete variant: ${res.statusText}`);
|
|
114
120
|
return res.json();
|
|
@@ -10,12 +10,13 @@ import { useApiConfig } from '../useApiConfig';
|
|
|
10
10
|
* Hook to list all warehouses using admin RPC
|
|
11
11
|
*/
|
|
12
12
|
export function useListWarehouses(options) {
|
|
13
|
-
const { baseURL,
|
|
13
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
14
14
|
return useQueryUnwrapped({
|
|
15
15
|
queryKey: queryKeys.admin.warehouses.list(),
|
|
16
16
|
queryFn: async () => {
|
|
17
|
+
const token = await getAuthToken();
|
|
17
18
|
const clients = createAdminRpcClients(baseURL);
|
|
18
|
-
const res = await clients.warehouses.index.$get({}, authHeaders(
|
|
19
|
+
const res = await clients.warehouses.index.$get({}, authHeaders(token));
|
|
19
20
|
if (!res.ok)
|
|
20
21
|
throw new Error(`Failed to fetch warehouses: ${res.statusText}`);
|
|
21
22
|
return res.json();
|
|
@@ -27,12 +28,13 @@ export function useListWarehouses(options) {
|
|
|
27
28
|
* Hook to create a warehouse using admin RPC
|
|
28
29
|
*/
|
|
29
30
|
export function useCreateWarehouse(options) {
|
|
30
|
-
const { baseURL,
|
|
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.warehouses.index.$post({ json: data }, authHeaders(
|
|
37
|
+
const res = await clients.warehouses.index.$post({ json: data }, authHeaders(token));
|
|
36
38
|
if (!res.ok)
|
|
37
39
|
throw new Error(`Failed to create warehouse: ${res.statusText}`);
|
|
38
40
|
return res.json();
|
|
@@ -47,12 +49,13 @@ export function useCreateWarehouse(options) {
|
|
|
47
49
|
* Hook to update a warehouse using admin RPC
|
|
48
50
|
*/
|
|
49
51
|
export function useUpdateWarehouse(warehouseId, options) {
|
|
50
|
-
const { baseURL,
|
|
52
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
51
53
|
const queryClient = useQueryClient();
|
|
52
54
|
return useMutation({
|
|
53
55
|
mutationFn: async (data) => {
|
|
56
|
+
const token = await getAuthToken();
|
|
54
57
|
const clients = createAdminRpcClients(baseURL);
|
|
55
|
-
const res = await clients.warehouses[':id'].$patch({ json: data, param: { id: warehouseId } }, authHeaders(
|
|
58
|
+
const res = await clients.warehouses[':id'].$patch({ json: data, param: { id: warehouseId } }, authHeaders(token));
|
|
56
59
|
if (!res.ok)
|
|
57
60
|
throw new Error(`Failed to update warehouse: ${res.statusText}`);
|
|
58
61
|
return res.json();
|
|
@@ -68,12 +71,13 @@ export function useUpdateWarehouse(warehouseId, options) {
|
|
|
68
71
|
* Hook to get warehouse inventory using admin RPC
|
|
69
72
|
*/
|
|
70
73
|
export function useGetWarehouseInventory(warehouseId, options) {
|
|
71
|
-
const { baseURL,
|
|
74
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
72
75
|
return useQueryUnwrapped({
|
|
73
76
|
queryKey: queryKeys.admin.warehouses.inventory(warehouseId),
|
|
74
77
|
queryFn: async () => {
|
|
78
|
+
const token = await getAuthToken();
|
|
75
79
|
const clients = createAdminRpcClients(baseURL);
|
|
76
|
-
const res = await clients.warehouses[':id'].inventory.$get({ param: { id: warehouseId } }, authHeaders(
|
|
80
|
+
const res = await clients.warehouses[':id'].inventory.$get({ param: { id: warehouseId } }, authHeaders(token));
|
|
77
81
|
if (!res.ok)
|
|
78
82
|
throw new Error(`Failed to fetch warehouse inventory: ${res.statusText}`);
|
|
79
83
|
return res.json();
|
|
@@ -85,12 +89,13 @@ export function useGetWarehouseInventory(warehouseId, options) {
|
|
|
85
89
|
* Hook to delete a warehouse using admin RPC
|
|
86
90
|
*/
|
|
87
91
|
export function useDeleteWarehouse(warehouseId, options) {
|
|
88
|
-
const { baseURL,
|
|
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.warehouses[':id'].$delete({ param: { id: warehouseId } }, authHeaders(
|
|
98
|
+
const res = await clients.warehouses[':id'].$delete({ param: { id: warehouseId } }, authHeaders(token));
|
|
94
99
|
if (!res.ok)
|
|
95
100
|
throw new Error(`Failed to delete warehouse: ${res.statusText}`);
|
|
96
101
|
return res.json();
|
|
@@ -296,7 +296,264 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
|
|
|
296
296
|
export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<ReturnType<typeof confirmOrder>>, Error, {
|
|
297
297
|
orderId: string;
|
|
298
298
|
token: string;
|
|
299
|
-
}>): import("@tanstack/react-query").UseMutationResult<
|
|
299
|
+
}>): import("@tanstack/react-query").UseMutationResult<{
|
|
300
|
+
subtotal: number;
|
|
301
|
+
deliveryCharge: number;
|
|
302
|
+
totalPrice: number;
|
|
303
|
+
discountAmount: number;
|
|
304
|
+
createdAt: string;
|
|
305
|
+
updatedAt: string;
|
|
306
|
+
deletedAt: string;
|
|
307
|
+
prospectSince: string;
|
|
308
|
+
lastRecoveryAttemptAt: string;
|
|
309
|
+
brand: {
|
|
310
|
+
createdAt: string;
|
|
311
|
+
updatedAt: string;
|
|
312
|
+
deletedAt: string;
|
|
313
|
+
name: string;
|
|
314
|
+
id: string;
|
|
315
|
+
slug: string;
|
|
316
|
+
logoUrl: string | null;
|
|
317
|
+
siteUrl: string;
|
|
318
|
+
domain: string;
|
|
319
|
+
metaPixelId: string | null;
|
|
320
|
+
};
|
|
321
|
+
deliveryZone: {
|
|
322
|
+
deliveryCost: number;
|
|
323
|
+
freeShippingThreshold: number;
|
|
324
|
+
createdAt: string;
|
|
325
|
+
updatedAt: string;
|
|
326
|
+
deletedAt: string;
|
|
327
|
+
state: {
|
|
328
|
+
createdAt: string;
|
|
329
|
+
updatedAt: string;
|
|
330
|
+
deletedAt: string;
|
|
331
|
+
name: string;
|
|
332
|
+
id: string;
|
|
333
|
+
isActive: boolean;
|
|
334
|
+
};
|
|
335
|
+
name: string;
|
|
336
|
+
id: string;
|
|
337
|
+
brandId: string | null;
|
|
338
|
+
stateId: string;
|
|
339
|
+
allowCOD: boolean;
|
|
340
|
+
allowOnline: boolean;
|
|
341
|
+
waybillOnly: boolean;
|
|
342
|
+
estimatedDays: number | null;
|
|
343
|
+
isActive: boolean;
|
|
344
|
+
};
|
|
345
|
+
items: {
|
|
346
|
+
priceAtPurchase: number;
|
|
347
|
+
variant: {
|
|
348
|
+
price: number;
|
|
349
|
+
createdAt: string;
|
|
350
|
+
updatedAt: string;
|
|
351
|
+
deletedAt: string;
|
|
352
|
+
product: {
|
|
353
|
+
createdAt: string;
|
|
354
|
+
updatedAt: string;
|
|
355
|
+
deletedAt: string;
|
|
356
|
+
name: string;
|
|
357
|
+
id: string;
|
|
358
|
+
slug: string;
|
|
359
|
+
brandId: string;
|
|
360
|
+
isActive: boolean;
|
|
361
|
+
description: string | null;
|
|
362
|
+
thumbnailUrl: string | null;
|
|
363
|
+
quantityDiscounts: string | number | boolean | {
|
|
364
|
+
[x: string]: string | number | boolean | /*elided*/ any | {
|
|
365
|
+
[x: number]: string | number | boolean | /*elided*/ any | /*elided*/ any;
|
|
366
|
+
length: number;
|
|
367
|
+
toString: never;
|
|
368
|
+
toLocaleString: never;
|
|
369
|
+
pop: never;
|
|
370
|
+
push: never;
|
|
371
|
+
concat: never;
|
|
372
|
+
join: never;
|
|
373
|
+
reverse: never;
|
|
374
|
+
shift: never;
|
|
375
|
+
slice: never;
|
|
376
|
+
sort: never;
|
|
377
|
+
splice: never;
|
|
378
|
+
unshift: never;
|
|
379
|
+
indexOf: never;
|
|
380
|
+
lastIndexOf: never;
|
|
381
|
+
every: never;
|
|
382
|
+
some: never;
|
|
383
|
+
forEach: never;
|
|
384
|
+
map: never;
|
|
385
|
+
filter: never;
|
|
386
|
+
reduce: never;
|
|
387
|
+
reduceRight: never;
|
|
388
|
+
find: never;
|
|
389
|
+
findIndex: never;
|
|
390
|
+
fill: never;
|
|
391
|
+
copyWithin: never;
|
|
392
|
+
entries: never;
|
|
393
|
+
keys: never;
|
|
394
|
+
values: never;
|
|
395
|
+
includes: never;
|
|
396
|
+
flatMap: never;
|
|
397
|
+
flat: never;
|
|
398
|
+
[Symbol.iterator]: never;
|
|
399
|
+
readonly [Symbol.unscopables]: {
|
|
400
|
+
[x: number]: boolean;
|
|
401
|
+
length?: boolean;
|
|
402
|
+
toString?: boolean;
|
|
403
|
+
toLocaleString?: boolean;
|
|
404
|
+
pop?: boolean;
|
|
405
|
+
push?: boolean;
|
|
406
|
+
concat?: boolean;
|
|
407
|
+
join?: boolean;
|
|
408
|
+
reverse?: boolean;
|
|
409
|
+
shift?: boolean;
|
|
410
|
+
slice?: boolean;
|
|
411
|
+
sort?: boolean;
|
|
412
|
+
splice?: boolean;
|
|
413
|
+
unshift?: boolean;
|
|
414
|
+
indexOf?: boolean;
|
|
415
|
+
lastIndexOf?: boolean;
|
|
416
|
+
every?: boolean;
|
|
417
|
+
some?: boolean;
|
|
418
|
+
forEach?: boolean;
|
|
419
|
+
map?: boolean;
|
|
420
|
+
filter?: boolean;
|
|
421
|
+
reduce?: boolean;
|
|
422
|
+
reduceRight?: boolean;
|
|
423
|
+
find?: boolean;
|
|
424
|
+
findIndex?: boolean;
|
|
425
|
+
fill?: boolean;
|
|
426
|
+
copyWithin?: boolean;
|
|
427
|
+
entries?: boolean;
|
|
428
|
+
keys?: boolean;
|
|
429
|
+
values?: boolean;
|
|
430
|
+
includes?: boolean;
|
|
431
|
+
flatMap?: boolean;
|
|
432
|
+
flat?: boolean;
|
|
433
|
+
};
|
|
434
|
+
};
|
|
435
|
+
} | {
|
|
436
|
+
[x: number]: string | number | boolean | {
|
|
437
|
+
[x: string]: string | number | boolean | /*elided*/ any | /*elided*/ any;
|
|
438
|
+
} | /*elided*/ any;
|
|
439
|
+
length: number;
|
|
440
|
+
toString: never;
|
|
441
|
+
toLocaleString: never;
|
|
442
|
+
pop: never;
|
|
443
|
+
push: never;
|
|
444
|
+
concat: never;
|
|
445
|
+
join: never;
|
|
446
|
+
reverse: never;
|
|
447
|
+
shift: never;
|
|
448
|
+
slice: never;
|
|
449
|
+
sort: never;
|
|
450
|
+
splice: never;
|
|
451
|
+
unshift: never;
|
|
452
|
+
indexOf: never;
|
|
453
|
+
lastIndexOf: never;
|
|
454
|
+
every: never;
|
|
455
|
+
some: never;
|
|
456
|
+
forEach: never;
|
|
457
|
+
map: never;
|
|
458
|
+
filter: never;
|
|
459
|
+
reduce: never;
|
|
460
|
+
reduceRight: never;
|
|
461
|
+
find: never;
|
|
462
|
+
findIndex: never;
|
|
463
|
+
fill: never;
|
|
464
|
+
copyWithin: never;
|
|
465
|
+
entries: never;
|
|
466
|
+
keys: never;
|
|
467
|
+
values: never;
|
|
468
|
+
includes: never;
|
|
469
|
+
flatMap: never;
|
|
470
|
+
flat: never;
|
|
471
|
+
[Symbol.iterator]: never;
|
|
472
|
+
readonly [Symbol.unscopables]: {
|
|
473
|
+
[x: number]: boolean;
|
|
474
|
+
length?: boolean;
|
|
475
|
+
toString?: boolean;
|
|
476
|
+
toLocaleString?: boolean;
|
|
477
|
+
pop?: boolean;
|
|
478
|
+
push?: boolean;
|
|
479
|
+
concat?: boolean;
|
|
480
|
+
join?: boolean;
|
|
481
|
+
reverse?: boolean;
|
|
482
|
+
shift?: boolean;
|
|
483
|
+
slice?: boolean;
|
|
484
|
+
sort?: boolean;
|
|
485
|
+
splice?: boolean;
|
|
486
|
+
unshift?: boolean;
|
|
487
|
+
indexOf?: boolean;
|
|
488
|
+
lastIndexOf?: boolean;
|
|
489
|
+
every?: boolean;
|
|
490
|
+
some?: boolean;
|
|
491
|
+
forEach?: boolean;
|
|
492
|
+
map?: boolean;
|
|
493
|
+
filter?: boolean;
|
|
494
|
+
reduce?: boolean;
|
|
495
|
+
reduceRight?: boolean;
|
|
496
|
+
find?: boolean;
|
|
497
|
+
findIndex?: boolean;
|
|
498
|
+
fill?: boolean;
|
|
499
|
+
copyWithin?: boolean;
|
|
500
|
+
entries?: boolean;
|
|
501
|
+
keys?: boolean;
|
|
502
|
+
values?: boolean;
|
|
503
|
+
includes?: boolean;
|
|
504
|
+
flatMap?: boolean;
|
|
505
|
+
flat?: boolean;
|
|
506
|
+
};
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
name: string | null;
|
|
510
|
+
id: string;
|
|
511
|
+
isActive: boolean;
|
|
512
|
+
thumbnailUrl: string | null;
|
|
513
|
+
productId: string;
|
|
514
|
+
sku: string;
|
|
515
|
+
trackInventory: boolean;
|
|
516
|
+
lowStockThreshold: number | null;
|
|
517
|
+
};
|
|
518
|
+
warehouse: {
|
|
519
|
+
createdAt: string;
|
|
520
|
+
updatedAt: string;
|
|
521
|
+
deletedAt: string;
|
|
522
|
+
name: string;
|
|
523
|
+
id: string;
|
|
524
|
+
isActive: boolean;
|
|
525
|
+
address: string | null;
|
|
526
|
+
city: string | null;
|
|
527
|
+
state: string | null;
|
|
528
|
+
};
|
|
529
|
+
id: string;
|
|
530
|
+
orderId: string;
|
|
531
|
+
variantId: string;
|
|
532
|
+
warehouseId: string | null;
|
|
533
|
+
quantity: number;
|
|
534
|
+
}[];
|
|
535
|
+
id: string;
|
|
536
|
+
email: string | null;
|
|
537
|
+
brandId: string;
|
|
538
|
+
deliveryZoneId: string;
|
|
539
|
+
recoveryAttempts: number;
|
|
540
|
+
recoveryDiscountCodeId: string | null;
|
|
541
|
+
wasRecovered: boolean;
|
|
542
|
+
estimatedDays: number | null;
|
|
543
|
+
orderNumber: number;
|
|
544
|
+
firstName: string;
|
|
545
|
+
lastName: string;
|
|
546
|
+
phone: string;
|
|
547
|
+
address: string;
|
|
548
|
+
city: string;
|
|
549
|
+
discountCodeId: string | null;
|
|
550
|
+
paymentMethod: import("@prisma/client").$Enums.PaymentMethod;
|
|
551
|
+
paystackReference: string | null;
|
|
552
|
+
status: import("@prisma/client").$Enums.OrderStatus;
|
|
553
|
+
cancellationReason: string | null;
|
|
554
|
+
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
555
|
+
userActionToken: string;
|
|
556
|
+
}, Error, {
|
|
300
557
|
orderId: string;
|
|
301
558
|
token: string;
|
|
302
559
|
}, unknown>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Hook to access API configuration from context
|
|
3
3
|
*/
|
|
4
|
+
import { type AuthTokenGetter } from '../provider';
|
|
4
5
|
export interface ApiConfig {
|
|
5
6
|
baseURL: string;
|
|
6
|
-
|
|
7
|
+
getAuthToken: AuthTokenGetter;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Get API configuration from context
|
|
@@ -6,9 +6,9 @@ import { useApiClientContext } from '../provider';
|
|
|
6
6
|
* Get API configuration from context
|
|
7
7
|
*/
|
|
8
8
|
export function useApiConfig() {
|
|
9
|
-
const { baseURL,
|
|
9
|
+
const { baseURL, getAuthToken } = useApiClientContext();
|
|
10
10
|
return {
|
|
11
11
|
baseURL,
|
|
12
|
-
|
|
12
|
+
getAuthToken,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
@@ -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];
|
|
@@ -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) {
|