@voyantjs/products-react 0.2.0 → 0.3.1

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 (91) hide show
  1. package/dist/hooks/index.d.ts +22 -0
  2. package/dist/hooks/index.d.ts.map +1 -1
  3. package/dist/hooks/index.js +22 -0
  4. package/dist/hooks/use-option-unit-mutation.d.ts +60 -0
  5. package/dist/hooks/use-option-unit-mutation.d.ts.map +1 -0
  6. package/dist/hooks/use-option-unit-mutation.js +41 -0
  7. package/dist/hooks/use-option-unit.d.ts +21 -0
  8. package/dist/hooks/use-option-unit.d.ts.map +1 -0
  9. package/dist/hooks/use-option-unit.js +12 -0
  10. package/dist/hooks/use-option-units.d.ts +27 -0
  11. package/dist/hooks/use-option-units.d.ts.map +1 -0
  12. package/dist/hooks/use-option-units.js +12 -0
  13. package/dist/hooks/use-product-categories.d.ts +22 -0
  14. package/dist/hooks/use-product-categories.d.ts.map +1 -0
  15. package/dist/hooks/use-product-categories.js +29 -0
  16. package/dist/hooks/use-product-category-mutation.d.ts +43 -0
  17. package/dist/hooks/use-product-category-mutation.d.ts.map +1 -0
  18. package/dist/hooks/use-product-category-mutation.js +39 -0
  19. package/dist/hooks/use-product-category.d.ts +16 -0
  20. package/dist/hooks/use-product-category.d.ts.map +1 -0
  21. package/dist/hooks/use-product-category.js +18 -0
  22. package/dist/hooks/use-product-day-mutation.d.ts +41 -0
  23. package/dist/hooks/use-product-day-mutation.d.ts.map +1 -0
  24. package/dist/hooks/use-product-day-mutation.js +41 -0
  25. package/dist/hooks/use-product-day-service-mutation.d.ts +63 -0
  26. package/dist/hooks/use-product-day-service-mutation.d.ts.map +1 -0
  27. package/dist/hooks/use-product-day-service-mutation.js +41 -0
  28. package/dist/hooks/use-product-day-services.d.ts +20 -0
  29. package/dist/hooks/use-product-day-services.d.ts.map +1 -0
  30. package/dist/hooks/use-product-day-services.js +12 -0
  31. package/dist/hooks/use-product-days.d.ts +16 -0
  32. package/dist/hooks/use-product-days.d.ts.map +1 -0
  33. package/dist/hooks/use-product-days.js +12 -0
  34. package/dist/hooks/use-product-media-mutation.d.ts +98 -0
  35. package/dist/hooks/use-product-media-mutation.d.ts.map +1 -0
  36. package/dist/hooks/use-product-media-mutation.js +69 -0
  37. package/dist/hooks/use-product-media.d.ts +26 -0
  38. package/dist/hooks/use-product-media.d.ts.map +1 -0
  39. package/dist/hooks/use-product-media.js +12 -0
  40. package/dist/hooks/use-product-mutation.d.ts +2 -2
  41. package/dist/hooks/use-product-option-mutation.d.ts +49 -0
  42. package/dist/hooks/use-product-option-mutation.d.ts.map +1 -0
  43. package/dist/hooks/use-product-option-mutation.js +39 -0
  44. package/dist/hooks/use-product-option.d.ts +18 -0
  45. package/dist/hooks/use-product-option.d.ts.map +1 -0
  46. package/dist/hooks/use-product-option.js +12 -0
  47. package/dist/hooks/use-product-options.d.ts +24 -0
  48. package/dist/hooks/use-product-options.d.ts.map +1 -0
  49. package/dist/hooks/use-product-options.js +12 -0
  50. package/dist/hooks/use-product-tag-mutation.d.ts +25 -0
  51. package/dist/hooks/use-product-tag-mutation.d.ts.map +1 -0
  52. package/dist/hooks/use-product-tag-mutation.js +39 -0
  53. package/dist/hooks/use-product-tag.d.ts +10 -0
  54. package/dist/hooks/use-product-tag.d.ts.map +1 -0
  55. package/dist/hooks/use-product-tag.js +18 -0
  56. package/dist/hooks/use-product-tags.d.ts +16 -0
  57. package/dist/hooks/use-product-tags.d.ts.map +1 -0
  58. package/dist/hooks/use-product-tags.js +25 -0
  59. package/dist/hooks/use-product-type-mutation.d.ts +50 -0
  60. package/dist/hooks/use-product-type-mutation.d.ts.map +1 -0
  61. package/dist/hooks/use-product-type-mutation.js +47 -0
  62. package/dist/hooks/use-product-type.d.ts +15 -0
  63. package/dist/hooks/use-product-type.d.ts.map +1 -0
  64. package/dist/hooks/use-product-type.js +12 -0
  65. package/dist/hooks/use-product-types.d.ts +1 -1
  66. package/dist/hooks/use-product-types.d.ts.map +1 -1
  67. package/dist/hooks/use-product-types.js +4 -22
  68. package/dist/hooks/use-product-version-mutation.d.ts +16 -0
  69. package/dist/hooks/use-product-version-mutation.d.ts.map +1 -0
  70. package/dist/hooks/use-product-version-mutation.js +22 -0
  71. package/dist/hooks/use-product-versions.d.ts +15 -0
  72. package/dist/hooks/use-product-versions.d.ts.map +1 -0
  73. package/dist/hooks/use-product-versions.js +12 -0
  74. package/dist/hooks/use-product.d.ts +1 -1
  75. package/dist/hooks/use-products.d.ts +1 -1
  76. package/dist/index.d.ts +1 -0
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +1 -0
  79. package/dist/provider.d.ts +1 -13
  80. package/dist/provider.d.ts.map +1 -1
  81. package/dist/provider.js +1 -16
  82. package/dist/query-keys.d.ts +48 -0
  83. package/dist/query-keys.d.ts.map +1 -1
  84. package/dist/query-keys.js +18 -0
  85. package/dist/query-options.d.ts +1031 -0
  86. package/dist/query-options.d.ts.map +1 -0
  87. package/dist/query-options.js +235 -0
  88. package/dist/schemas.d.ts +431 -3
  89. package/dist/schemas.d.ts.map +1 -1
  90. package/dist/schemas.js +117 -0
  91. package/package.json +7 -3
