@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.
- package/dist/enum-types.d.ts +8 -0
- package/dist/enum-types.js +5 -0
- package/dist/fetchers/carts.js +5 -0
- 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.js +18 -12
- 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/useApiConfig.d.ts +2 -1
- package/dist/hooks/useApiConfig.js +2 -2
- package/dist/provider.d.ts +7 -4
- package/dist/provider.js +5 -3
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/apps/backend/src/generated/zod/index.d.ts +0 -1114
- package/dist/apps/backend/src/generated/zod/index.js +0 -670
- package/dist/apps/backend/src/http-app.d.ts +0 -40
- package/dist/apps/backend/src/http-app.js +0 -106
- package/dist/apps/backend/src/lib/brand-response.d.ts +0 -14
- package/dist/apps/backend/src/lib/brand-response.js +0 -8
- package/dist/apps/backend/src/lib/cart-helpers.d.ts +0 -280
- package/dist/apps/backend/src/lib/cart-helpers.js +0 -93
- package/dist/apps/backend/src/lib/cart-recovery.d.ts +0 -30
- package/dist/apps/backend/src/lib/cart-recovery.js +0 -147
- package/dist/apps/backend/src/lib/cart-response.d.ts +0 -121
- package/dist/apps/backend/src/lib/cart-response.js +0 -150
- package/dist/apps/backend/src/lib/clerk.d.ts +0 -18
- package/dist/apps/backend/src/lib/clerk.js +0 -167
- package/dist/apps/backend/src/lib/delivery-zone-response.d.ts +0 -62
- package/dist/apps/backend/src/lib/delivery-zone-response.js +0 -24
- package/dist/apps/backend/src/lib/discount-code-response.d.ts +0 -42
- package/dist/apps/backend/src/lib/discount-code-response.js +0 -19
- package/dist/apps/backend/src/lib/discount.d.ts +0 -20
- package/dist/apps/backend/src/lib/discount.js +0 -35
- package/dist/apps/backend/src/lib/inventory.d.ts +0 -26
- package/dist/apps/backend/src/lib/inventory.js +0 -160
- package/dist/apps/backend/src/lib/meta-capi.d.ts +0 -48
- package/dist/apps/backend/src/lib/meta-capi.js +0 -120
- package/dist/apps/backend/src/lib/openapi.d.ts +0 -36
- package/dist/apps/backend/src/lib/openapi.js +0 -69
- package/dist/apps/backend/src/lib/order-recovery.d.ts +0 -367
- package/dist/apps/backend/src/lib/order-recovery.js +0 -373
- package/dist/apps/backend/src/lib/order-response.d.ts +0 -136
- package/dist/apps/backend/src/lib/order-response.js +0 -61
- package/dist/apps/backend/src/lib/pricing.d.ts +0 -39
- package/dist/apps/backend/src/lib/pricing.js +0 -62
- package/dist/apps/backend/src/lib/prisma.d.ts +0 -9
- package/dist/apps/backend/src/lib/prisma.js +0 -30
- package/dist/apps/backend/src/lib/product-response.d.ts +0 -82
- package/dist/apps/backend/src/lib/product-response.js +0 -29
- package/dist/apps/backend/src/lib/utils.d.ts +0 -32
- package/dist/apps/backend/src/lib/utils.js +0 -63
- package/dist/apps/backend/src/middleware/clerk-auth.d.ts +0 -8
- package/dist/apps/backend/src/middleware/clerk-auth.js +0 -89
- package/dist/apps/backend/src/middleware/cors.d.ts +0 -8
- package/dist/apps/backend/src/middleware/cors.js +0 -11
- package/dist/apps/backend/src/notifications/producers/meta-capi-producer.d.ts +0 -55
- package/dist/apps/backend/src/notifications/producers/meta-capi-producer.js +0 -125
- package/dist/apps/backend/src/notifications/producers/order-notification.d.ts +0 -9
- package/dist/apps/backend/src/notifications/producers/order-notification.js +0 -18
- package/dist/apps/backend/src/notifications/producers/prospect-recovery-notification.d.ts +0 -10
- package/dist/apps/backend/src/notifications/producers/prospect-recovery-notification.js +0 -11
- package/dist/apps/backend/src/routes/admin/abandoned-carts.d.ts +0 -605
- package/dist/apps/backend/src/routes/admin/abandoned-carts.js +0 -194
- package/dist/apps/backend/src/routes/admin/brands.d.ts +0 -175
- package/dist/apps/backend/src/routes/admin/brands.js +0 -118
- package/dist/apps/backend/src/routes/admin/customers.d.ts +0 -306
- package/dist/apps/backend/src/routes/admin/customers.js +0 -39
- package/dist/apps/backend/src/routes/admin/delivery-zones.d.ts +0 -438
- package/dist/apps/backend/src/routes/admin/delivery-zones.js +0 -300
- package/dist/apps/backend/src/routes/admin/discount-codes.d.ts +0 -478
- package/dist/apps/backend/src/routes/admin/discount-codes.js +0 -418
- package/dist/apps/backend/src/routes/admin/inventory.d.ts +0 -273
- package/dist/apps/backend/src/routes/admin/inventory.js +0 -189
- package/dist/apps/backend/src/routes/admin/orders.d.ts +0 -1478
- package/dist/apps/backend/src/routes/admin/orders.js +0 -503
- package/dist/apps/backend/src/routes/admin/products.d.ts +0 -860
- package/dist/apps/backend/src/routes/admin/products.js +0 -107
- package/dist/apps/backend/src/routes/admin/stats.d.ts +0 -288
- package/dist/apps/backend/src/routes/admin/stats.js +0 -55
- package/dist/apps/backend/src/routes/admin/variants.d.ts +0 -239
- package/dist/apps/backend/src/routes/admin/variants.js +0 -173
- package/dist/apps/backend/src/routes/admin/warehouses.d.ts +0 -373
- package/dist/apps/backend/src/routes/admin/warehouses.js +0 -123
- package/dist/apps/backend/src/routes/public/brands.d.ts +0 -40
- package/dist/apps/backend/src/routes/public/brands.js +0 -38
- package/dist/apps/backend/src/routes/public/carts.d.ts +0 -2655
- package/dist/apps/backend/src/routes/public/carts.js +0 -631
- package/dist/apps/backend/src/routes/public/delivery-zones.d.ts +0 -35
- package/dist/apps/backend/src/routes/public/delivery-zones.js +0 -62
- package/dist/apps/backend/src/routes/public/orders.d.ts +0 -323
- package/dist/apps/backend/src/routes/public/orders.js +0 -160
- package/dist/apps/backend/src/routes/public/products.d.ts +0 -449
- package/dist/apps/backend/src/routes/public/products.js +0 -133
- package/dist/apps/backend/src/types/index.d.ts +0 -42
- package/dist/apps/backend/src/types/index.js +0 -2
- package/dist/apps/backend/src/validators/brand.d.ts +0 -17
- package/dist/apps/backend/src/validators/brand.js +0 -15
- package/dist/apps/backend/src/validators/delivery-zone.d.ts +0 -31
- package/dist/apps/backend/src/validators/delivery-zone.js +0 -51
- package/dist/apps/backend/src/validators/discount-code.d.ts +0 -74
- package/dist/apps/backend/src/validators/discount-code.js +0 -50
- package/dist/apps/backend/src/validators/inventory.d.ts +0 -20
- package/dist/apps/backend/src/validators/inventory.js +0 -15
- package/dist/apps/backend/src/validators/order.d.ts +0 -87
- package/dist/apps/backend/src/validators/order.js +0 -61
- package/dist/apps/backend/src/validators/product.d.ts +0 -18
- package/dist/apps/backend/src/validators/product.js +0 -19
- package/dist/apps/backend/src/validators/variant.d.ts +0 -19
- package/dist/apps/backend/src/validators/variant.js +0 -19
- package/dist/apps/backend/src/validators/warehouse.d.ts +0 -15
- package/dist/apps/backend/src/validators/warehouse.js +0 -15
- package/dist/packages/api-client/src/backend-types.d.ts +0 -10
- package/dist/packages/api-client/src/backend-types.js +0 -10
- package/dist/packages/api-client/src/client.d.ts +0 -20
- package/dist/packages/api-client/src/client.js +0 -40
- package/dist/packages/api-client/src/fetchers/brands.d.ts +0 -25
- package/dist/packages/api-client/src/fetchers/brands.js +0 -26
- package/dist/packages/api-client/src/fetchers/carts.d.ts +0 -2335
- package/dist/packages/api-client/src/fetchers/carts.js +0 -169
- package/dist/packages/api-client/src/fetchers/delivery-zones.d.ts +0 -28
- package/dist/packages/api-client/src/fetchers/delivery-zones.js +0 -26
- package/dist/packages/api-client/src/fetchers/index.d.ts +0 -22
- package/dist/packages/api-client/src/fetchers/index.js +0 -22
- package/dist/packages/api-client/src/fetchers/orders.d.ts +0 -283
- package/dist/packages/api-client/src/fetchers/orders.js +0 -44
- package/dist/packages/api-client/src/fetchers/products.d.ts +0 -386
- package/dist/packages/api-client/src/fetchers/products.js +0 -42
- package/dist/packages/api-client/src/hooks/admin/abandoned-carts.d.ts +0 -535
- package/dist/packages/api-client/src/hooks/admin/abandoned-carts.js +0 -83
- package/dist/packages/api-client/src/hooks/admin/brands.d.ts +0 -79
- package/dist/packages/api-client/src/hooks/admin/brands.js +0 -108
- package/dist/packages/api-client/src/hooks/admin/customers.d.ts +0 -278
- package/dist/packages/api-client/src/hooks/admin/customers.js +0 -26
- package/dist/packages/api-client/src/hooks/admin/delivery-zones.d.ts +0 -270
- package/dist/packages/api-client/src/hooks/admin/delivery-zones.js +0 -176
- package/dist/packages/api-client/src/hooks/admin/discount-codes.d.ts +0 -299
- package/dist/packages/api-client/src/hooks/admin/discount-codes.js +0 -165
- package/dist/packages/api-client/src/hooks/admin/index.d.ts +0 -16
- package/dist/packages/api-client/src/hooks/admin/index.js +0 -16
- package/dist/packages/api-client/src/hooks/admin/inventory.d.ts +0 -224
- package/dist/packages/api-client/src/hooks/admin/inventory.js +0 -107
- package/dist/packages/api-client/src/hooks/admin/orders.d.ts +0 -1380
- package/dist/packages/api-client/src/hooks/admin/orders.js +0 -175
- package/dist/packages/api-client/src/hooks/admin/products.d.ts +0 -374
- package/dist/packages/api-client/src/hooks/admin/products.js +0 -89
- package/dist/packages/api-client/src/hooks/admin/stats.d.ts +0 -277
- package/dist/packages/api-client/src/hooks/admin/stats.js +0 -25
- package/dist/packages/api-client/src/hooks/admin/variants.d.ts +0 -115
- package/dist/packages/api-client/src/hooks/admin/variants.js +0 -127
- package/dist/packages/api-client/src/hooks/admin/warehouses.d.ts +0 -277
- package/dist/packages/api-client/src/hooks/admin/warehouses.js +0 -108
- package/dist/packages/api-client/src/hooks/public/brands.d.ts +0 -33
- package/dist/packages/api-client/src/hooks/public/brands.js +0 -30
- package/dist/packages/api-client/src/hooks/public/carts.d.ts +0 -2405
- package/dist/packages/api-client/src/hooks/public/carts.js +0 -213
- package/dist/packages/api-client/src/hooks/public/delivery-zones.d.ts +0 -34
- package/dist/packages/api-client/src/hooks/public/delivery-zones.js +0 -28
- package/dist/packages/api-client/src/hooks/public/index.d.ts +0 -10
- package/dist/packages/api-client/src/hooks/public/index.js +0 -10
- package/dist/packages/api-client/src/hooks/public/orders.d.ts +0 -302
- package/dist/packages/api-client/src/hooks/public/orders.js +0 -50
- package/dist/packages/api-client/src/hooks/public/products.d.ts +0 -398
- package/dist/packages/api-client/src/hooks/public/products.js +0 -47
- package/dist/packages/api-client/src/hooks/use-query-unwrapped.d.ts +0 -20
- package/dist/packages/api-client/src/hooks/use-query-unwrapped.js +0 -22
- package/dist/packages/api-client/src/hooks/useApiConfig.d.ts +0 -12
- package/dist/packages/api-client/src/hooks/useApiConfig.js +0 -14
- package/dist/packages/api-client/src/index.d.ts +0 -20
- package/dist/packages/api-client/src/index.js +0 -25
- package/dist/packages/api-client/src/provider.d.ts +0 -36
- package/dist/packages/api-client/src/provider.js +0 -54
- package/dist/packages/api-client/src/rpc-client.d.ts +0 -9035
- package/dist/packages/api-client/src/rpc-client.js +0 -78
- package/dist/packages/api-client/src/rpc-types.d.ts +0 -76
- package/dist/packages/api-client/src/rpc-types.js +0 -7
- package/dist/packages/api-client/src/types.d.ts +0 -37
- package/dist/packages/api-client/src/types.js +0 -16
- package/dist/packages/api-client/src/utils/query-keys.d.ts +0 -106
- package/dist/packages/api-client/src/utils/query-keys.js +0 -108
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export const createStateSchema = z.object({
|
|
3
|
-
name: z.string().min(1),
|
|
4
|
-
isActive: z.boolean().optional(),
|
|
5
|
-
});
|
|
6
|
-
export const updateStateSchema = z.object({
|
|
7
|
-
name: z.string().min(1).optional(),
|
|
8
|
-
isActive: z.boolean().optional(),
|
|
9
|
-
});
|
|
10
|
-
export const createDeliveryZoneSchema = z
|
|
11
|
-
.object({
|
|
12
|
-
stateId: z.uuid(),
|
|
13
|
-
brandId: z.uuid().nullable().optional(),
|
|
14
|
-
name: z.string().min(1),
|
|
15
|
-
deliveryCost: z.number().nonnegative(),
|
|
16
|
-
freeShippingThreshold: z.number().nonnegative().nullable().optional(),
|
|
17
|
-
allowCOD: z.boolean().optional(),
|
|
18
|
-
allowOnline: z.boolean().optional(),
|
|
19
|
-
waybillOnly: z.boolean().optional(),
|
|
20
|
-
estimatedDays: z.number().int().positive().nullable().optional(),
|
|
21
|
-
isActive: z.boolean().optional(),
|
|
22
|
-
})
|
|
23
|
-
.refine((data) => {
|
|
24
|
-
// If waybillOnly is true, allowCOD must be false
|
|
25
|
-
if (data.waybillOnly && data.allowCOD !== false) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
return true;
|
|
29
|
-
}, {
|
|
30
|
-
message: 'When waybillOnly is true, allowCOD must be false',
|
|
31
|
-
});
|
|
32
|
-
export const updateDeliveryZoneSchema = z
|
|
33
|
-
.object({
|
|
34
|
-
name: z.string().min(1).optional(),
|
|
35
|
-
deliveryCost: z.number().nonnegative().optional(),
|
|
36
|
-
freeShippingThreshold: z.number().nonnegative().nullable().optional(),
|
|
37
|
-
allowCOD: z.boolean().optional(),
|
|
38
|
-
allowOnline: z.boolean().optional(),
|
|
39
|
-
waybillOnly: z.boolean().optional(),
|
|
40
|
-
estimatedDays: z.number().int().positive().nullable().optional(),
|
|
41
|
-
isActive: z.boolean().optional(),
|
|
42
|
-
})
|
|
43
|
-
.refine((data) => {
|
|
44
|
-
// If waybillOnly is being set to true, allowCOD must be false
|
|
45
|
-
if (data.waybillOnly && data.allowCOD !== false && data.allowCOD !== undefined) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
return true;
|
|
49
|
-
}, {
|
|
50
|
-
message: 'When waybillOnly is true, allowCOD must be false',
|
|
51
|
-
});
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const createDiscountCodeSchema: z.ZodObject<{
|
|
3
|
-
code: z.ZodString;
|
|
4
|
-
brandId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
5
|
-
type: z.ZodEnum<{
|
|
6
|
-
fixed: "fixed";
|
|
7
|
-
percentage: "percentage";
|
|
8
|
-
}>;
|
|
9
|
-
value: z.ZodNumber;
|
|
10
|
-
description: z.ZodOptional<z.ZodString>;
|
|
11
|
-
category: z.ZodDefault<z.ZodEnum<{
|
|
12
|
-
recovery: "recovery";
|
|
13
|
-
manual: "manual";
|
|
14
|
-
influencer: "influencer";
|
|
15
|
-
seasonal: "seasonal";
|
|
16
|
-
referral: "referral";
|
|
17
|
-
}>>;
|
|
18
|
-
minPurchase: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
19
|
-
maxDiscount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
20
|
-
usageLimit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
21
|
-
perCustomerLimit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
22
|
-
validFrom: z.ZodOptional<z.ZodString>;
|
|
23
|
-
validUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
24
|
-
isActive: z.ZodDefault<z.ZodBoolean>;
|
|
25
|
-
isAutoApply: z.ZodDefault<z.ZodBoolean>;
|
|
26
|
-
}, z.core.$strip>;
|
|
27
|
-
export declare const updateDiscountCodeSchema: z.ZodObject<{
|
|
28
|
-
code: z.ZodOptional<z.ZodString>;
|
|
29
|
-
type: z.ZodOptional<z.ZodEnum<{
|
|
30
|
-
fixed: "fixed";
|
|
31
|
-
percentage: "percentage";
|
|
32
|
-
}>>;
|
|
33
|
-
value: z.ZodOptional<z.ZodNumber>;
|
|
34
|
-
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
|
-
category: z.ZodOptional<z.ZodEnum<{
|
|
36
|
-
recovery: "recovery";
|
|
37
|
-
manual: "manual";
|
|
38
|
-
influencer: "influencer";
|
|
39
|
-
seasonal: "seasonal";
|
|
40
|
-
referral: "referral";
|
|
41
|
-
}>>;
|
|
42
|
-
minPurchase: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
43
|
-
maxDiscount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
44
|
-
usageLimit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
45
|
-
perCustomerLimit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
46
|
-
validFrom: z.ZodOptional<z.ZodString>;
|
|
47
|
-
validUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
48
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
-
isAutoApply: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
-
}, z.core.$strip>;
|
|
51
|
-
export declare const bulkGenerateCodesSchema: z.ZodObject<{
|
|
52
|
-
prefix: z.ZodString;
|
|
53
|
-
count: z.ZodNumber;
|
|
54
|
-
brandId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
55
|
-
type: z.ZodEnum<{
|
|
56
|
-
fixed: "fixed";
|
|
57
|
-
percentage: "percentage";
|
|
58
|
-
}>;
|
|
59
|
-
value: z.ZodNumber;
|
|
60
|
-
description: z.ZodOptional<z.ZodString>;
|
|
61
|
-
category: z.ZodDefault<z.ZodEnum<{
|
|
62
|
-
recovery: "recovery";
|
|
63
|
-
manual: "manual";
|
|
64
|
-
influencer: "influencer";
|
|
65
|
-
seasonal: "seasonal";
|
|
66
|
-
referral: "referral";
|
|
67
|
-
}>>;
|
|
68
|
-
minPurchase: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
69
|
-
maxDiscount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
70
|
-
perCustomerLimit: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
71
|
-
validFrom: z.ZodOptional<z.ZodString>;
|
|
72
|
-
validUntil: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
73
|
-
isActive: z.ZodDefault<z.ZodBoolean>;
|
|
74
|
-
}, z.core.$strip>;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
// Create discount code schema
|
|
3
|
-
export const createDiscountCodeSchema = z.object({
|
|
4
|
-
code: z.string().min(1).max(50).regex(/^[A-Z0-9-]+$/, 'Code must contain only uppercase letters, numbers, and hyphens'),
|
|
5
|
-
brandId: z.string().uuid().nullable().optional(),
|
|
6
|
-
type: z.enum(['percentage', 'fixed']),
|
|
7
|
-
value: z.number().positive(), // Percentage (e.g., 10.00 for 10%) or fixed amount in Naira
|
|
8
|
-
description: z.string().min(1).max(500).optional(),
|
|
9
|
-
category: z.enum(['manual', 'recovery', 'influencer', 'seasonal', 'referral']).default('manual'),
|
|
10
|
-
minPurchase: z.number().nonnegative().nullable().optional(), // Minimum purchase in Naira
|
|
11
|
-
maxDiscount: z.number().positive().nullable().optional(), // Max discount in Naira
|
|
12
|
-
usageLimit: z.number().int().positive().nullable().optional(),
|
|
13
|
-
perCustomerLimit: z.number().int().positive().nullable().optional(),
|
|
14
|
-
validFrom: z.string().datetime().optional(),
|
|
15
|
-
validUntil: z.string().datetime().nullable().optional(),
|
|
16
|
-
isActive: z.boolean().default(true),
|
|
17
|
-
isAutoApply: z.boolean().default(false),
|
|
18
|
-
});
|
|
19
|
-
// Update discount code schema (all fields optional)
|
|
20
|
-
export const updateDiscountCodeSchema = z.object({
|
|
21
|
-
code: z.string().min(1).max(50).regex(/^[A-Z0-9-]+$/).optional(),
|
|
22
|
-
type: z.enum(['percentage', 'fixed']).optional(),
|
|
23
|
-
value: z.number().positive().optional(), // Percentage or fixed amount in Naira
|
|
24
|
-
description: z.string().min(1).max(500).nullable().optional(),
|
|
25
|
-
category: z.enum(['manual', 'recovery', 'influencer', 'seasonal', 'referral']).optional(),
|
|
26
|
-
minPurchase: z.number().nonnegative().nullable().optional(), // Minimum purchase in Naira
|
|
27
|
-
maxDiscount: z.number().positive().nullable().optional(), // Max discount in Naira
|
|
28
|
-
usageLimit: z.number().int().positive().nullable().optional(),
|
|
29
|
-
perCustomerLimit: z.number().int().positive().nullable().optional(),
|
|
30
|
-
validFrom: z.string().datetime().optional(),
|
|
31
|
-
validUntil: z.string().datetime().nullable().optional(),
|
|
32
|
-
isActive: z.boolean().optional(),
|
|
33
|
-
isAutoApply: z.boolean().optional(),
|
|
34
|
-
});
|
|
35
|
-
// Bulk generate discount codes schema
|
|
36
|
-
export const bulkGenerateCodesSchema = z.object({
|
|
37
|
-
prefix: z.string().min(1).max(20).regex(/^[A-Z0-9-]+$/),
|
|
38
|
-
count: z.number().int().positive().max(1000), // Max 1000 codes at once
|
|
39
|
-
brandId: z.string().uuid().nullable().optional(),
|
|
40
|
-
type: z.enum(['percentage', 'fixed']),
|
|
41
|
-
value: z.number().positive(), // Percentage or fixed amount in Naira
|
|
42
|
-
description: z.string().min(1).max(500).optional(),
|
|
43
|
-
category: z.enum(['manual', 'recovery', 'influencer', 'seasonal', 'referral']).default('manual'),
|
|
44
|
-
minPurchase: z.number().nonnegative().nullable().optional(), // Minimum purchase in Naira
|
|
45
|
-
maxDiscount: z.number().positive().nullable().optional(), // Max discount in Naira
|
|
46
|
-
perCustomerLimit: z.number().int().positive().nullable().optional(),
|
|
47
|
-
validFrom: z.string().datetime().optional(),
|
|
48
|
-
validUntil: z.string().datetime().nullable().optional(),
|
|
49
|
-
isActive: z.boolean().default(true),
|
|
50
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const adjustInventorySchema: z.ZodObject<{
|
|
3
|
-
variantId: z.ZodUUID;
|
|
4
|
-
warehouseId: z.ZodUUID;
|
|
5
|
-
quantity: z.ZodNumber;
|
|
6
|
-
type: z.ZodEnum<{
|
|
7
|
-
restock: "restock";
|
|
8
|
-
adjustment: "adjustment";
|
|
9
|
-
damaged: "damaged";
|
|
10
|
-
initial: "initial";
|
|
11
|
-
}>;
|
|
12
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
export declare const transferInventorySchema: z.ZodObject<{
|
|
15
|
-
variantId: z.ZodUUID;
|
|
16
|
-
fromWarehouseId: z.ZodUUID;
|
|
17
|
-
toWarehouseId: z.ZodUUID;
|
|
18
|
-
quantity: z.ZodNumber;
|
|
19
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
20
|
-
}, z.core.$strip>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export const adjustInventorySchema = z.object({
|
|
3
|
-
variantId: z.uuid(),
|
|
4
|
-
warehouseId: z.uuid(),
|
|
5
|
-
quantity: z.number().int(),
|
|
6
|
-
type: z.enum(['restock', 'adjustment', 'damaged', 'initial']),
|
|
7
|
-
reason: z.string().optional(),
|
|
8
|
-
});
|
|
9
|
-
export const transferInventorySchema = z.object({
|
|
10
|
-
variantId: z.uuid(),
|
|
11
|
-
fromWarehouseId: z.uuid(),
|
|
12
|
-
toWarehouseId: z.uuid(),
|
|
13
|
-
quantity: z.number().int().positive(),
|
|
14
|
-
reason: z.string().optional(),
|
|
15
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const createOrderSchema: z.ZodObject<{
|
|
3
|
-
brandSlug: z.ZodString;
|
|
4
|
-
firstName: z.ZodString;
|
|
5
|
-
lastName: z.ZodString;
|
|
6
|
-
phone: z.ZodString;
|
|
7
|
-
address: z.ZodString;
|
|
8
|
-
city: z.ZodString;
|
|
9
|
-
deliveryZoneId: z.ZodString;
|
|
10
|
-
deliveryCharge: z.ZodNumber;
|
|
11
|
-
items: z.ZodArray<z.ZodObject<{
|
|
12
|
-
sku: z.ZodString;
|
|
13
|
-
quantity: z.ZodNumber;
|
|
14
|
-
}, z.core.$strip>>;
|
|
15
|
-
discount: z.ZodOptional<z.ZodNumber>;
|
|
16
|
-
paymentMethod: z.ZodEnum<{
|
|
17
|
-
cod: "cod";
|
|
18
|
-
online: "online";
|
|
19
|
-
}>;
|
|
20
|
-
paystackReference: z.ZodOptional<z.ZodString>;
|
|
21
|
-
}, z.core.$strip>;
|
|
22
|
-
export declare const updateOrderSchema: z.ZodObject<{
|
|
23
|
-
brandSlug: z.ZodOptional<z.ZodString>;
|
|
24
|
-
firstName: z.ZodOptional<z.ZodString>;
|
|
25
|
-
lastName: z.ZodOptional<z.ZodString>;
|
|
26
|
-
phone: z.ZodOptional<z.ZodString>;
|
|
27
|
-
address: z.ZodOptional<z.ZodString>;
|
|
28
|
-
city: z.ZodOptional<z.ZodString>;
|
|
29
|
-
deliveryZoneId: z.ZodOptional<z.ZodString>;
|
|
30
|
-
deliveryCharge: z.ZodOptional<z.ZodNumber>;
|
|
31
|
-
discount: z.ZodOptional<z.ZodNumber>;
|
|
32
|
-
paymentMethod: z.ZodOptional<z.ZodEnum<{
|
|
33
|
-
cod: "cod";
|
|
34
|
-
online: "online";
|
|
35
|
-
}>>;
|
|
36
|
-
paystackReference: z.ZodOptional<z.ZodString>;
|
|
37
|
-
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
38
|
-
sku: z.ZodString;
|
|
39
|
-
quantity: z.ZodNumber;
|
|
40
|
-
}, z.core.$strip>>>;
|
|
41
|
-
}, z.core.$strip>;
|
|
42
|
-
export declare const updateOrderStatusSchema: z.ZodObject<{
|
|
43
|
-
status: z.ZodEnum<{
|
|
44
|
-
pending: "pending";
|
|
45
|
-
shipped: "shipped";
|
|
46
|
-
delivered: "delivered";
|
|
47
|
-
cancelled: "cancelled";
|
|
48
|
-
returned: "returned";
|
|
49
|
-
prospect: "prospect";
|
|
50
|
-
}>;
|
|
51
|
-
cancellationReason: z.ZodOptional<z.ZodString>;
|
|
52
|
-
prospectReason: z.ZodOptional<z.ZodEnum<{
|
|
53
|
-
other: "other";
|
|
54
|
-
no_answer: "no_answer";
|
|
55
|
-
thinking: "thinking";
|
|
56
|
-
price_concern: "price_concern";
|
|
57
|
-
will_call_back: "will_call_back";
|
|
58
|
-
unclear_commitment: "unclear_commitment";
|
|
59
|
-
payment_issue: "payment_issue";
|
|
60
|
-
}>>;
|
|
61
|
-
prospectNote: z.ZodOptional<z.ZodString>;
|
|
62
|
-
warehouses: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
63
|
-
orderItemId: z.ZodUUID;
|
|
64
|
-
warehouseId: z.ZodUUID;
|
|
65
|
-
}, z.core.$strip>>>;
|
|
66
|
-
}, z.core.$strip>;
|
|
67
|
-
export declare const orderFiltersSchema: z.ZodObject<{
|
|
68
|
-
brandId: z.ZodOptional<z.ZodUUID>;
|
|
69
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
70
|
-
pending: "pending";
|
|
71
|
-
shipped: "shipped";
|
|
72
|
-
delivered: "delivered";
|
|
73
|
-
cancelled: "cancelled";
|
|
74
|
-
returned: "returned";
|
|
75
|
-
prospect: "prospect";
|
|
76
|
-
}>>;
|
|
77
|
-
paymentMethod: z.ZodOptional<z.ZodEnum<{
|
|
78
|
-
cod: "cod";
|
|
79
|
-
online: "online";
|
|
80
|
-
}>>;
|
|
81
|
-
warehouseId: z.ZodOptional<z.ZodUUID>;
|
|
82
|
-
search: z.ZodOptional<z.ZodString>;
|
|
83
|
-
startDate: z.ZodOptional<z.ZodString>;
|
|
84
|
-
endDate: z.ZodOptional<z.ZodString>;
|
|
85
|
-
page: z.ZodOptional<z.ZodNumber>;
|
|
86
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
87
|
-
}, z.core.$strip>;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { OrderStatusSchema, ProspectReasonSchema, PaymentMethodSchema } from '../generated/zod';
|
|
3
|
-
// Order creation schema (public API)
|
|
4
|
-
export const createOrderSchema = z.object({
|
|
5
|
-
brandSlug: z.string().min(1),
|
|
6
|
-
firstName: z.string().min(1),
|
|
7
|
-
lastName: z.string().min(1),
|
|
8
|
-
phone: z.string().min(1),
|
|
9
|
-
address: z.string().min(1),
|
|
10
|
-
city: z.string().min(1),
|
|
11
|
-
deliveryZoneId: z.string().uuid(),
|
|
12
|
-
deliveryCharge: z.number().nonnegative(),
|
|
13
|
-
items: z.array(z.object({
|
|
14
|
-
sku: z.string().min(1),
|
|
15
|
-
quantity: z.number().int().positive(),
|
|
16
|
-
})).min(1),
|
|
17
|
-
discount: z.number().nonnegative().optional(),
|
|
18
|
-
paymentMethod: PaymentMethodSchema,
|
|
19
|
-
paystackReference: z.string().optional(),
|
|
20
|
-
});
|
|
21
|
-
// Update order schema (admin API)
|
|
22
|
-
export const updateOrderSchema = z.object({
|
|
23
|
-
brandSlug: z.string().min(1).optional(),
|
|
24
|
-
firstName: z.string().min(1).optional(),
|
|
25
|
-
lastName: z.string().min(1).optional(),
|
|
26
|
-
phone: z.string().min(1).optional(),
|
|
27
|
-
address: z.string().min(1).optional(),
|
|
28
|
-
city: z.string().min(1).optional(),
|
|
29
|
-
deliveryZoneId: z.string().uuid().optional(),
|
|
30
|
-
deliveryCharge: z.number().nonnegative().optional(),
|
|
31
|
-
discount: z.number().nonnegative().optional(),
|
|
32
|
-
paymentMethod: PaymentMethodSchema.optional(),
|
|
33
|
-
paystackReference: z.string().optional(),
|
|
34
|
-
items: z.array(z.object({
|
|
35
|
-
sku: z.string().min(1),
|
|
36
|
-
quantity: z.number().int().positive(),
|
|
37
|
-
})).optional(),
|
|
38
|
-
});
|
|
39
|
-
// Update order status schema
|
|
40
|
-
export const updateOrderStatusSchema = z.object({
|
|
41
|
-
status: OrderStatusSchema,
|
|
42
|
-
cancellationReason: z.string().optional(),
|
|
43
|
-
prospectReason: ProspectReasonSchema.optional(),
|
|
44
|
-
prospectNote: z.string().optional(),
|
|
45
|
-
warehouses: z.array(z.object({
|
|
46
|
-
orderItemId: z.uuid(),
|
|
47
|
-
warehouseId: z.uuid(),
|
|
48
|
-
})).optional(), // Required when status is 'shipped'
|
|
49
|
-
});
|
|
50
|
-
// Order filter schema
|
|
51
|
-
export const orderFiltersSchema = z.object({
|
|
52
|
-
brandId: z.uuid().optional(),
|
|
53
|
-
status: OrderStatusSchema.optional(),
|
|
54
|
-
paymentMethod: PaymentMethodSchema.optional(),
|
|
55
|
-
warehouseId: z.uuid().optional(),
|
|
56
|
-
search: z.string().optional(), // Search by order number, customer name, phone
|
|
57
|
-
startDate: z.string().optional(),
|
|
58
|
-
endDate: z.string().optional(),
|
|
59
|
-
page: z.number().int().positive().optional(),
|
|
60
|
-
limit: z.number().int().positive().max(100).optional(),
|
|
61
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const createProductSchema: z.ZodObject<{
|
|
3
|
-
brandId: z.ZodString;
|
|
4
|
-
name: z.ZodString;
|
|
5
|
-
slug: z.ZodString;
|
|
6
|
-
description: z.ZodOptional<z.ZodString>;
|
|
7
|
-
thumbnailUrl: z.ZodOptional<z.ZodString>;
|
|
8
|
-
quantityDiscounts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
9
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
export declare const updateProductSchema: z.ZodObject<{
|
|
12
|
-
name: z.ZodOptional<z.ZodString>;
|
|
13
|
-
slug: z.ZodOptional<z.ZodString>;
|
|
14
|
-
description: z.ZodOptional<z.ZodString>;
|
|
15
|
-
thumbnailUrl: z.ZodOptional<z.ZodString>;
|
|
16
|
-
quantityDiscounts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
|
|
17
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
-
}, z.core.$strip>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
const quantityDiscountsSchema = z.record(z.string().regex(/^\d+$/, 'Quantity must be a number'), z.number().int().min(0).max(100, 'Discount must be between 0 and 100')).optional();
|
|
3
|
-
export const createProductSchema = z.object({
|
|
4
|
-
brandId: z.string().uuid(),
|
|
5
|
-
name: z.string().min(1),
|
|
6
|
-
slug: z.string().min(1).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Slug must be lowercase letters, numbers, and hyphens only'),
|
|
7
|
-
description: z.string().optional(),
|
|
8
|
-
thumbnailUrl: z.string().url().optional(),
|
|
9
|
-
quantityDiscounts: quantityDiscountsSchema,
|
|
10
|
-
isActive: z.boolean().optional(),
|
|
11
|
-
});
|
|
12
|
-
export const updateProductSchema = z.object({
|
|
13
|
-
name: z.string().min(1).optional(),
|
|
14
|
-
slug: z.string().min(1).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Slug must be lowercase letters, numbers, and hyphens only').optional(),
|
|
15
|
-
description: z.string().optional(),
|
|
16
|
-
thumbnailUrl: z.string().url().optional(),
|
|
17
|
-
quantityDiscounts: quantityDiscountsSchema,
|
|
18
|
-
isActive: z.boolean().optional(),
|
|
19
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const createVariantSchema: z.ZodObject<{
|
|
3
|
-
sku: z.ZodString;
|
|
4
|
-
name: z.ZodOptional<z.ZodString>;
|
|
5
|
-
thumbnailUrl: z.ZodOptional<z.ZodURL>;
|
|
6
|
-
price: z.ZodNumber;
|
|
7
|
-
trackInventory: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
-
lowStockThreshold: z.ZodOptional<z.ZodNumber>;
|
|
9
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
export declare const updateVariantSchema: z.ZodObject<{
|
|
12
|
-
sku: z.ZodOptional<z.ZodString>;
|
|
13
|
-
name: z.ZodOptional<z.ZodString>;
|
|
14
|
-
thumbnailUrl: z.ZodOptional<z.ZodString>;
|
|
15
|
-
price: z.ZodOptional<z.ZodNumber>;
|
|
16
|
-
trackInventory: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
-
lowStockThreshold: z.ZodOptional<z.ZodNumber>;
|
|
18
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
-
}, z.core.$strip>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export const createVariantSchema = z.object({
|
|
3
|
-
sku: z.string().min(1),
|
|
4
|
-
name: z.string().optional(),
|
|
5
|
-
thumbnailUrl: z.url().optional(),
|
|
6
|
-
price: z.number().positive(), // Price in Naira
|
|
7
|
-
trackInventory: z.boolean().optional(),
|
|
8
|
-
lowStockThreshold: z.number().int().nonnegative().optional(),
|
|
9
|
-
isActive: z.boolean().optional(),
|
|
10
|
-
});
|
|
11
|
-
export const updateVariantSchema = z.object({
|
|
12
|
-
sku: z.string().min(1).optional(),
|
|
13
|
-
name: z.string().optional(),
|
|
14
|
-
thumbnailUrl: z.string().url().optional(),
|
|
15
|
-
price: z.number().positive().optional(), // Price in Naira
|
|
16
|
-
trackInventory: z.boolean().optional(),
|
|
17
|
-
lowStockThreshold: z.number().int().nonnegative().optional(),
|
|
18
|
-
isActive: z.boolean().optional(),
|
|
19
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export declare const createWarehouseSchema: z.ZodObject<{
|
|
3
|
-
name: z.ZodString;
|
|
4
|
-
address: z.ZodOptional<z.ZodString>;
|
|
5
|
-
city: z.ZodOptional<z.ZodString>;
|
|
6
|
-
state: z.ZodOptional<z.ZodString>;
|
|
7
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
-
}, z.core.$strip>;
|
|
9
|
-
export declare const updateWarehouseSchema: z.ZodObject<{
|
|
10
|
-
name: z.ZodOptional<z.ZodString>;
|
|
11
|
-
address: z.ZodOptional<z.ZodString>;
|
|
12
|
-
city: z.ZodOptional<z.ZodString>;
|
|
13
|
-
state: z.ZodOptional<z.ZodString>;
|
|
14
|
-
isActive: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
-
}, z.core.$strip>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
export const createWarehouseSchema = z.object({
|
|
3
|
-
name: z.string().min(1),
|
|
4
|
-
address: z.string().optional(),
|
|
5
|
-
city: z.string().optional(),
|
|
6
|
-
state: z.string().optional(),
|
|
7
|
-
isActive: z.boolean().optional(),
|
|
8
|
-
});
|
|
9
|
-
export const updateWarehouseSchema = z.object({
|
|
10
|
-
name: z.string().min(1).optional(),
|
|
11
|
-
address: z.string().optional(),
|
|
12
|
-
city: z.string().optional(),
|
|
13
|
-
state: z.string().optional(),
|
|
14
|
-
isActive: z.boolean().optional(),
|
|
15
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Backend RPC types - AUTO-GENERATED, DO NOT EDIT MANUALLY
|
|
3
|
-
*
|
|
4
|
-
* Generated from apps/backend/src/index.ts
|
|
5
|
-
* Run 'pnpm run generate-types' to regenerate this file
|
|
6
|
-
*
|
|
7
|
-
* These types provide end-to-end type safety between the backend API
|
|
8
|
-
* and the frontend hooks/fetchers.
|
|
9
|
-
*/
|
|
10
|
-
export type { CartsRPC, OrdersRPC, ProductsRPC, DeliveryZonesRPC, BrandsRPC, AdminOrdersRPC, AdminBrandsRPC, AdminProductsRPC, AdminVariantsRPC, AdminWarehousesRPC, AdminInventoryRPC, AdminCustomersRPC, AdminStatsRPC, AdminAbandonedCartsRPC, AdminDiscountCodesRPC, AdminDeliveryZonesRPC, } from '../../../apps/backend/src/http-app';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Backend RPC types - AUTO-GENERATED, DO NOT EDIT MANUALLY
|
|
3
|
-
*
|
|
4
|
-
* Generated from apps/backend/src/index.ts
|
|
5
|
-
* Run 'pnpm run generate-types' to regenerate this file
|
|
6
|
-
*
|
|
7
|
-
* These types provide end-to-end type safety between the backend API
|
|
8
|
-
* and the frontend hooks/fetchers.
|
|
9
|
-
*/
|
|
10
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Axios client configuration for OMS API
|
|
3
|
-
*/
|
|
4
|
-
import { AxiosInstance, AxiosError } from 'axios';
|
|
5
|
-
export interface ApiClientConfig {
|
|
6
|
-
baseURL: string;
|
|
7
|
-
onError?: (error: AxiosError) => void;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Initialize the API client with configuration
|
|
11
|
-
*/
|
|
12
|
-
export declare function initializeApiClient(config: ApiClientConfig): AxiosInstance;
|
|
13
|
-
/**
|
|
14
|
-
* Get the current API client instance
|
|
15
|
-
*/
|
|
16
|
-
export declare function getApiClient(): AxiosInstance;
|
|
17
|
-
/**
|
|
18
|
-
* Reset the API client (mainly for testing)
|
|
19
|
-
*/
|
|
20
|
-
export declare function resetApiClient(): void;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Axios client configuration for OMS API
|
|
3
|
-
*/
|
|
4
|
-
import axios from 'axios';
|
|
5
|
-
let apiClient = null;
|
|
6
|
-
/**
|
|
7
|
-
* Initialize the API client with configuration
|
|
8
|
-
*/
|
|
9
|
-
export function initializeApiClient(config) {
|
|
10
|
-
apiClient = axios.create({
|
|
11
|
-
baseURL: config.baseURL,
|
|
12
|
-
headers: {
|
|
13
|
-
'Content-Type': 'application/json',
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
// Response interceptor for error handling
|
|
17
|
-
apiClient.interceptors.response.use((response) => response, (error) => {
|
|
18
|
-
// Call custom error handler if provided
|
|
19
|
-
if (config.onError) {
|
|
20
|
-
config.onError(error);
|
|
21
|
-
}
|
|
22
|
-
return Promise.reject(error);
|
|
23
|
-
});
|
|
24
|
-
return apiClient;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Get the current API client instance
|
|
28
|
-
*/
|
|
29
|
-
export function getApiClient() {
|
|
30
|
-
if (!apiClient) {
|
|
31
|
-
throw new Error('API client not initialized. Make sure to wrap your app with ApiClientProvider.');
|
|
32
|
-
}
|
|
33
|
-
return apiClient;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Reset the API client (mainly for testing)
|
|
37
|
-
*/
|
|
38
|
-
export function resetApiClient() {
|
|
39
|
-
apiClient = null;
|
|
40
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Brand fetcher functions
|
|
3
|
-
*
|
|
4
|
-
* These are the actual data-fetching functions used by hooks.
|
|
5
|
-
* They can also be imported directly in Server Components.
|
|
6
|
-
*
|
|
7
|
-
* API URL is hardcoded to https://oms-api.instock.ng
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* Fetch brand configuration by slug
|
|
11
|
-
*
|
|
12
|
-
* @param slug - Brand slug (e.g., 'my-brand')
|
|
13
|
-
* @returns Brand with metaPixelId and other configuration
|
|
14
|
-
*/
|
|
15
|
-
export declare function fetchBrandBySlug(slug: string): Promise<{
|
|
16
|
-
name: string;
|
|
17
|
-
id: string;
|
|
18
|
-
slug: string;
|
|
19
|
-
logoUrl: string;
|
|
20
|
-
siteUrl: string;
|
|
21
|
-
domain: string;
|
|
22
|
-
metaPixelId: string;
|
|
23
|
-
createdAt: string;
|
|
24
|
-
updatedAt: string;
|
|
25
|
-
}>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Brand fetcher functions
|
|
3
|
-
*
|
|
4
|
-
* These are the actual data-fetching functions used by hooks.
|
|
5
|
-
* They can also be imported directly in Server Components.
|
|
6
|
-
*
|
|
7
|
-
* API URL is hardcoded to https://oms-api.instock.ng
|
|
8
|
-
*/
|
|
9
|
-
import { createRpcClients } from '../rpc-client';
|
|
10
|
-
const API_URL = 'https://oms-api.instock.ng';
|
|
11
|
-
/**
|
|
12
|
-
* Fetch brand configuration by slug
|
|
13
|
-
*
|
|
14
|
-
* @param slug - Brand slug (e.g., 'my-brand')
|
|
15
|
-
* @returns Brand with metaPixelId and other configuration
|
|
16
|
-
*/
|
|
17
|
-
export async function fetchBrandBySlug(slug) {
|
|
18
|
-
const clients = createRpcClients(API_URL);
|
|
19
|
-
const res = await clients.brands[':slug'].$get({
|
|
20
|
-
param: { slug },
|
|
21
|
-
});
|
|
22
|
-
if (!res.ok) {
|
|
23
|
-
throw new Error(`Failed to fetch brand: ${res.statusText}`);
|
|
24
|
-
}
|
|
25
|
-
return res.json();
|
|
26
|
-
}
|