@instockng/api-client 1.0.22 → 1.0.25
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/backend-types.d.ts +1 -1
- package/dist/fetchers/brands.d.ts +0 -2
- package/dist/fetchers/brands.js +2 -4
- package/dist/fetchers/carts.d.ts +3667 -759
- package/dist/fetchers/carts.js +11 -13
- package/dist/fetchers/delivery-zones.d.ts +0 -2
- package/dist/fetchers/delivery-zones.js +2 -4
- package/dist/fetchers/orders.d.ts +1130 -259
- package/dist/fetchers/orders.js +4 -6
- package/dist/fetchers/products.d.ts +638 -58
- package/dist/fetchers/products.js +4 -6
- package/dist/hooks/admin/abandoned-carts.d.ts +707 -125
- package/dist/hooks/admin/customers.d.ts +291 -0
- package/dist/hooks/admin/index.d.ts +8 -7
- package/dist/hooks/admin/index.js +8 -7
- package/dist/hooks/admin/media.d.ts +44 -0
- package/dist/hooks/admin/media.js +86 -0
- package/dist/hooks/admin/orders.d.ts +2531 -785
- package/dist/hooks/admin/products.d.ts +615 -33
- package/dist/hooks/admin/stats.d.ts +291 -0
- package/dist/hooks/admin/warehouses.d.ts +291 -0
- package/dist/hooks/public/carts.d.ts +3867 -957
- package/dist/hooks/public/orders.d.ts +930 -57
- package/dist/hooks/public/products.d.ts +627 -45
- package/dist/provider.d.ts +1 -0
- package/dist/provider.js +2 -1
- package/dist/rpc-client.d.ts +15535 -6438
- package/dist/rpc-client.js +1 -0
- package/dist/utils/query-keys.d.ts +4 -0
- package/dist/utils/query-keys.js +4 -0
- package/package.json +8 -7
package/dist/fetchers/carts.js
CHANGED
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These are the actual data-fetching functions used by hooks.
|
|
5
5
|
* They can also be imported directly in Server Components.
|
|
6
|
-
*
|
|
7
|
-
* API URL is hardcoded to https://oms-api.instock.ng
|
|
8
6
|
*/
|
|
9
7
|
import { createRpcClients } from '../rpc-client';
|
|
10
|
-
|
|
8
|
+
import { API_BASE_URL } from '../provider';
|
|
11
9
|
/**
|
|
12
10
|
* Fetch a cart by ID
|
|
13
11
|
*
|
|
@@ -15,7 +13,7 @@ const API_URL = 'https://oms-api.instock.ng';
|
|
|
15
13
|
* @returns Cart with items, brand, and delivery zone
|
|
16
14
|
*/
|
|
17
15
|
export async function fetchCart(cartId) {
|
|
18
|
-
const clients = createRpcClients(
|
|
16
|
+
const clients = createRpcClients(API_BASE_URL);
|
|
19
17
|
const res = await clients.carts[':id'].$get({
|
|
20
18
|
param: { id: cartId },
|
|
21
19
|
});
|
|
@@ -31,7 +29,7 @@ export async function fetchCart(cartId) {
|
|
|
31
29
|
* @returns Newly created cart
|
|
32
30
|
*/
|
|
33
31
|
export async function createCart(brandSlug) {
|
|
34
|
-
const clients = createRpcClients(
|
|
32
|
+
const clients = createRpcClients(API_BASE_URL);
|
|
35
33
|
const res = await clients.carts.index.$post({
|
|
36
34
|
json: { brandSlug },
|
|
37
35
|
});
|
|
@@ -48,7 +46,7 @@ export async function createCart(brandSlug) {
|
|
|
48
46
|
* @returns Updated cart
|
|
49
47
|
*/
|
|
50
48
|
export async function updateCart(cartId, data) {
|
|
51
|
-
const clients = createRpcClients(
|
|
49
|
+
const clients = createRpcClients(API_BASE_URL);
|
|
52
50
|
const res = await clients.carts[':id'].$patch({
|
|
53
51
|
param: { id: cartId },
|
|
54
52
|
// @ts-expect-error - Hono RPC type inference issue
|
|
@@ -72,7 +70,7 @@ export async function updateCart(cartId, data) {
|
|
|
72
70
|
* @returns Updated cart
|
|
73
71
|
*/
|
|
74
72
|
export async function addCartItem(cartId, sku, quantity, fbc, fbp, ttp, ttclid) {
|
|
75
|
-
const clients = createRpcClients(
|
|
73
|
+
const clients = createRpcClients(API_BASE_URL);
|
|
76
74
|
const res = await clients.carts[':id'].items.$post({
|
|
77
75
|
param: { id: cartId },
|
|
78
76
|
// @ts-expect-error - Hono RPC type inference issue
|
|
@@ -92,7 +90,7 @@ export async function addCartItem(cartId, sku, quantity, fbc, fbp, ttp, ttclid)
|
|
|
92
90
|
* @returns Updated cart
|
|
93
91
|
*/
|
|
94
92
|
export async function updateCartItem(cartId, itemId, quantity) {
|
|
95
|
-
const clients = createRpcClients(
|
|
93
|
+
const clients = createRpcClients(API_BASE_URL);
|
|
96
94
|
const res = await clients.carts[':id'].items[':itemId'].$patch({
|
|
97
95
|
param: { id: cartId, itemId },
|
|
98
96
|
// @ts-expect-error - Hono RPC type inference issue
|
|
@@ -111,7 +109,7 @@ export async function updateCartItem(cartId, itemId, quantity) {
|
|
|
111
109
|
* @returns Updated cart
|
|
112
110
|
*/
|
|
113
111
|
export async function removeCartItem(cartId, itemId) {
|
|
114
|
-
const clients = createRpcClients(
|
|
112
|
+
const clients = createRpcClients(API_BASE_URL);
|
|
115
113
|
const res = await clients.carts[':id'].items[':itemId'].$delete({
|
|
116
114
|
param: { id: cartId, itemId },
|
|
117
115
|
});
|
|
@@ -128,7 +126,7 @@ export async function removeCartItem(cartId, itemId) {
|
|
|
128
126
|
* @returns Updated cart
|
|
129
127
|
*/
|
|
130
128
|
export async function applyDiscount(cartId, code) {
|
|
131
|
-
const clients = createRpcClients(
|
|
129
|
+
const clients = createRpcClients(API_BASE_URL);
|
|
132
130
|
const res = await clients.carts[':id']['apply-discount'].$post({
|
|
133
131
|
param: { id: cartId },
|
|
134
132
|
// @ts-expect-error - Hono RPC type inference issue
|
|
@@ -146,7 +144,7 @@ export async function applyDiscount(cartId, code) {
|
|
|
146
144
|
* @returns Updated cart
|
|
147
145
|
*/
|
|
148
146
|
export async function removeDiscount(cartId) {
|
|
149
|
-
const clients = createRpcClients(
|
|
147
|
+
const clients = createRpcClients(API_BASE_URL);
|
|
150
148
|
const res = await clients.carts[':id']['remove-discount'].$post({
|
|
151
149
|
param: { id: cartId },
|
|
152
150
|
});
|
|
@@ -163,7 +161,7 @@ export async function removeDiscount(cartId) {
|
|
|
163
161
|
* @returns Created order
|
|
164
162
|
*/
|
|
165
163
|
export async function checkoutCart(cartId, checkoutData) {
|
|
166
|
-
const clients = createRpcClients(
|
|
164
|
+
const clients = createRpcClients(API_BASE_URL);
|
|
167
165
|
const res = await clients.carts[':id'].checkout.$post({
|
|
168
166
|
param: { id: cartId },
|
|
169
167
|
// @ts-expect-error - Hono RPC type inference issue
|
|
@@ -182,7 +180,7 @@ export async function checkoutCart(cartId, checkoutData) {
|
|
|
182
180
|
* @returns Array of recommended products from the same brand
|
|
183
181
|
*/
|
|
184
182
|
export async function fetchCartRecommendations(cartId, limit) {
|
|
185
|
-
const clients = createRpcClients(
|
|
183
|
+
const clients = createRpcClients(API_BASE_URL);
|
|
186
184
|
const res = await clients.carts[':id'].recommendations.$get({
|
|
187
185
|
param: { id: cartId },
|
|
188
186
|
// @ts-ignore - Hono RPC type inference issue with query parameters
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These are the actual data-fetching functions used by hooks.
|
|
5
5
|
* They can also be imported directly in Server Components.
|
|
6
|
-
*
|
|
7
|
-
* API URL is hardcoded to https://oms-api.instock.ng
|
|
8
6
|
*/
|
|
9
7
|
import { createRpcClients } from '../rpc-client';
|
|
10
|
-
|
|
8
|
+
import { API_BASE_URL } from '../provider';
|
|
11
9
|
/**
|
|
12
10
|
* Fetch delivery zones
|
|
13
11
|
*
|
|
@@ -15,7 +13,7 @@ const API_URL = 'https://oms-api.instock.ng';
|
|
|
15
13
|
* @returns List of delivery zones with states
|
|
16
14
|
*/
|
|
17
15
|
export async function fetchDeliveryZones(brandId) {
|
|
18
|
-
const clients = createRpcClients(
|
|
16
|
+
const clients = createRpcClients(API_BASE_URL);
|
|
19
17
|
const res = await clients.deliveryZones.index.$get({
|
|
20
18
|
query: brandId ? { brandId } : {},
|
|
21
19
|
});
|