@@ -0,0 +1,20 @@
1
+ export interface UseProductDayServicesOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useProductDayServices(productId: string | null | undefined, dayId: string | null | undefined, options?: UseProductDayServicesOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ data: {
6
+ id: string;
7
+ dayId: string;
8
+ supplierServiceId: string | null;
9
+ serviceType: "other" | "transfer" | "accommodation" | "experience" | "guide" | "meal";
10
+ name: string;
11
+ description: string | null;
12
+ costCurrency: string;
13
+ costAmountCents: number;
14
+ quantity: number;
15
+ sortOrder: number | null;
16
+ notes: string | null;
17
+ createdAt: string;
18
+ }[];
19
+ }, Error>;
20
+ //# sourceMappingURL=use-product-day-services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-product-day-services.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-day-services.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,4BAA4B;IAC3C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,OAAO,GAAE,4BAAiC;;;;;;;;;;;;;;;UAS3C"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantProductsContext } from "../provider.js";
4
+ import { getProductDayServicesQueryOptions } from "../query-options.js";
5
+ export function useProductDayServices(productId, dayId, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantProductsContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getProductDayServicesQueryOptions({ baseUrl, fetcher }, productId, dayId, options),
10
+ enabled: enabled && Boolean(productId) && Boolean(dayId),
11
+ });
12
+ }
@@ -0,0 +1,16 @@
1
+ export interface UseProductDaysOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useProductDays(productId: string | null | undefined, options?: UseProductDaysOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ data: {
6
+ id: string;
7
+ productId: string;
8
+ dayNumber: number;
9
+ title: string | null;
10
+ description: string | null;
11
+ location: string | null;
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ }[];
15
+ }, Error>;
16
+ //# sourceMappingURL=use-product-days.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-product-days.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-days.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,qBAA0B;;;;;;;;;;;UASpC"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantProductsContext } from "../provider.js";
4
+ import { getProductDaysQueryOptions } from "../query-options.js";
5
+ export function useProductDays(productId, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantProductsContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getProductDaysQueryOptions({ baseUrl, fetcher }, productId, options),
10
+ enabled: enabled && Boolean(productId),
11
+ });
12
+ }
@@ -0,0 +1,98 @@
1
+ import { type UpdateProductMediaInput } from "../schemas.js";
2
+ export declare function useProductMediaMutation(): {
3
+ create: import("@tanstack/react-query").UseMutationResult<{
4
+ id: string;
5
+ productId: string;
6
+ dayId: string | null;
7
+ mediaType: "image" | "video" | "document";
8
+ name: string;
9
+ url: string;
10
+ storageKey: string | null;
11
+ mimeType: string | null;
12
+ fileSize: number | null;
13
+ altText: string | null;
14
+ sortOrder: number;
15
+ isCover: boolean;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ }, Error, {
19
+ mediaType: "image" | "video" | "document";
20
+ name: string;
21
+ url: string;
22
+ storageKey?: string | null | undefined;
23
+ mimeType?: string | null | undefined;
24
+ fileSize?: number | null | undefined;
25
+ altText?: string | null | undefined;
26
+ sortOrder?: number | undefined;
27
+ isCover?: boolean | undefined;
28
+ dayId?: string | null | undefined;
29
+ } & {
30
+ productId: string;
31
+ }, unknown>;
32
+ update: import("@tanstack/react-query").UseMutationResult<{
33
+ id: string;
34
+ productId: string;
35
+ dayId: string | null;
36
+ mediaType: "image" | "video" | "document";
37
+ name: string;
38
+ url: string;
39
+ storageKey: string | null;
40
+ mimeType: string | null;
41
+ fileSize: number | null;
42
+ altText: string | null;
43
+ sortOrder: number;
44
+ isCover: boolean;
45
+ createdAt: string;
46
+ updatedAt: string;
47
+ }, Error, {
48
+ mediaId: string;
49
+ input: UpdateProductMediaInput;
50
+ }, unknown>;
51
+ remove: import("@tanstack/react-query").UseMutationResult<{
52
+ data: {
53
+ id: string;
54
+ productId: string;
55
+ dayId: string | null;
56
+ mediaType: "image" | "video" | "document";
57
+ name: string;
58
+ url: string;
59
+ storageKey: string | null;
60
+ mimeType: string | null;
61
+ fileSize: number | null;
62
+ altText: string | null;
63
+ sortOrder: number;
64
+ isCover: boolean;
65
+ createdAt: string;
66
+ updatedAt: string;
67
+ };
68
+ }, Error, string, unknown>;
69
+ reorder: import("@tanstack/react-query").UseMutationResult<{
70
+ data: {
71
+ id: string;
72
+ }[];
73
+ }, Error, {
74
+ items: {
75
+ id: string;
76
+ sortOrder: number;
77
+ }[];
78
+ } & {
79
+ productId: string;
80
+ }, unknown>;
81
+ setCover: import("@tanstack/react-query").UseMutationResult<{
82
+ id: string;
83
+ productId: string;
84
+ dayId: string | null;
85
+ mediaType: "image" | "video" | "document";
86
+ name: string;
87
+ url: string;
88
+ storageKey: string | null;
89
+ mimeType: string | null;
90
+ fileSize: number | null;
91
+ altText: string | null;
92
+ sortOrder: number;
93
+ isCover: boolean;
94
+ createdAt: string;
95
+ updatedAt: string;
96
+ }, Error, string, unknown>;
97
+ };
98
+ //# sourceMappingURL=use-product-media-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-product-media-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-media-mutation.ts"],"names":[],"mappings":"AAQA,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,eAAe,CAAA;AAMtB,wBAAgB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAQO,MAAM;;;;;;;;;;;;;;;;;;iBAoBE,MAAM;eAAS,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAmDP,MAAM;;;;;;;;;;;;;;;;;;EAe1F"}
@@ -0,0 +1,69 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { z } from "zod";
4
+ import { fetchWithValidation } from "../client.js";
5
+ import { useVoyantProductsContext } from "../provider.js";
6
+ import { productsQueryKeys } from "../query-keys.js";
7
+ import { productMediaResponse, } from "../schemas.js";
8
+ const reorderResponseSchema = z.object({
9
+ data: z.array(z.object({ id: z.string() })),
10
+ });
11
+ export function useProductMediaMutation() {
12
+ const { baseUrl, fetcher } = useVoyantProductsContext();
13
+ const queryClient = useQueryClient();
14
+ const create = useMutation({
15
+ mutationFn: async ({ productId, ...input }) => {
16
+ const path = input.dayId
17
+ ? `/v1/products/${productId}/days/${input.dayId}/media`
18
+ : `/v1/products/${productId}/media`;
19
+ const { data } = await fetchWithValidation(path, productMediaResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
20
+ return data;
21
+ },
22
+ onSuccess: async (data) => {
23
+ await queryClient.invalidateQueries({
24
+ queryKey: productsQueryKeys.productMedia(data.productId),
25
+ });
26
+ },
27
+ });
28
+ const update = useMutation({
29
+ mutationFn: async ({ mediaId, input }) => {
30
+ const { data } = await fetchWithValidation(`/v1/products/media/${mediaId}`, productMediaResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
31
+ return data;
32
+ },
33
+ onSuccess: async (data) => {
34
+ await queryClient.invalidateQueries({
35
+ queryKey: productsQueryKeys.productMedia(data.productId),
36
+ });
37
+ await queryClient.invalidateQueries({ queryKey: productsQueryKeys.productMediaItem(data.id) });
38
+ },
39
+ });
40
+ const remove = useMutation({
41
+ mutationFn: async (mediaId) => fetchWithValidation(`/v1/products/media/${mediaId}`, productMediaResponse, { baseUrl, fetcher }, { method: "DELETE" }),
42
+ onSuccess: async ({ data }) => {
43
+ await queryClient.invalidateQueries({
44
+ queryKey: productsQueryKeys.productMedia(data.productId),
45
+ });
46
+ await queryClient.invalidateQueries({ queryKey: productsQueryKeys.productMediaItem(data.id) });
47
+ },
48
+ });
49
+ const setCover = useMutation({
50
+ mutationFn: async (mediaId) => {
51
+ const { data } = await fetchWithValidation(`/v1/products/media/${mediaId}/set-cover`, productMediaResponse, { baseUrl, fetcher }, { method: "PATCH" });
52
+ return data;
53
+ },
54
+ onSuccess: async (data) => {
55
+ await queryClient.invalidateQueries({
56
+ queryKey: productsQueryKeys.productMedia(data.productId),
57
+ });
58
+ },
59
+ });
60
+ const reorder = useMutation({
61
+ mutationFn: async ({ productId, items }) => fetchWithValidation(`/v1/products/${productId}/media/reorder`, reorderResponseSchema, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify({ items }) }),
62
+ onSuccess: async (_data, variables) => {
63
+ await queryClient.invalidateQueries({
64
+ queryKey: productsQueryKeys.productMedia(variables.productId),
65
+ });
66
+ },
67
+ });
68
+ return { create, update, remove, reorder, setCover };
69
+ }
@@ -0,0 +1,26 @@
1
+ import type { ProductMediaListFilters } from "../query-keys.js";
2
+ export interface UseProductMediaOptions extends ProductMediaListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useProductMedia(productId: string | null | undefined, options?: UseProductMediaOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ productId: string;
9
+ dayId: string | null;
10
+ mediaType: "image" | "video" | "document";
11
+ name: string;
12
+ url: string;
13
+ storageKey: string | null;
14
+ mimeType: string | null;
15
+ fileSize: number | null;
16
+ altText: string | null;
17
+ sortOrder: number;
18
+ isCover: boolean;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ }[];
22
+ total: number;
23
+ limit: number;
24
+ offset: number;
25
+ }, Error>;
26
+ //# sourceMappingURL=use-product-media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-product-media.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-media.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAG/D,MAAM,WAAW,sBAAuB,SAAQ,uBAAuB;IACrE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,GAAE,sBAA2B;;;;;;;;;;;;;;;;;;;;UASrC"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantProductsContext } from "../provider.js";
4
+ import { getProductMediaQueryOptions } from "../query-options.js";
5
+ export function useProductMedia(productId, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantProductsContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getProductMediaQueryOptions({ baseUrl, fetcher }, productId, filters),
10
+ enabled: enabled && Boolean(productId),
11
+ });
12
+ }
@@ -26,7 +26,7 @@ export declare function useProductMutation(): {
26
26
  name: string;
27
27
  status: "draft" | "active" | "archived";
28
28
  description: string | null;
29
- bookingMode: "date" | "date_time" | "open" | "stay" | "transfer" | "itinerary" | "other";
29
+ bookingMode: "other" | "date" | "date_time" | "open" | "stay" | "transfer" | "itinerary";
30
30
  capacityMode: "free_sale" | "limited" | "on_request";
31
31
  timezone: string | null;
32
32
  visibility: "public" | "private" | "hidden";
@@ -50,7 +50,7 @@ export declare function useProductMutation(): {
50
50
  name: string;
51
51
  status: "draft" | "active" | "archived";
52
52
  description: string | null;
53
- bookingMode: "date" | "date_time" | "open" | "stay" | "transfer" | "itinerary" | "other";
53
+ bookingMode: "other" | "date" | "date_time" | "open" | "stay" | "transfer" | "itinerary";
54
54
  capacityMode: "free_sale" | "limited" | "on_request";
55
55
  timezone: string | null;
56
56
  visibility: "public" | "private" | "hidden";
@@ -0,0 +1,49 @@
1
+ export interface CreateProductOptionInput {
2
+ productId: string;
3
+ name: string;
4
+ code?: string | null;
5
+ description?: string | null;
6
+ status?: "draft" | "active" | "archived";
7
+ isDefault?: boolean;
8
+ sortOrder?: number;
9
+ availableFrom?: string | null;
10
+ availableTo?: string | null;
11
+ }
12
+ export type UpdateProductOptionInput = Omit<Partial<CreateProductOptionInput>, "productId">;
13
+ export declare function useProductOptionMutation(): {
14
+ create: import("@tanstack/react-query").UseMutationResult<{
15
+ id: string;
16
+ productId: string;
17
+ name: string;
18
+ code: string | null;
19
+ description: string | null;
20
+ status: "draft" | "active" | "archived";
21
+ isDefault: boolean;
22
+ sortOrder: number;
23
+ availableFrom: string | null;
24
+ availableTo: string | null;
25
+ createdAt: string;
26
+ updatedAt: string;
27
+ }, Error, CreateProductOptionInput, unknown>;
28
+ update: import("@tanstack/react-query").UseMutationResult<{
29
+ id: string;
30
+ productId: string;
31
+ name: string;
32
+ code: string | null;
33
+ description: string | null;
34
+ status: "draft" | "active" | "archived";
35
+ isDefault: boolean;
36
+ sortOrder: number;
37
+ availableFrom: string | null;
38
+ availableTo: string | null;
39
+ createdAt: string;
40
+ updatedAt: string;
41
+ }, Error, {
42
+ id: string;
43
+ input: UpdateProductOptionInput;
44
+ }, unknown>;
45
+ remove: import("@tanstack/react-query").UseMutationResult<{
46
+ success: boolean;
47
+ }, Error, string, unknown>;
48
+ };
49
+ //# sourceMappingURL=use-product-option-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-product-option-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-option-mutation.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,MAAM,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAA;IACxC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,OAAO,CAAC,wBAAwB,CAAC,EAAE,WAAW,CAAC,CAAA;AAI3F,wBAAgB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBI,MAAM;eAAS,wBAAwB;;;;;EA6BlF"}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { z } from "zod";
4
+ import { fetchWithValidation } from "../client.js";
5
+ import { useVoyantProductsContext } from "../provider.js";
6
+ import { productsQueryKeys } from "../query-keys.js";
7
+ import { productOptionSingleResponse } from "../schemas.js";
8
+ const deleteResponseSchema = z.object({ success: z.boolean() });
9
+ export function useProductOptionMutation() {
10
+ const { baseUrl, fetcher } = useVoyantProductsContext();
11
+ const queryClient = useQueryClient();
12
+ const create = useMutation({
13
+ mutationFn: async ({ productId, ...input }) => {
14
+ const { data } = await fetchWithValidation(`/v1/products/${productId}/options`, productOptionSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
15
+ return data;
16
+ },
17
+ onSuccess: (data) => {
18
+ void queryClient.invalidateQueries({ queryKey: productsQueryKeys.productOptions() });
19
+ void queryClient.invalidateQueries({ queryKey: productsQueryKeys.product(data.productId) });
20
+ },
21
+ });
22
+ const update = useMutation({
23
+ mutationFn: async ({ id, input }) => {
24
+ const { data } = await fetchWithValidation(`/v1/products/options/${id}`, productOptionSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
25
+ return data;
26
+ },
27
+ onSuccess: (data) => {
28
+ void queryClient.invalidateQueries({ queryKey: productsQueryKeys.productOptions() });
29
+ queryClient.setQueryData(productsQueryKeys.productOption(data.id), data);
30
+ },
31
+ });
32
+ const remove = useMutation({
33
+ mutationFn: async (id) => fetchWithValidation(`/v1/products/options/${id}`, deleteResponseSchema, { baseUrl, fetcher }, { method: "DELETE" }),
34
+ onSuccess: () => {
35
+ void queryClient.invalidateQueries({ queryKey: productsQueryKeys.productOptions() });
36
+ },
37
+ });
38
+ return { create, update, remove };
39
+ }
@@ -0,0 +1,18 @@
1
+ export interface UseProductOptionOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useProductOption(id: string | null | undefined, options?: UseProductOptionOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ productId: string;
7
+ name: string;
8
+ code: string | null;
9
+ description: string | null;
10
+ status: "draft" | "active" | "archived";
11
+ isDefault: boolean;
12
+ sortOrder: number;
13
+ availableFrom: string | null;
14
+ availableTo: string | null;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ }, Error>;
18
+ //# sourceMappingURL=use-product-option.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-product-option.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-option.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7B,OAAO,GAAE,uBAA4B;;;;;;;;;;;;;UAStC"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantProductsContext } from "../provider.js";
4
+ import { getProductOptionQueryOptions } from "../query-options.js";
5
+ export function useProductOption(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantProductsContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getProductOptionQueryOptions({ baseUrl, fetcher }, id, options),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,24 @@
1
+ import type { ProductOptionsListFilters } from "../query-keys.js";
2
+ export interface UseProductOptionsListOptions extends ProductOptionsListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useProductOptions(options?: UseProductOptionsListOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ productId: string;
9
+ name: string;
10
+ code: string | null;
11
+ description: string | null;
12
+ status: "draft" | "active" | "archived";
13
+ isDefault: boolean;
14
+ sortOrder: number;
15
+ availableFrom: string | null;
16
+ availableTo: string | null;
17
+ createdAt: string;
18
+ updatedAt: string;
19
+ }[];
20
+ total: number;
21
+ limit: number;
22
+ offset: number;
23
+ }, Error>;
24
+ //# sourceMappingURL=use-product-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-product-options.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-options.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAGjE,MAAM,WAAW,4BAA6B,SAAQ,yBAAyB;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,4BAAiC;;;;;;;;;;;;;;;;;;UAQ3E"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantProductsContext } from "../provider.js";
4
+ import { getProductOptionsQueryOptions } from "../query-options.js";
5
+ export function useProductOptions(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantProductsContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getProductOptionsQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,25 @@
1
+ export interface CreateProductTagInput {
2
+ name: string;
3
+ }
4
+ export type UpdateProductTagInput = Partial<CreateProductTagInput>;
5
+ export declare function useProductTagMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ id: string;
8
+ name: string;
9
+ createdAt: string;
10
+ updatedAt: string;
11
+ }, Error, CreateProductTagInput, unknown>;
12
+ update: import("@tanstack/react-query").UseMutationResult<{
13
+ id: string;
14
+ name: string;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ }, Error, {
18
+ id: string;
19
+ input: UpdateProductTagInput;
20
+ }, unknown>;
21
+ remove: import("@tanstack/react-query").UseMutationResult<{
22
+ success: boolean;
23
+ }, Error, string, unknown>;
24
+ };
25
+ //# sourceMappingURL=use-product-tag-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-product-tag-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-tag-mutation.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,MAAM,qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;AAIlE,wBAAgB,qBAAqB;;;;;;;;;;;;;YAoBO,MAAM;eAAS,qBAAqB;;;;;EA8B/E"}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { z } from "zod";
4
+ import { fetchWithValidation } from "../client.js";
5
+ import { useVoyantProductsContext } from "../provider.js";
6
+ import { productsQueryKeys } from "../query-keys.js";
7
+ import { productTagSingleResponse } from "../schemas.js";
8
+ const deleteResponseSchema = z.object({ success: z.boolean() });
9
+ export function useProductTagMutation() {
10
+ const { baseUrl, fetcher } = useVoyantProductsContext();
11
+ const queryClient = useQueryClient();
12
+ const create = useMutation({
13
+ mutationFn: async (input) => {
14
+ const { data } = await fetchWithValidation("/v1/products/product-tags", productTagSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
15
+ return data;
16
+ },
17
+ onSuccess: () => {
18
+ void queryClient.invalidateQueries({ queryKey: productsQueryKeys.productTags() });
19
+ },
20
+ });
21
+ const update = useMutation({
22
+ mutationFn: async ({ id, input }) => {
23
+ const { data } = await fetchWithValidation(`/v1/products/product-tags/${id}`, productTagSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
24
+ return data;
25
+ },
26
+ onSuccess: (data) => {
27
+ void queryClient.invalidateQueries({ queryKey: productsQueryKeys.productTags() });
28
+ queryClient.setQueryData(productsQueryKeys.productTag(data.id), data);
29
+ },
30
+ });
31
+ const remove = useMutation({
32
+ mutationFn: async (id) => fetchWithValidation(`/v1/products/product-tags/${id}`, deleteResponseSchema, { baseUrl, fetcher }, { method: "DELETE" }),
33
+ onSuccess: (_data, id) => {
34
+ void queryClient.invalidateQueries({ queryKey: productsQueryKeys.productTags() });
35
+ queryClient.removeQueries({ queryKey: productsQueryKeys.productTag(id) });
36
+ },
37
+ });
38
+ return { create, update, remove };
39
+ }
@@ -0,0 +1,10 @@
1
+ export interface UseProductTagOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useProductTag(id: string | null | undefined, options?: UseProductTagOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ name: string;
7
+ createdAt: string;
8
+ updatedAt: string;
9
+ }, Error>;
10
+ //# sourceMappingURL=use-product-tag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-product-tag.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-tag.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,GAAE,oBAAyB;;;;;UAgB9F"}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantProductsContext } from "../provider.js";
5
+ import { productsQueryKeys } from "../query-keys.js";
6
+ import { productTagSingleResponse } from "../schemas.js";
7
+ export function useProductTag(id, options = {}) {
8
+ const { baseUrl, fetcher } = useVoyantProductsContext();
9
+ const { enabled = true } = options;
10
+ return useQuery({
11
+ queryKey: productsQueryKeys.productTag(id ?? "__missing__"),
12
+ queryFn: async () => {
13
+ const { data } = await fetchWithValidation(`/v1/products/product-tags/${id}`, productTagSingleResponse, { baseUrl, fetcher });
14
+ return data;
15
+ },
16
+ enabled: enabled && Boolean(id),
17
+ });
18
+ }
@@ -0,0 +1,16 @@
1
+ import { type ProductTagsListFilters } from "../query-keys.js";
2
+ export interface UseProductTagsOptions extends ProductTagsListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useProductTags(options?: UseProductTagsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ name: string;
9
+ createdAt: string;
10
+ updatedAt: string;
11
+ }[];
12
+ total: number;
13
+ limit: number;
14
+ offset: number;
15
+ }, Error>;
16
+ //# sourceMappingURL=use-product-tags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-product-tags.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-tags.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,sBAAsB,EAAqB,MAAM,kBAAkB,CAAA;AAGjF,MAAM,WAAW,qBAAsB,SAAQ,sBAAsB;IACnE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B;;;;;;;;;;UAoBjE"}
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantProductsContext } from "../provider.js";
5
+ import { productsQueryKeys } from "../query-keys.js";
6
+ import { productTagListResponse } from "../schemas.js";
7
+ export function useProductTags(options = {}) {
8
+ const { baseUrl, fetcher } = useVoyantProductsContext();
9
+ const { enabled = true, ...filters } = options;
10
+ return useQuery({
11
+ queryKey: productsQueryKeys.productTagsList(filters),
12
+ queryFn: () => {
13
+ const params = new URLSearchParams();
14
+ if (filters.search)
15
+ params.set("search", filters.search);
16
+ if (filters.limit !== undefined)
17
+ params.set("limit", String(filters.limit));
18
+ if (filters.offset !== undefined)
19
+ params.set("offset", String(filters.offset));
20
+ const qs = params.toString();
21
+ return fetchWithValidation(`/v1/products/product-tags${qs ? `?${qs}` : ""}`, productTagListResponse, { baseUrl, fetcher });
22
+ },
23
+ enabled,
24
+ });
25
+ }