@instockng/api-client 1.0.28 → 1.0.29
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.
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* They can also be imported directly in Server Components.
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
|
-
* Fetch products by brand
|
|
8
|
+
* Fetch products by brand slug
|
|
9
9
|
*
|
|
10
|
-
* @param
|
|
10
|
+
* @param brandSlug - Brand slug (e.g., 'toyland')
|
|
11
11
|
* @returns Products for the brand with variants and availability
|
|
12
12
|
*/
|
|
13
|
-
export declare function fetchProductsByBrand(
|
|
13
|
+
export declare function fetchProductsByBrand(brandSlug: string): Promise<{
|
|
14
14
|
id: string;
|
|
15
15
|
name: string;
|
|
16
16
|
slug: string;
|
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
import { createRpcClients } from '../rpc-client';
|
|
8
8
|
const API_URL = 'https://oms-api.instock.com.ng';
|
|
9
9
|
/**
|
|
10
|
-
* Fetch products by brand
|
|
10
|
+
* Fetch products by brand slug
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
12
|
+
* @param brandSlug - Brand slug (e.g., 'toyland')
|
|
13
13
|
* @returns Products for the brand with variants and availability
|
|
14
14
|
*/
|
|
15
|
-
export async function fetchProductsByBrand(
|
|
15
|
+
export async function fetchProductsByBrand(brandSlug) {
|
|
16
16
|
const clients = createRpcClients(API_URL);
|
|
17
|
-
const res = await clients.products[':
|
|
18
|
-
param: {
|
|
17
|
+
const res = await clients.products[':brandSlug'].$get({
|
|
18
|
+
param: { brandSlug },
|
|
19
19
|
});
|
|
20
20
|
if (!res.ok) {
|
|
21
21
|
throw new Error(`Failed to fetch products: ${res.statusText}`);
|
|
@@ -7,18 +7,18 @@
|
|
|
7
7
|
import { UseQueryOptions } from '@tanstack/react-query';
|
|
8
8
|
import { fetchProductsByBrand, fetchProductBySlug, fetchProductAddons } from '../../fetchers/products';
|
|
9
9
|
/**
|
|
10
|
-
* Hook to get products by brand using RPC
|
|
10
|
+
* Hook to get products by brand slug using RPC
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
12
|
+
* @param brandSlug - Brand slug (e.g., 'toyland')
|
|
13
13
|
* @param options - React Query options
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```tsx
|
|
17
|
-
* const { data: products, isLoading } = useGetProducts('
|
|
17
|
+
* const { data: products, isLoading } = useGetProducts('toyland');
|
|
18
18
|
* console.log(products?.data[0].name); // Fully typed!
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export declare function useGetProducts(
|
|
21
|
+
export declare function useGetProducts(brandSlug: string, options?: Omit<UseQueryOptions<Awaited<ReturnType<typeof fetchProductsByBrand>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
|
|
22
22
|
id: string;
|
|
23
23
|
name: string;
|
|
24
24
|
slug: string;
|
|
@@ -8,21 +8,21 @@ import { useQueryUnwrapped } from '../use-query-unwrapped';
|
|
|
8
8
|
import { queryKeys } from '../../utils/query-keys';
|
|
9
9
|
import { fetchProductsByBrand, fetchProductBySlug, fetchProductAddons } from '../../fetchers/products';
|
|
10
10
|
/**
|
|
11
|
-
* Hook to get products by brand using RPC
|
|
11
|
+
* Hook to get products by brand slug using RPC
|
|
12
12
|
*
|
|
13
|
-
* @param
|
|
13
|
+
* @param brandSlug - Brand slug (e.g., 'toyland')
|
|
14
14
|
* @param options - React Query options
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```tsx
|
|
18
|
-
* const { data: products, isLoading } = useGetProducts('
|
|
18
|
+
* const { data: products, isLoading } = useGetProducts('toyland');
|
|
19
19
|
* console.log(products?.data[0].name); // Fully typed!
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
export function useGetProducts(
|
|
22
|
+
export function useGetProducts(brandSlug, options) {
|
|
23
23
|
return useQueryUnwrapped({
|
|
24
|
-
queryKey: queryKeys.public.products.list(
|
|
25
|
-
queryFn: () => fetchProductsByBrand(
|
|
24
|
+
queryKey: queryKeys.public.products.list(brandSlug),
|
|
25
|
+
queryFn: () => fetchProductsByBrand(brandSlug),
|
|
26
26
|
...options,
|
|
27
27
|
});
|
|
28
28
|
}
|
package/dist/rpc-client.d.ts
CHANGED
|
@@ -8709,11 +8709,11 @@ export declare function createRpcClients(baseURL: string): {
|
|
|
8709
8709
|
}>;
|
|
8710
8710
|
};
|
|
8711
8711
|
} & {
|
|
8712
|
-
":
|
|
8712
|
+
":brandSlug": import("hono/client").ClientRequest<{
|
|
8713
8713
|
$get: {
|
|
8714
8714
|
input: {
|
|
8715
8715
|
param: {
|
|
8716
|
-
|
|
8716
|
+
brandSlug: string;
|
|
8717
8717
|
};
|
|
8718
8718
|
};
|
|
8719
8719
|
output: {
|
|
@@ -9198,7 +9198,7 @@ export declare function createRpcClients(baseURL: string): {
|
|
|
9198
9198
|
} | {
|
|
9199
9199
|
input: {
|
|
9200
9200
|
param: {
|
|
9201
|
-
|
|
9201
|
+
brandSlug: string;
|
|
9202
9202
|
};
|
|
9203
9203
|
};
|
|
9204
9204
|
output: {
|
|
@@ -9212,7 +9212,7 @@ export declare function createRpcClients(baseURL: string): {
|
|
|
9212
9212
|
} | {
|
|
9213
9213
|
input: {
|
|
9214
9214
|
param: {
|
|
9215
|
-
|
|
9215
|
+
brandSlug: string;
|
|
9216
9216
|
};
|
|
9217
9217
|
};
|
|
9218
9218
|
output: {
|