@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.
- package/dist/hooks/index.d.ts +22 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +22 -0
- package/dist/hooks/use-option-unit-mutation.d.ts +60 -0
- package/dist/hooks/use-option-unit-mutation.d.ts.map +1 -0
- package/dist/hooks/use-option-unit-mutation.js +41 -0
- package/dist/hooks/use-option-unit.d.ts +21 -0
- package/dist/hooks/use-option-unit.d.ts.map +1 -0
- package/dist/hooks/use-option-unit.js +12 -0
- package/dist/hooks/use-option-units.d.ts +27 -0
- package/dist/hooks/use-option-units.d.ts.map +1 -0
- package/dist/hooks/use-option-units.js +12 -0
- package/dist/hooks/use-product-categories.d.ts +22 -0
- package/dist/hooks/use-product-categories.d.ts.map +1 -0
- package/dist/hooks/use-product-categories.js +29 -0
- package/dist/hooks/use-product-category-mutation.d.ts +43 -0
- package/dist/hooks/use-product-category-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-category-mutation.js +39 -0
- package/dist/hooks/use-product-category.d.ts +16 -0
- package/dist/hooks/use-product-category.d.ts.map +1 -0
- package/dist/hooks/use-product-category.js +18 -0
- package/dist/hooks/use-product-day-mutation.d.ts +41 -0
- package/dist/hooks/use-product-day-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-day-mutation.js +41 -0
- package/dist/hooks/use-product-day-service-mutation.d.ts +63 -0
- package/dist/hooks/use-product-day-service-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-day-service-mutation.js +41 -0
- package/dist/hooks/use-product-day-services.d.ts +20 -0
- package/dist/hooks/use-product-day-services.d.ts.map +1 -0
- package/dist/hooks/use-product-day-services.js +12 -0
- package/dist/hooks/use-product-days.d.ts +16 -0
- package/dist/hooks/use-product-days.d.ts.map +1 -0
- package/dist/hooks/use-product-days.js +12 -0
- package/dist/hooks/use-product-media-mutation.d.ts +98 -0
- package/dist/hooks/use-product-media-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-media-mutation.js +69 -0
- package/dist/hooks/use-product-media.d.ts +26 -0
- package/dist/hooks/use-product-media.d.ts.map +1 -0
- package/dist/hooks/use-product-media.js +12 -0
- package/dist/hooks/use-product-mutation.d.ts +2 -2
- package/dist/hooks/use-product-option-mutation.d.ts +49 -0
- package/dist/hooks/use-product-option-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-option-mutation.js +39 -0
- package/dist/hooks/use-product-option.d.ts +18 -0
- package/dist/hooks/use-product-option.d.ts.map +1 -0
- package/dist/hooks/use-product-option.js +12 -0
- package/dist/hooks/use-product-options.d.ts +24 -0
- package/dist/hooks/use-product-options.d.ts.map +1 -0
- package/dist/hooks/use-product-options.js +12 -0
- package/dist/hooks/use-product-tag-mutation.d.ts +25 -0
- package/dist/hooks/use-product-tag-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-tag-mutation.js +39 -0
- package/dist/hooks/use-product-tag.d.ts +10 -0
- package/dist/hooks/use-product-tag.d.ts.map +1 -0
- package/dist/hooks/use-product-tag.js +18 -0
- package/dist/hooks/use-product-tags.d.ts +16 -0
- package/dist/hooks/use-product-tags.d.ts.map +1 -0
- package/dist/hooks/use-product-tags.js +25 -0
- package/dist/hooks/use-product-type-mutation.d.ts +50 -0
- package/dist/hooks/use-product-type-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-type-mutation.js +47 -0
- package/dist/hooks/use-product-type.d.ts +15 -0
- package/dist/hooks/use-product-type.d.ts.map +1 -0
- package/dist/hooks/use-product-type.js +12 -0
- package/dist/hooks/use-product-types.d.ts +1 -1
- package/dist/hooks/use-product-types.d.ts.map +1 -1
- package/dist/hooks/use-product-types.js +4 -22
- package/dist/hooks/use-product-version-mutation.d.ts +16 -0
- package/dist/hooks/use-product-version-mutation.d.ts.map +1 -0
- package/dist/hooks/use-product-version-mutation.js +22 -0
- package/dist/hooks/use-product-versions.d.ts +15 -0
- package/dist/hooks/use-product-versions.d.ts.map +1 -0
- package/dist/hooks/use-product-versions.js +12 -0
- package/dist/hooks/use-product.d.ts +1 -1
- package/dist/hooks/use-products.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/provider.d.ts +1 -13
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +1 -16
- package/dist/query-keys.d.ts +48 -0
- package/dist/query-keys.d.ts.map +1 -1
- package/dist/query-keys.js +18 -0
- package/dist/query-options.d.ts +1031 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +235 -0
- package/dist/schemas.d.ts +431 -3
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +117 -0
- package/package.json +7 -3
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
|
+
export * from "./use-option-unit.js";
|
|
2
|
+
export * from "./use-option-unit-mutation.js";
|
|
3
|
+
export * from "./use-option-units.js";
|
|
1
4
|
export * from "./use-product.js";
|
|
5
|
+
export * from "./use-product-categories.js";
|
|
6
|
+
export * from "./use-product-category.js";
|
|
7
|
+
export * from "./use-product-category-mutation.js";
|
|
8
|
+
export * from "./use-product-day-mutation.js";
|
|
9
|
+
export * from "./use-product-day-service-mutation.js";
|
|
10
|
+
export * from "./use-product-day-services.js";
|
|
11
|
+
export * from "./use-product-days.js";
|
|
12
|
+
export * from "./use-product-media.js";
|
|
13
|
+
export * from "./use-product-media-mutation.js";
|
|
2
14
|
export * from "./use-product-mutation.js";
|
|
15
|
+
export * from "./use-product-option.js";
|
|
16
|
+
export * from "./use-product-option-mutation.js";
|
|
17
|
+
export * from "./use-product-options.js";
|
|
18
|
+
export * from "./use-product-tag.js";
|
|
19
|
+
export * from "./use-product-tag-mutation.js";
|
|
20
|
+
export * from "./use-product-tags.js";
|
|
21
|
+
export * from "./use-product-type.js";
|
|
22
|
+
export * from "./use-product-type-mutation.js";
|
|
3
23
|
export * from "./use-product-types.js";
|
|
24
|
+
export * from "./use-product-version-mutation.js";
|
|
25
|
+
export * from "./use-product-versions.js";
|
|
4
26
|
export * from "./use-products.js";
|
|
5
27
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,mBAAmB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA;AACzC,cAAc,oCAAoC,CAAA;AAClD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uCAAuC,CAAA;AACrD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kCAAkC,CAAA;AAChD,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wBAAwB,CAAA;AACtC,cAAc,mCAAmC,CAAA;AACjD,cAAc,2BAA2B,CAAA;AACzC,cAAc,mBAAmB,CAAA"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
+
export * from "./use-option-unit.js";
|
|
2
|
+
export * from "./use-option-unit-mutation.js";
|
|
3
|
+
export * from "./use-option-units.js";
|
|
1
4
|
export * from "./use-product.js";
|
|
5
|
+
export * from "./use-product-categories.js";
|
|
6
|
+
export * from "./use-product-category.js";
|
|
7
|
+
export * from "./use-product-category-mutation.js";
|
|
8
|
+
export * from "./use-product-day-mutation.js";
|
|
9
|
+
export * from "./use-product-day-service-mutation.js";
|
|
10
|
+
export * from "./use-product-day-services.js";
|
|
11
|
+
export * from "./use-product-days.js";
|
|
12
|
+
export * from "./use-product-media.js";
|
|
13
|
+
export * from "./use-product-media-mutation.js";
|
|
2
14
|
export * from "./use-product-mutation.js";
|
|
15
|
+
export * from "./use-product-option.js";
|
|
16
|
+
export * from "./use-product-option-mutation.js";
|
|
17
|
+
export * from "./use-product-options.js";
|
|
18
|
+
export * from "./use-product-tag.js";
|
|
19
|
+
export * from "./use-product-tag-mutation.js";
|
|
20
|
+
export * from "./use-product-tags.js";
|
|
21
|
+
export * from "./use-product-type.js";
|
|
22
|
+
export * from "./use-product-type-mutation.js";
|
|
3
23
|
export * from "./use-product-types.js";
|
|
24
|
+
export * from "./use-product-version-mutation.js";
|
|
25
|
+
export * from "./use-product-versions.js";
|
|
4
26
|
export * from "./use-products.js";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface CreateOptionUnitInput {
|
|
2
|
+
optionId: string;
|
|
3
|
+
name: string;
|
|
4
|
+
code?: string | null;
|
|
5
|
+
description?: string | null;
|
|
6
|
+
unitType?: "person" | "group" | "room" | "vehicle" | "service" | "other";
|
|
7
|
+
minQuantity?: number | null;
|
|
8
|
+
maxQuantity?: number | null;
|
|
9
|
+
minAge?: number | null;
|
|
10
|
+
maxAge?: number | null;
|
|
11
|
+
occupancyMin?: number | null;
|
|
12
|
+
occupancyMax?: number | null;
|
|
13
|
+
isRequired?: boolean;
|
|
14
|
+
isHidden?: boolean;
|
|
15
|
+
sortOrder?: number;
|
|
16
|
+
}
|
|
17
|
+
export type UpdateOptionUnitInput = Omit<Partial<CreateOptionUnitInput>, "optionId">;
|
|
18
|
+
export declare function useOptionUnitMutation(): {
|
|
19
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
20
|
+
id: string;
|
|
21
|
+
optionId: string;
|
|
22
|
+
name: string;
|
|
23
|
+
code: string | null;
|
|
24
|
+
description: string | null;
|
|
25
|
+
unitType: "person" | "group" | "room" | "vehicle" | "service" | "other";
|
|
26
|
+
minQuantity: number | null;
|
|
27
|
+
maxQuantity: number | null;
|
|
28
|
+
minAge: number | null;
|
|
29
|
+
maxAge: number | null;
|
|
30
|
+
occupancyMin: number | null;
|
|
31
|
+
occupancyMax: number | null;
|
|
32
|
+
isRequired: boolean;
|
|
33
|
+
isHidden: boolean;
|
|
34
|
+
sortOrder: number;
|
|
35
|
+
}, Error, CreateOptionUnitInput, unknown>;
|
|
36
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
37
|
+
id: string;
|
|
38
|
+
optionId: string;
|
|
39
|
+
name: string;
|
|
40
|
+
code: string | null;
|
|
41
|
+
description: string | null;
|
|
42
|
+
unitType: "person" | "group" | "room" | "vehicle" | "service" | "other";
|
|
43
|
+
minQuantity: number | null;
|
|
44
|
+
maxQuantity: number | null;
|
|
45
|
+
minAge: number | null;
|
|
46
|
+
maxAge: number | null;
|
|
47
|
+
occupancyMin: number | null;
|
|
48
|
+
occupancyMax: number | null;
|
|
49
|
+
isRequired: boolean;
|
|
50
|
+
isHidden: boolean;
|
|
51
|
+
sortOrder: number;
|
|
52
|
+
}, Error, {
|
|
53
|
+
id: string;
|
|
54
|
+
input: UpdateOptionUnitInput;
|
|
55
|
+
}, unknown>;
|
|
56
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
57
|
+
success: boolean;
|
|
58
|
+
}, Error, string, unknown>;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=use-option-unit-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-option-unit-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-option-unit-mutation.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAA;IACxE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,EAAE,UAAU,CAAC,CAAA;AAIpF,wBAAgB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAuBO,MAAM;eAAS,qBAAqB;;;;;EA6B/E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { optionUnitSingleResponse } from "../schemas.js";
|
|
8
|
+
const deleteResponseSchema = z.object({ success: z.boolean() });
|
|
9
|
+
export function useOptionUnitMutation() {
|
|
10
|
+
const { baseUrl, fetcher } = useVoyantProductsContext();
|
|
11
|
+
const queryClient = useQueryClient();
|
|
12
|
+
const create = useMutation({
|
|
13
|
+
mutationFn: async ({ optionId, ...input }) => {
|
|
14
|
+
const { data } = await fetchWithValidation(`/v1/products/options/${optionId}/units`, optionUnitSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
15
|
+
return data;
|
|
16
|
+
},
|
|
17
|
+
onSuccess: (data) => {
|
|
18
|
+
void queryClient.invalidateQueries({ queryKey: productsQueryKeys.optionUnits() });
|
|
19
|
+
void queryClient.invalidateQueries({
|
|
20
|
+
queryKey: productsQueryKeys.productOption(data.optionId),
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const update = useMutation({
|
|
25
|
+
mutationFn: async ({ id, input }) => {
|
|
26
|
+
const { data } = await fetchWithValidation(`/v1/products/units/${id}`, optionUnitSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
27
|
+
return data;
|
|
28
|
+
},
|
|
29
|
+
onSuccess: (data) => {
|
|
30
|
+
void queryClient.invalidateQueries({ queryKey: productsQueryKeys.optionUnits() });
|
|
31
|
+
queryClient.setQueryData(productsQueryKeys.optionUnit(data.id), data);
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const remove = useMutation({
|
|
35
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/products/units/${id}`, deleteResponseSchema, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
36
|
+
onSuccess: () => {
|
|
37
|
+
void queryClient.invalidateQueries({ queryKey: productsQueryKeys.optionUnits() });
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return { create, update, remove };
|
|
41
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface UseOptionUnitOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useOptionUnit(id: string | undefined, options?: UseOptionUnitOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
optionId: string;
|
|
7
|
+
name: string;
|
|
8
|
+
code: string | null;
|
|
9
|
+
description: string | null;
|
|
10
|
+
unitType: "person" | "group" | "room" | "vehicle" | "service" | "other";
|
|
11
|
+
minQuantity: number | null;
|
|
12
|
+
maxQuantity: number | null;
|
|
13
|
+
minAge: number | null;
|
|
14
|
+
maxAge: number | null;
|
|
15
|
+
occupancyMin: number | null;
|
|
16
|
+
occupancyMax: number | null;
|
|
17
|
+
isRequired: boolean;
|
|
18
|
+
isHidden: boolean;
|
|
19
|
+
sortOrder: number;
|
|
20
|
+
}, Error>;
|
|
21
|
+
//# sourceMappingURL=use-option-unit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-option-unit.d.ts","sourceRoot":"","sources":["../../src/hooks/use-option-unit.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,GAAE,oBAAyB;;;;;;;;;;;;;;;;UAQvF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantProductsContext } from "../provider.js";
|
|
4
|
+
import { getOptionUnitQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useOptionUnit(id, options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantProductsContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getOptionUnitQueryOptions({ baseUrl, fetcher }, id, options),
|
|
10
|
+
enabled: enabled && !!id,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { OptionUnitsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseOptionUnitsOptions extends OptionUnitsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useOptionUnits(options?: UseOptionUnitsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
optionId: string;
|
|
9
|
+
name: string;
|
|
10
|
+
code: string | null;
|
|
11
|
+
description: string | null;
|
|
12
|
+
unitType: "person" | "group" | "room" | "vehicle" | "service" | "other";
|
|
13
|
+
minQuantity: number | null;
|
|
14
|
+
maxQuantity: number | null;
|
|
15
|
+
minAge: number | null;
|
|
16
|
+
maxAge: number | null;
|
|
17
|
+
occupancyMin: number | null;
|
|
18
|
+
occupancyMax: number | null;
|
|
19
|
+
isRequired: boolean;
|
|
20
|
+
isHidden: boolean;
|
|
21
|
+
sortOrder: number;
|
|
22
|
+
}[];
|
|
23
|
+
total: number;
|
|
24
|
+
limit: number;
|
|
25
|
+
offset: number;
|
|
26
|
+
}, Error>;
|
|
27
|
+
//# sourceMappingURL=use-option-units.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-option-units.d.ts","sourceRoot":"","sources":["../../src/hooks/use-option-units.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAG9D,MAAM,WAAW,qBAAsB,SAAQ,sBAAsB;IACnE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B;;;;;;;;;;;;;;;;;;;;;UAQjE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantProductsContext } from "../provider.js";
|
|
4
|
+
import { getOptionUnitsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useOptionUnits(options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantProductsContext();
|
|
7
|
+
const { enabled = true, ...filters } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getOptionUnitsQueryOptions({ baseUrl, fetcher }, filters),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ProductCategoriesListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseProductCategoriesOptions extends ProductCategoriesListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useProductCategories(options?: UseProductCategoriesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
parentId: string | null;
|
|
9
|
+
name: string;
|
|
10
|
+
slug: string;
|
|
11
|
+
description: string | null;
|
|
12
|
+
sortOrder: number;
|
|
13
|
+
active: boolean;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
17
|
+
}[];
|
|
18
|
+
total: number;
|
|
19
|
+
limit: number;
|
|
20
|
+
offset: number;
|
|
21
|
+
}, Error>;
|
|
22
|
+
//# sourceMappingURL=use-product-categories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-product-categories.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-categories.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,4BAA4B,EAAqB,MAAM,kBAAkB,CAAA;AAGvF,MAAM,WAAW,2BAA4B,SAAQ,4BAA4B;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC;;;;;;;;;;;;;;;;UAsB7E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { productCategoryListResponse } from "../schemas.js";
|
|
7
|
+
export function useProductCategories(options = {}) {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantProductsContext();
|
|
9
|
+
const { enabled = true, ...filters } = options;
|
|
10
|
+
return useQuery({
|
|
11
|
+
queryKey: productsQueryKeys.productCategoriesList(filters),
|
|
12
|
+
queryFn: () => {
|
|
13
|
+
const params = new URLSearchParams();
|
|
14
|
+
if (filters.parentId)
|
|
15
|
+
params.set("parentId", filters.parentId);
|
|
16
|
+
if (filters.active !== undefined)
|
|
17
|
+
params.set("active", String(filters.active));
|
|
18
|
+
if (filters.search)
|
|
19
|
+
params.set("search", filters.search);
|
|
20
|
+
if (filters.limit !== undefined)
|
|
21
|
+
params.set("limit", String(filters.limit));
|
|
22
|
+
if (filters.offset !== undefined)
|
|
23
|
+
params.set("offset", String(filters.offset));
|
|
24
|
+
const qs = params.toString();
|
|
25
|
+
return fetchWithValidation(`/v1/products/product-categories${qs ? `?${qs}` : ""}`, productCategoryListResponse, { baseUrl, fetcher });
|
|
26
|
+
},
|
|
27
|
+
enabled,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface CreateProductCategoryInput {
|
|
2
|
+
name: string;
|
|
3
|
+
slug: string;
|
|
4
|
+
parentId?: string | null;
|
|
5
|
+
description?: string | null;
|
|
6
|
+
sortOrder?: number;
|
|
7
|
+
active?: boolean;
|
|
8
|
+
metadata?: Record<string, unknown> | null;
|
|
9
|
+
}
|
|
10
|
+
export type UpdateProductCategoryInput = Partial<CreateProductCategoryInput>;
|
|
11
|
+
export declare function useProductCategoryMutation(): {
|
|
12
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
13
|
+
id: string;
|
|
14
|
+
parentId: string | null;
|
|
15
|
+
name: string;
|
|
16
|
+
slug: string;
|
|
17
|
+
description: string | null;
|
|
18
|
+
sortOrder: number;
|
|
19
|
+
active: boolean;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
23
|
+
}, Error, CreateProductCategoryInput, unknown>;
|
|
24
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
25
|
+
id: string;
|
|
26
|
+
parentId: string | null;
|
|
27
|
+
name: string;
|
|
28
|
+
slug: string;
|
|
29
|
+
description: string | null;
|
|
30
|
+
sortOrder: number;
|
|
31
|
+
active: boolean;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
updatedAt: string;
|
|
34
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
35
|
+
}, Error, {
|
|
36
|
+
id: string;
|
|
37
|
+
input: UpdateProductCategoryInput;
|
|
38
|
+
}, unknown>;
|
|
39
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
40
|
+
success: boolean;
|
|
41
|
+
}, Error, string, unknown>;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=use-product-category-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-product-category-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-category-mutation.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;CAC1C;AAED,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAA;AAI5E,wBAAgB,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;YAoBE,MAAM;eAAS,0BAA0B;;;;;EA8BpF"}
|
|
@@ -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 { productCategorySingleResponse } from "../schemas.js";
|
|
8
|
+
const deleteResponseSchema = z.object({ success: z.boolean() });
|
|
9
|
+
export function useProductCategoryMutation() {
|
|
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-categories", productCategorySingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
15
|
+
return data;
|
|
16
|
+
},
|
|
17
|
+
onSuccess: () => {
|
|
18
|
+
void queryClient.invalidateQueries({ queryKey: productsQueryKeys.productCategories() });
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const update = useMutation({
|
|
22
|
+
mutationFn: async ({ id, input }) => {
|
|
23
|
+
const { data } = await fetchWithValidation(`/v1/products/product-categories/${id}`, productCategorySingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
24
|
+
return data;
|
|
25
|
+
},
|
|
26
|
+
onSuccess: (data) => {
|
|
27
|
+
void queryClient.invalidateQueries({ queryKey: productsQueryKeys.productCategories() });
|
|
28
|
+
queryClient.setQueryData(productsQueryKeys.productCategory(data.id), data);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const remove = useMutation({
|
|
32
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/products/product-categories/${id}`, deleteResponseSchema, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
33
|
+
onSuccess: (_data, id) => {
|
|
34
|
+
void queryClient.invalidateQueries({ queryKey: productsQueryKeys.productCategories() });
|
|
35
|
+
queryClient.removeQueries({ queryKey: productsQueryKeys.productCategory(id) });
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
return { create, update, remove };
|
|
39
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface UseProductCategoryOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useProductCategory(id: string | null | undefined, options?: UseProductCategoryOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
parentId: string | null;
|
|
7
|
+
name: string;
|
|
8
|
+
slug: string;
|
|
9
|
+
description: string | null;
|
|
10
|
+
sortOrder: number;
|
|
11
|
+
active: boolean;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
15
|
+
}, Error>;
|
|
16
|
+
//# sourceMappingURL=use-product-category.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-product-category.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-category.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7B,OAAO,GAAE,yBAA8B;;;;;;;;;;;UAiBxC"}
|
|
@@ -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 { productCategorySingleResponse } from "../schemas.js";
|
|
7
|
+
export function useProductCategory(id, options = {}) {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantProductsContext();
|
|
9
|
+
const { enabled = true } = options;
|
|
10
|
+
return useQuery({
|
|
11
|
+
queryKey: productsQueryKeys.productCategory(id ?? "__missing__"),
|
|
12
|
+
queryFn: async () => {
|
|
13
|
+
const { data } = await fetchWithValidation(`/v1/products/product-categories/${id}`, productCategorySingleResponse, { baseUrl, fetcher });
|
|
14
|
+
return data;
|
|
15
|
+
},
|
|
16
|
+
enabled: enabled && Boolean(id),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type UpdateProductDayInput } from "../schemas.js";
|
|
2
|
+
export declare function useProductDayMutation(): {
|
|
3
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
4
|
+
id: string;
|
|
5
|
+
productId: string;
|
|
6
|
+
dayNumber: number;
|
|
7
|
+
title: string | null;
|
|
8
|
+
description: string | null;
|
|
9
|
+
location: string | null;
|
|
10
|
+
createdAt: string;
|
|
11
|
+
updatedAt: string;
|
|
12
|
+
}, Error, {
|
|
13
|
+
dayNumber: number;
|
|
14
|
+
title?: string | null | undefined;
|
|
15
|
+
description?: string | null | undefined;
|
|
16
|
+
location?: string | null | undefined;
|
|
17
|
+
} & {
|
|
18
|
+
productId: string;
|
|
19
|
+
}, unknown>;
|
|
20
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
21
|
+
id: string;
|
|
22
|
+
productId: string;
|
|
23
|
+
dayNumber: number;
|
|
24
|
+
title: string | null;
|
|
25
|
+
description: string | null;
|
|
26
|
+
location: string | null;
|
|
27
|
+
createdAt: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
}, Error, {
|
|
30
|
+
productId: string;
|
|
31
|
+
dayId: string;
|
|
32
|
+
input: UpdateProductDayInput;
|
|
33
|
+
}, unknown>;
|
|
34
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
35
|
+
success: boolean;
|
|
36
|
+
}, Error, {
|
|
37
|
+
productId: string;
|
|
38
|
+
dayId: string;
|
|
39
|
+
}, unknown>;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=use-product-day-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-product-day-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-day-mutation.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,eAAe,CAAA;AAEtB,wBAAgB,qBAAqB;;;;;;;;;;;;;;;;mBAKgD,MAAM;;;;;;;;;;;;mBAsB1E,MAAM;eACV,MAAM;eACN,qBAAqB;;;;;mBAkBwB,MAAM;eAAS,MAAM;;EAe9E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } 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 { productDayResponse, successEnvelope, } from "../schemas.js";
|
|
7
|
+
export function useProductDayMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantProductsContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async ({ productId, ...input }) => {
|
|
12
|
+
const { data } = await fetchWithValidation(`/v1/products/${productId}/days`, productDayResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: async (data) => {
|
|
16
|
+
await queryClient.invalidateQueries({
|
|
17
|
+
queryKey: productsQueryKeys.productDays(data.productId),
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const update = useMutation({
|
|
22
|
+
mutationFn: async ({ productId, dayId, input, }) => {
|
|
23
|
+
const { data } = await fetchWithValidation(`/v1/products/${productId}/days/${dayId}`, productDayResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
24
|
+
return data;
|
|
25
|
+
},
|
|
26
|
+
onSuccess: async (data) => {
|
|
27
|
+
await queryClient.invalidateQueries({
|
|
28
|
+
queryKey: productsQueryKeys.productDays(data.productId),
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const remove = useMutation({
|
|
33
|
+
mutationFn: async ({ productId, dayId }) => fetchWithValidation(`/v1/products/${productId}/days/${dayId}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
34
|
+
onSuccess: async (_data, variables) => {
|
|
35
|
+
await queryClient.invalidateQueries({
|
|
36
|
+
queryKey: productsQueryKeys.productDays(variables.productId),
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return { create, update, remove };
|
|
41
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type UpdateProductDayServiceInput } from "../schemas.js";
|
|
2
|
+
export declare function useProductDayServiceMutation(): {
|
|
3
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
4
|
+
dayId: string;
|
|
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
|
+
serviceType: "other" | "transfer" | "accommodation" | "experience" | "guide" | "meal";
|
|
21
|
+
name: string;
|
|
22
|
+
costCurrency: string;
|
|
23
|
+
costAmountCents: number;
|
|
24
|
+
description?: string | null | undefined;
|
|
25
|
+
supplierServiceId?: string | null | undefined;
|
|
26
|
+
quantity?: number | undefined;
|
|
27
|
+
sortOrder?: number | null | undefined;
|
|
28
|
+
notes?: string | null | undefined;
|
|
29
|
+
} & {
|
|
30
|
+
productId: string;
|
|
31
|
+
dayId: string;
|
|
32
|
+
}, unknown>;
|
|
33
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
34
|
+
dayId: string;
|
|
35
|
+
data: {
|
|
36
|
+
id: string;
|
|
37
|
+
dayId: string;
|
|
38
|
+
supplierServiceId: string | null;
|
|
39
|
+
serviceType: "other" | "transfer" | "accommodation" | "experience" | "guide" | "meal";
|
|
40
|
+
name: string;
|
|
41
|
+
description: string | null;
|
|
42
|
+
costCurrency: string;
|
|
43
|
+
costAmountCents: number;
|
|
44
|
+
quantity: number;
|
|
45
|
+
sortOrder: number | null;
|
|
46
|
+
notes: string | null;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
};
|
|
49
|
+
}, Error, {
|
|
50
|
+
productId: string;
|
|
51
|
+
dayId: string;
|
|
52
|
+
serviceId: string;
|
|
53
|
+
input: UpdateProductDayServiceInput;
|
|
54
|
+
}, unknown>;
|
|
55
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
56
|
+
success: boolean;
|
|
57
|
+
}, Error, {
|
|
58
|
+
productId: string;
|
|
59
|
+
dayId: string;
|
|
60
|
+
serviceId: string;
|
|
61
|
+
}, unknown>;
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=use-product-day-service-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-product-day-service-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-product-day-service-mutation.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,4BAA4B,EAClC,MAAM,eAAe,CAAA;AAEtB,wBAAgB,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBASO,MAAM;eAAS,MAAM;;;;;;;;;;;;;;;;;;;mBAuBvD,MAAM;eACV,MAAM;mBACF,MAAM;eACV,4BAA4B;;;;;mBAuBxB,MAAM;eACV,MAAM;mBACF,MAAM;;EAgBtB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } 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 { productDayServiceResponse, successEnvelope, } from "../schemas.js";
|
|
7
|
+
export function useProductDayServiceMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantProductsContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async ({ productId, dayId, ...input }) => {
|
|
12
|
+
const { data } = await fetchWithValidation(`/v1/products/${productId}/days/${dayId}/services`, productDayServiceResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return { dayId, data };
|
|
14
|
+
},
|
|
15
|
+
onSuccess: async ({ dayId }, variables) => {
|
|
16
|
+
await queryClient.invalidateQueries({
|
|
17
|
+
queryKey: productsQueryKeys.productDayServices(variables.productId, dayId),
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const update = useMutation({
|
|
22
|
+
mutationFn: async ({ productId, dayId, serviceId, input, }) => {
|
|
23
|
+
const { data } = await fetchWithValidation(`/v1/products/${productId}/days/${dayId}/services/${serviceId}`, productDayServiceResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
24
|
+
return { dayId, data };
|
|
25
|
+
},
|
|
26
|
+
onSuccess: async ({ dayId }, variables) => {
|
|
27
|
+
await queryClient.invalidateQueries({
|
|
28
|
+
queryKey: productsQueryKeys.productDayServices(variables.productId, dayId),
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const remove = useMutation({
|
|
33
|
+
mutationFn: async ({ productId, dayId, serviceId, }) => fetchWithValidation(`/v1/products/${productId}/days/${dayId}/services/${serviceId}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
34
|
+
onSuccess: async (_data, variables) => {
|
|
35
|
+
await queryClient.invalidateQueries({
|
|
36
|
+
queryKey: productsQueryKeys.productDayServices(variables.productId, variables.dayId),
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return { create, update, remove };
|
|
41
|
+
}
|