@voyantjs/pricing-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 (126) hide show
  1. package/LICENSE +109 -0
  2. package/dist/hooks/index.d.ts +33 -0
  3. package/dist/hooks/index.d.ts.map +1 -1
  4. package/dist/hooks/index.js +33 -0
  5. package/dist/hooks/use-cancellation-policies.d.ts +20 -0
  6. package/dist/hooks/use-cancellation-policies.d.ts.map +1 -0
  7. package/dist/hooks/use-cancellation-policies.js +12 -0
  8. package/dist/hooks/use-cancellation-policy-mutation.d.ts +57 -0
  9. package/dist/hooks/use-cancellation-policy-mutation.d.ts.map +1 -0
  10. package/dist/hooks/use-cancellation-policy-mutation.js +49 -0
  11. package/dist/hooks/use-cancellation-policy-rule-mutation.d.ts +58 -0
  12. package/dist/hooks/use-cancellation-policy-rule-mutation.d.ts.map +1 -0
  13. package/dist/hooks/use-cancellation-policy-rule-mutation.js +49 -0
  14. package/dist/hooks/use-cancellation-policy-rule.d.ts +15 -0
  15. package/dist/hooks/use-cancellation-policy-rule.d.ts.map +1 -0
  16. package/dist/hooks/use-cancellation-policy-rule.js +12 -0
  17. package/dist/hooks/use-cancellation-policy-rules.d.ts +21 -0
  18. package/dist/hooks/use-cancellation-policy-rules.d.ts.map +1 -0
  19. package/dist/hooks/use-cancellation-policy-rules.js +12 -0
  20. package/dist/hooks/use-cancellation-policy.d.ts +14 -0
  21. package/dist/hooks/use-cancellation-policy.d.ts.map +1 -0
  22. package/dist/hooks/use-cancellation-policy.js +12 -0
  23. package/dist/hooks/use-dropoff-price-rule-mutation.d.ts +72 -0
  24. package/dist/hooks/use-dropoff-price-rule-mutation.d.ts.map +1 -0
  25. package/dist/hooks/use-dropoff-price-rule-mutation.js +52 -0
  26. package/dist/hooks/use-dropoff-price-rule.d.ts +18 -0
  27. package/dist/hooks/use-dropoff-price-rule.d.ts.map +1 -0
  28. package/dist/hooks/use-dropoff-price-rule.js +12 -0
  29. package/dist/hooks/use-dropoff-price-rules.d.ts +24 -0
  30. package/dist/hooks/use-dropoff-price-rules.d.ts.map +1 -0
  31. package/dist/hooks/use-dropoff-price-rules.js +12 -0
  32. package/dist/hooks/use-extra-price-rule-mutation.d.ts +72 -0
  33. package/dist/hooks/use-extra-price-rule-mutation.d.ts.map +1 -0
  34. package/dist/hooks/use-extra-price-rule-mutation.js +52 -0
  35. package/dist/hooks/use-extra-price-rule.d.ts +18 -0
  36. package/dist/hooks/use-extra-price-rule.d.ts.map +1 -0
  37. package/dist/hooks/use-extra-price-rule.js +12 -0
  38. package/dist/hooks/use-extra-price-rules.d.ts +24 -0
  39. package/dist/hooks/use-extra-price-rules.d.ts.map +1 -0
  40. package/dist/hooks/use-extra-price-rules.js +12 -0
  41. package/dist/hooks/use-option-price-rule-mutation.d.ts +98 -0
  42. package/dist/hooks/use-option-price-rule-mutation.d.ts.map +1 -0
  43. package/dist/hooks/use-option-price-rule-mutation.js +66 -0
  44. package/dist/hooks/use-option-price-rule.d.ts +24 -0
  45. package/dist/hooks/use-option-price-rule.d.ts.map +1 -0
  46. package/dist/hooks/use-option-price-rule.js +12 -0
  47. package/dist/hooks/use-option-price-rules.d.ts +30 -0
  48. package/dist/hooks/use-option-price-rules.d.ts.map +1 -0
  49. package/dist/hooks/use-option-price-rules.js +12 -0
  50. package/dist/hooks/use-option-start-time-rule-mutation.d.ts +70 -0
  51. package/dist/hooks/use-option-start-time-rule-mutation.d.ts.map +1 -0
  52. package/dist/hooks/use-option-start-time-rule-mutation.js +51 -0
  53. package/dist/hooks/use-option-start-time-rule.d.ts +17 -0
  54. package/dist/hooks/use-option-start-time-rule.d.ts.map +1 -0
  55. package/dist/hooks/use-option-start-time-rule.js +12 -0
  56. package/dist/hooks/use-option-start-time-rules.d.ts +23 -0
  57. package/dist/hooks/use-option-start-time-rules.d.ts.map +1 -0
  58. package/dist/hooks/use-option-start-time-rules.js +12 -0
  59. package/dist/hooks/use-option-unit-price-rule-mutation.d.ts +79 -0
  60. package/dist/hooks/use-option-unit-price-rule-mutation.d.ts.map +1 -0
  61. package/dist/hooks/use-option-unit-price-rule-mutation.js +54 -0
  62. package/dist/hooks/use-option-unit-price-rule.d.ts +19 -0
  63. package/dist/hooks/use-option-unit-price-rule.d.ts.map +1 -0
  64. package/dist/hooks/use-option-unit-price-rule.js +12 -0
  65. package/dist/hooks/use-option-unit-price-rules.d.ts +25 -0
  66. package/dist/hooks/use-option-unit-price-rules.d.ts.map +1 -0
  67. package/dist/hooks/use-option-unit-price-rules.js +12 -0
  68. package/dist/hooks/use-option-unit-tier-mutation.d.ts +50 -0
  69. package/dist/hooks/use-option-unit-tier-mutation.d.ts.map +1 -0
  70. package/dist/hooks/use-option-unit-tier-mutation.js +48 -0
  71. package/dist/hooks/use-option-unit-tier.d.ts +14 -0
  72. package/dist/hooks/use-option-unit-tier.d.ts.map +1 -0
  73. package/dist/hooks/use-option-unit-tier.js +12 -0
  74. package/dist/hooks/use-option-unit-tiers.d.ts +20 -0
  75. package/dist/hooks/use-option-unit-tiers.d.ts.map +1 -0
  76. package/dist/hooks/use-option-unit-tiers.js +12 -0
  77. package/dist/hooks/use-pickup-price-rule-mutation.d.ts +64 -0
  78. package/dist/hooks/use-pickup-price-rule-mutation.d.ts.map +1 -0
  79. package/dist/hooks/use-pickup-price-rule-mutation.js +50 -0
  80. package/dist/hooks/use-pickup-price-rule.d.ts +16 -0
  81. package/dist/hooks/use-pickup-price-rule.d.ts.map +1 -0
  82. package/dist/hooks/use-pickup-price-rule.js +12 -0
  83. package/dist/hooks/use-pickup-price-rules.d.ts +22 -0
  84. package/dist/hooks/use-pickup-price-rules.d.ts.map +1 -0
  85. package/dist/hooks/use-pickup-price-rules.js +12 -0
  86. package/dist/hooks/use-price-catalog-mutation.d.ts +60 -0
  87. package/dist/hooks/use-price-catalog-mutation.d.ts.map +1 -0
  88. package/dist/hooks/use-price-catalog-mutation.js +51 -0
  89. package/dist/hooks/use-price-catalog.d.ts +14 -0
  90. package/dist/hooks/use-price-catalog.d.ts.map +1 -0
  91. package/dist/hooks/use-price-catalog.js +12 -0
  92. package/dist/hooks/use-price-catalogs.d.ts +20 -0
  93. package/dist/hooks/use-price-catalogs.d.ts.map +1 -0
  94. package/dist/hooks/use-price-catalogs.js +12 -0
  95. package/dist/hooks/use-price-schedule-mutation.d.ts +76 -0
  96. package/dist/hooks/use-price-schedule-mutation.d.ts.map +1 -0
  97. package/dist/hooks/use-price-schedule-mutation.js +64 -0
  98. package/dist/hooks/use-price-schedule.d.ts +18 -0
  99. package/dist/hooks/use-price-schedule.d.ts.map +1 -0
  100. package/dist/hooks/use-price-schedule.js +12 -0
  101. package/dist/hooks/use-price-schedules.d.ts +28 -0
  102. package/dist/hooks/use-price-schedules.d.ts.map +1 -0
  103. package/dist/hooks/use-price-schedules.js +11 -0
  104. package/dist/hooks/use-pricing-categories.d.ts +1 -1
  105. package/dist/hooks/use-pricing-categories.d.ts.map +1 -1
  106. package/dist/hooks/use-pricing-categories.js +2 -0
  107. package/dist/hooks/use-pricing-category-mutation.d.ts +2 -2
  108. package/dist/hooks/use-pricing-category.d.ts +1 -1
  109. package/dist/hooks/use-pricing-category.d.ts.map +1 -1
  110. package/dist/hooks/use-pricing-category.js +2 -8
  111. package/dist/index.d.ts +1 -0
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +1 -0
  114. package/dist/provider.d.ts +1 -13
  115. package/dist/provider.d.ts.map +1 -1
  116. package/dist/provider.js +1 -16
  117. package/dist/query-keys.d.ts +116 -0
  118. package/dist/query-keys.d.ts.map +1 -1
  119. package/dist/query-keys.js +33 -0
  120. package/dist/query-options.d.ts +1727 -0
  121. package/dist/query-options.d.ts.map +1 -0
  122. package/dist/query-options.js +409 -0
  123. package/dist/schemas.d.ts +688 -3
  124. package/dist/schemas.d.ts.map +1 -1
  125. package/dist/schemas.js +165 -0
  126. package/package.json +42 -46
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { z } from "zod";
4
+ import { fetchWithValidation } from "../client.js";
5
+ import { useVoyantPricingContext } from "../provider.js";
6
+ import { pricingQueryKeys } from "../query-keys.js";
7
+ import { dropoffPriceRuleSingleResponse, successEnvelope } from "../schemas.js";
8
+ const dropoffPriceRuleInputSchema = z.object({
9
+ optionPriceRuleId: z.string(),
10
+ optionId: z.string(),
11
+ facilityId: z.string().nullable().optional(),
12
+ dropoffCode: z.string().max(100).nullable().optional(),
13
+ dropoffName: z.string().min(1).max(255),
14
+ pricingMode: z.enum(["included", "per_person", "per_booking", "on_request", "unavailable"]),
15
+ sellAmountCents: z.number().int().min(0).nullable().optional(),
16
+ costAmountCents: z.number().int().min(0).nullable().optional(),
17
+ active: z.boolean().optional(),
18
+ sortOrder: z.number().int().optional(),
19
+ notes: z.string().nullable().optional(),
20
+ });
21
+ export function useDropoffPriceRuleMutation() {
22
+ const { baseUrl, fetcher } = useVoyantPricingContext();
23
+ const queryClient = useQueryClient();
24
+ const create = useMutation({
25
+ mutationFn: async (input) => {
26
+ const { data } = await fetchWithValidation("/v1/pricing/dropoff-price-rules", dropoffPriceRuleSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
27
+ return data;
28
+ },
29
+ onSuccess: (data) => {
30
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.dropoffPriceRules() });
31
+ queryClient.setQueryData(pricingQueryKeys.dropoffPriceRule(data.id), data);
32
+ },
33
+ });
34
+ const update = useMutation({
35
+ mutationFn: async ({ id, input }) => {
36
+ const { data } = await fetchWithValidation(`/v1/pricing/dropoff-price-rules/${id}`, dropoffPriceRuleSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
37
+ return data;
38
+ },
39
+ onSuccess: (data) => {
40
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.dropoffPriceRules() });
41
+ queryClient.setQueryData(pricingQueryKeys.dropoffPriceRule(data.id), data);
42
+ },
43
+ });
44
+ const remove = useMutation({
45
+ mutationFn: async (id) => fetchWithValidation(`/v1/pricing/dropoff-price-rules/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
46
+ onSuccess: (_data, id) => {
47
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.dropoffPriceRules() });
48
+ queryClient.removeQueries({ queryKey: pricingQueryKeys.dropoffPriceRule(id) });
49
+ },
50
+ });
51
+ return { create, update, remove };
52
+ }
@@ -0,0 +1,18 @@
1
+ export interface UseDropoffPriceRuleOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useDropoffPriceRule(id: string | null | undefined, options?: UseDropoffPriceRuleOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ optionPriceRuleId: string;
7
+ optionId: string;
8
+ facilityId: string | null;
9
+ dropoffCode: string | null;
10
+ dropoffName: string;
11
+ pricingMode: "included" | "per_person" | "per_booking" | "on_request" | "unavailable";
12
+ sellAmountCents: number | null;
13
+ costAmountCents: number | null;
14
+ active: boolean;
15
+ sortOrder: number;
16
+ notes: string | null;
17
+ }, Error>;
18
+ //# sourceMappingURL=use-dropoff-price-rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-dropoff-price-rule.d.ts","sourceRoot":"","sources":["../../src/hooks/use-dropoff-price-rule.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7B,OAAO,GAAE,0BAA+B;;;;;;;;;;;;;UASzC"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantPricingContext } from "../provider.js";
4
+ import { getDropoffPriceRuleQueryOptions } from "../query-options.js";
5
+ export function useDropoffPriceRule(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantPricingContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getDropoffPriceRuleQueryOptions({ baseUrl, fetcher }, id ?? "__missing__"),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,24 @@
1
+ import type { DropoffPriceRulesListFilters } from "../query-keys.js";
2
+ export interface UseDropoffPriceRulesOptions extends DropoffPriceRulesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useDropoffPriceRules(options?: UseDropoffPriceRulesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ optionPriceRuleId: string;
9
+ optionId: string;
10
+ facilityId: string | null;
11
+ dropoffCode: string | null;
12
+ dropoffName: string;
13
+ pricingMode: "included" | "per_person" | "per_booking" | "on_request" | "unavailable";
14
+ sellAmountCents: number | null;
15
+ costAmountCents: number | null;
16
+ active: boolean;
17
+ sortOrder: number;
18
+ notes: string | null;
19
+ }[];
20
+ total: number;
21
+ limit: number;
22
+ offset: number;
23
+ }, Error>;
24
+ //# sourceMappingURL=use-dropoff-price-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-dropoff-price-rules.d.ts","sourceRoot":"","sources":["../../src/hooks/use-dropoff-price-rules.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAA;AAGpE,MAAM,WAAW,2BAA4B,SAAQ,4BAA4B;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC;;;;;;;;;;;;;;;;;;UAQ7E"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantPricingContext } from "../provider.js";
4
+ import { getDropoffPriceRulesQueryOptions } from "../query-options.js";
5
+ export function useDropoffPriceRules(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantPricingContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getDropoffPriceRulesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,72 @@
1
+ import { z } from "zod";
2
+ declare const extraPriceRuleInputSchema: z.ZodObject<{
3
+ optionPriceRuleId: z.ZodString;
4
+ optionId: z.ZodString;
5
+ productExtraId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
6
+ optionExtraConfigId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
7
+ pricingMode: z.ZodEnum<{
8
+ included: "included";
9
+ per_person: "per_person";
10
+ per_booking: "per_booking";
11
+ on_request: "on_request";
12
+ unavailable: "unavailable";
13
+ }>;
14
+ sellAmountCents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
15
+ costAmountCents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
16
+ active: z.ZodOptional<z.ZodBoolean>;
17
+ sortOrder: z.ZodOptional<z.ZodNumber>;
18
+ notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
20
+ }, z.core.$strip>;
21
+ export type CreateExtraPriceRuleInput = z.input<typeof extraPriceRuleInputSchema>;
22
+ export type UpdateExtraPriceRuleInput = Partial<CreateExtraPriceRuleInput>;
23
+ export declare function useExtraPriceRuleMutation(): {
24
+ create: import("@tanstack/react-query").UseMutationResult<{
25
+ id: string;
26
+ optionPriceRuleId: string;
27
+ optionId: string;
28
+ productExtraId: string | null;
29
+ optionExtraConfigId: string | null;
30
+ pricingMode: "included" | "per_person" | "per_booking" | "on_request" | "unavailable";
31
+ sellAmountCents: number | null;
32
+ costAmountCents: number | null;
33
+ active: boolean;
34
+ sortOrder: number;
35
+ notes: string | null;
36
+ metadata?: Record<string, unknown> | null | undefined;
37
+ }, Error, {
38
+ optionPriceRuleId: string;
39
+ optionId: string;
40
+ pricingMode: "included" | "per_person" | "per_booking" | "on_request" | "unavailable";
41
+ productExtraId?: string | null | undefined;
42
+ optionExtraConfigId?: string | null | undefined;
43
+ sellAmountCents?: number | null | undefined;
44
+ costAmountCents?: number | null | undefined;
45
+ active?: boolean | undefined;
46
+ sortOrder?: number | undefined;
47
+ notes?: string | null | undefined;
48
+ metadata?: Record<string, unknown> | null | undefined;
49
+ }, unknown>;
50
+ update: import("@tanstack/react-query").UseMutationResult<{
51
+ id: string;
52
+ optionPriceRuleId: string;
53
+ optionId: string;
54
+ productExtraId: string | null;
55
+ optionExtraConfigId: string | null;
56
+ pricingMode: "included" | "per_person" | "per_booking" | "on_request" | "unavailable";
57
+ sellAmountCents: number | null;
58
+ costAmountCents: number | null;
59
+ active: boolean;
60
+ sortOrder: number;
61
+ notes: string | null;
62
+ metadata?: Record<string, unknown> | null | undefined;
63
+ }, Error, {
64
+ id: string;
65
+ input: UpdateExtraPriceRuleInput;
66
+ }, unknown>;
67
+ remove: import("@tanstack/react-query").UseMutationResult<{
68
+ success: boolean;
69
+ }, Error, string, unknown>;
70
+ };
71
+ export {};
72
+ //# sourceMappingURL=use-extra-price-rule-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-extra-price-rule-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-extra-price-rule-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB,QAAA,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;iBAY7B,CAAA;AAEF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AACjF,MAAM,MAAM,yBAAyB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAA;AAE1E,wBAAgB,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBG,MAAM;eAAS,yBAAyB;;;;;EA8BnF"}
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { z } from "zod";
4
+ import { fetchWithValidation } from "../client.js";
5
+ import { useVoyantPricingContext } from "../provider.js";
6
+ import { pricingQueryKeys } from "../query-keys.js";
7
+ import { extraPriceRuleSingleResponse, successEnvelope } from "../schemas.js";
8
+ const extraPriceRuleInputSchema = z.object({
9
+ optionPriceRuleId: z.string(),
10
+ optionId: z.string(),
11
+ productExtraId: z.string().nullable().optional(),
12
+ optionExtraConfigId: z.string().nullable().optional(),
13
+ pricingMode: z.enum(["included", "per_person", "per_booking", "on_request", "unavailable"]),
14
+ sellAmountCents: z.number().int().min(0).nullable().optional(),
15
+ costAmountCents: z.number().int().min(0).nullable().optional(),
16
+ active: z.boolean().optional(),
17
+ sortOrder: z.number().int().optional(),
18
+ notes: z.string().nullable().optional(),
19
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
20
+ });
21
+ export function useExtraPriceRuleMutation() {
22
+ const { baseUrl, fetcher } = useVoyantPricingContext();
23
+ const queryClient = useQueryClient();
24
+ const create = useMutation({
25
+ mutationFn: async (input) => {
26
+ const { data } = await fetchWithValidation("/v1/pricing/extra-price-rules", extraPriceRuleSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
27
+ return data;
28
+ },
29
+ onSuccess: (data) => {
30
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.extraPriceRules() });
31
+ queryClient.setQueryData(pricingQueryKeys.extraPriceRule(data.id), data);
32
+ },
33
+ });
34
+ const update = useMutation({
35
+ mutationFn: async ({ id, input }) => {
36
+ const { data } = await fetchWithValidation(`/v1/pricing/extra-price-rules/${id}`, extraPriceRuleSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
37
+ return data;
38
+ },
39
+ onSuccess: (data) => {
40
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.extraPriceRules() });
41
+ queryClient.setQueryData(pricingQueryKeys.extraPriceRule(data.id), data);
42
+ },
43
+ });
44
+ const remove = useMutation({
45
+ mutationFn: async (id) => fetchWithValidation(`/v1/pricing/extra-price-rules/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
46
+ onSuccess: (_data, id) => {
47
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.extraPriceRules() });
48
+ queryClient.removeQueries({ queryKey: pricingQueryKeys.extraPriceRule(id) });
49
+ },
50
+ });
51
+ return { create, update, remove };
52
+ }
@@ -0,0 +1,18 @@
1
+ export interface UseExtraPriceRuleOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useExtraPriceRule(id: string | null | undefined, options?: UseExtraPriceRuleOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ optionPriceRuleId: string;
7
+ optionId: string;
8
+ productExtraId: string | null;
9
+ optionExtraConfigId: string | null;
10
+ pricingMode: "included" | "per_person" | "per_booking" | "on_request" | "unavailable";
11
+ sellAmountCents: number | null;
12
+ costAmountCents: number | null;
13
+ active: boolean;
14
+ sortOrder: number;
15
+ notes: string | null;
16
+ metadata?: Record<string, unknown> | null | undefined;
17
+ }, Error>;
18
+ //# sourceMappingURL=use-extra-price-rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-extra-price-rule.d.ts","sourceRoot":"","sources":["../../src/hooks/use-extra-price-rule.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7B,OAAO,GAAE,wBAA6B;;;;;;;;;;;;;UASvC"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantPricingContext } from "../provider.js";
4
+ import { getExtraPriceRuleQueryOptions } from "../query-options.js";
5
+ export function useExtraPriceRule(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantPricingContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getExtraPriceRuleQueryOptions({ baseUrl, fetcher }, id ?? "__missing__"),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,24 @@
1
+ import type { ExtraPriceRulesListFilters } from "../query-keys.js";
2
+ export interface UseExtraPriceRulesOptions extends ExtraPriceRulesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useExtraPriceRules(options?: UseExtraPriceRulesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ optionPriceRuleId: string;
9
+ optionId: string;
10
+ productExtraId: string | null;
11
+ optionExtraConfigId: string | null;
12
+ pricingMode: "included" | "per_person" | "per_booking" | "on_request" | "unavailable";
13
+ sellAmountCents: number | null;
14
+ costAmountCents: number | null;
15
+ active: boolean;
16
+ sortOrder: number;
17
+ notes: string | null;
18
+ metadata?: Record<string, unknown> | null | undefined;
19
+ }[];
20
+ total: number;
21
+ limit: number;
22
+ offset: number;
23
+ }, Error>;
24
+ //# sourceMappingURL=use-extra-price-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-extra-price-rules.d.ts","sourceRoot":"","sources":["../../src/hooks/use-extra-price-rules.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAGlE,MAAM,WAAW,yBAA0B,SAAQ,0BAA0B;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B;;;;;;;;;;;;;;;;;;UAQzE"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantPricingContext } from "../provider.js";
4
+ import { getExtraPriceRulesQueryOptions } from "../query-options.js";
5
+ export function useExtraPriceRules(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantPricingContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getExtraPriceRulesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,98 @@
1
+ import { z } from "zod";
2
+ declare const optionPriceRuleInputSchema: z.ZodObject<{
3
+ productId: z.ZodString;
4
+ optionId: z.ZodString;
5
+ priceCatalogId: z.ZodString;
6
+ priceScheduleId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
7
+ cancellationPolicyId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
9
+ name: z.ZodString;
10
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
+ pricingMode: z.ZodEnum<{
12
+ per_person: "per_person";
13
+ per_booking: "per_booking";
14
+ on_request: "on_request";
15
+ starting_from: "starting_from";
16
+ free: "free";
17
+ }>;
18
+ baseSellAmountCents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
19
+ baseCostAmountCents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
20
+ minPerBooking: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
21
+ maxPerBooking: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
22
+ allPricingCategories: z.ZodOptional<z.ZodBoolean>;
23
+ isDefault: z.ZodOptional<z.ZodBoolean>;
24
+ active: z.ZodOptional<z.ZodBoolean>;
25
+ notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
27
+ }, z.core.$strip>;
28
+ export type CreateOptionPriceRuleInput = z.input<typeof optionPriceRuleInputSchema>;
29
+ export type UpdateOptionPriceRuleInput = Partial<CreateOptionPriceRuleInput>;
30
+ export declare function useOptionPriceRuleMutation(): {
31
+ create: import("@tanstack/react-query").UseMutationResult<{
32
+ id: string;
33
+ productId: string;
34
+ optionId: string;
35
+ priceCatalogId: string;
36
+ priceScheduleId: string | null;
37
+ cancellationPolicyId: string | null;
38
+ code: string | null;
39
+ name: string;
40
+ description: string | null;
41
+ pricingMode: "per_person" | "per_booking" | "on_request" | "starting_from" | "free";
42
+ baseSellAmountCents: number | null;
43
+ baseCostAmountCents: number | null;
44
+ minPerBooking: number | null;
45
+ maxPerBooking: number | null;
46
+ allPricingCategories: boolean;
47
+ isDefault: boolean;
48
+ active: boolean;
49
+ notes: string | null;
50
+ }, Error, {
51
+ productId: string;
52
+ optionId: string;
53
+ priceCatalogId: string;
54
+ name: string;
55
+ pricingMode: "per_person" | "per_booking" | "on_request" | "starting_from" | "free";
56
+ priceScheduleId?: string | null | undefined;
57
+ cancellationPolicyId?: string | null | undefined;
58
+ code?: string | null | undefined;
59
+ description?: string | null | undefined;
60
+ baseSellAmountCents?: number | null | undefined;
61
+ baseCostAmountCents?: number | null | undefined;
62
+ minPerBooking?: number | null | undefined;
63
+ maxPerBooking?: number | null | undefined;
64
+ allPricingCategories?: boolean | undefined;
65
+ isDefault?: boolean | undefined;
66
+ active?: boolean | undefined;
67
+ notes?: string | null | undefined;
68
+ metadata?: Record<string, unknown> | null | undefined;
69
+ }, unknown>;
70
+ update: import("@tanstack/react-query").UseMutationResult<{
71
+ id: string;
72
+ productId: string;
73
+ optionId: string;
74
+ priceCatalogId: string;
75
+ priceScheduleId: string | null;
76
+ cancellationPolicyId: string | null;
77
+ code: string | null;
78
+ name: string;
79
+ description: string | null;
80
+ pricingMode: "per_person" | "per_booking" | "on_request" | "starting_from" | "free";
81
+ baseSellAmountCents: number | null;
82
+ baseCostAmountCents: number | null;
83
+ minPerBooking: number | null;
84
+ maxPerBooking: number | null;
85
+ allPricingCategories: boolean;
86
+ isDefault: boolean;
87
+ active: boolean;
88
+ notes: string | null;
89
+ }, Error, {
90
+ id: string;
91
+ input: UpdateOptionPriceRuleInput;
92
+ }, unknown>;
93
+ remove: import("@tanstack/react-query").UseMutationResult<{
94
+ success: boolean;
95
+ }, Error, string, unknown>;
96
+ };
97
+ export {};
98
+ //# sourceMappingURL=use-option-price-rule-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-option-price-rule-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-option-price-rule-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAevB,QAAA,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;iBAmB9B,CAAA;AAEF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AACnF,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAA;AAE5E,wBAAgB,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBE,MAAM;eAAS,0BAA0B;;;;;EA8BpF"}
@@ -0,0 +1,66 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { z } from "zod";
4
+ import { fetchWithValidation } from "../client.js";
5
+ import { useVoyantPricingContext } from "../provider.js";
6
+ import { pricingQueryKeys } from "../query-keys.js";
7
+ import { optionPriceRuleSingleResponse, successEnvelope } from "../schemas.js";
8
+ const optionPricingModeSchema = z.enum([
9
+ "per_person",
10
+ "per_booking",
11
+ "starting_from",
12
+ "free",
13
+ "on_request",
14
+ ]);
15
+ const optionPriceRuleInputSchema = z.object({
16
+ productId: z.string(),
17
+ optionId: z.string(),
18
+ priceCatalogId: z.string(),
19
+ priceScheduleId: z.string().nullable().optional(),
20
+ cancellationPolicyId: z.string().nullable().optional(),
21
+ code: z.string().max(100).nullable().optional(),
22
+ name: z.string().min(1).max(255),
23
+ description: z.string().nullable().optional(),
24
+ pricingMode: optionPricingModeSchema,
25
+ baseSellAmountCents: z.number().int().min(0).nullable().optional(),
26
+ baseCostAmountCents: z.number().int().min(0).nullable().optional(),
27
+ minPerBooking: z.number().int().min(0).nullable().optional(),
28
+ maxPerBooking: z.number().int().min(0).nullable().optional(),
29
+ allPricingCategories: z.boolean().optional(),
30
+ isDefault: z.boolean().optional(),
31
+ active: z.boolean().optional(),
32
+ notes: z.string().nullable().optional(),
33
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
34
+ });
35
+ export function useOptionPriceRuleMutation() {
36
+ const { baseUrl, fetcher } = useVoyantPricingContext();
37
+ const queryClient = useQueryClient();
38
+ const create = useMutation({
39
+ mutationFn: async (input) => {
40
+ const { data } = await fetchWithValidation("/v1/pricing/option-price-rules", optionPriceRuleSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
41
+ return data;
42
+ },
43
+ onSuccess: (data) => {
44
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.optionPriceRules() });
45
+ queryClient.setQueryData(pricingQueryKeys.optionPriceRule(data.id), data);
46
+ },
47
+ });
48
+ const update = useMutation({
49
+ mutationFn: async ({ id, input }) => {
50
+ const { data } = await fetchWithValidation(`/v1/pricing/option-price-rules/${id}`, optionPriceRuleSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
51
+ return data;
52
+ },
53
+ onSuccess: (data) => {
54
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.optionPriceRules() });
55
+ queryClient.setQueryData(pricingQueryKeys.optionPriceRule(data.id), data);
56
+ },
57
+ });
58
+ const remove = useMutation({
59
+ mutationFn: async (id) => fetchWithValidation(`/v1/pricing/option-price-rules/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
60
+ onSuccess: (_data, id) => {
61
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.optionPriceRules() });
62
+ queryClient.removeQueries({ queryKey: pricingQueryKeys.optionPriceRule(id) });
63
+ },
64
+ });
65
+ return { create, update, remove };
66
+ }
@@ -0,0 +1,24 @@
1
+ export interface UseOptionPriceRuleOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useOptionPriceRule(id: string | null | undefined, options?: UseOptionPriceRuleOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ productId: string;
7
+ optionId: string;
8
+ priceCatalogId: string;
9
+ priceScheduleId: string | null;
10
+ cancellationPolicyId: string | null;
11
+ code: string | null;
12
+ name: string;
13
+ description: string | null;
14
+ pricingMode: "per_person" | "per_booking" | "on_request" | "starting_from" | "free";
15
+ baseSellAmountCents: number | null;
16
+ baseCostAmountCents: number | null;
17
+ minPerBooking: number | null;
18
+ maxPerBooking: number | null;
19
+ allPricingCategories: boolean;
20
+ isDefault: boolean;
21
+ active: boolean;
22
+ notes: string | null;
23
+ }, Error>;
24
+ //# sourceMappingURL=use-option-price-rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-option-price-rule.d.ts","sourceRoot":"","sources":["../../src/hooks/use-option-price-rule.ts"],"names":[],"mappings":"AAOA,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;;;;;;;;;;;;;;;;;;;UASxC"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantPricingContext } from "../provider.js";
4
+ import { getOptionPriceRuleQueryOptions } from "../query-options.js";
5
+ export function useOptionPriceRule(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantPricingContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getOptionPriceRuleQueryOptions({ baseUrl, fetcher }, id ?? "__missing__"),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,30 @@
1
+ import type { OptionPriceRulesListFilters } from "../query-keys.js";
2
+ export interface UseOptionPriceRulesOptions extends OptionPriceRulesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useOptionPriceRules(options?: UseOptionPriceRulesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ productId: string;
9
+ optionId: string;
10
+ priceCatalogId: string;
11
+ priceScheduleId: string | null;
12
+ cancellationPolicyId: string | null;
13
+ code: string | null;
14
+ name: string;
15
+ description: string | null;
16
+ pricingMode: "per_person" | "per_booking" | "on_request" | "starting_from" | "free";
17
+ baseSellAmountCents: number | null;
18
+ baseCostAmountCents: number | null;
19
+ minPerBooking: number | null;
20
+ maxPerBooking: number | null;
21
+ allPricingCategories: boolean;
22
+ isDefault: boolean;
23
+ active: boolean;
24
+ notes: string | null;
25
+ }[];
26
+ total: number;
27
+ limit: number;
28
+ offset: number;
29
+ }, Error>;
30
+ //# sourceMappingURL=use-option-price-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-option-price-rules.d.ts","sourceRoot":"","sources":["../../src/hooks/use-option-price-rules.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAA;AAGnE,MAAM,WAAW,0BAA2B,SAAQ,2BAA2B;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,0BAA+B;;;;;;;;;;;;;;;;;;;;;;;;UAQ3E"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantPricingContext } from "../provider.js";
4
+ import { getOptionPriceRulesQueryOptions } from "../query-options.js";
5
+ export function useOptionPriceRules(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantPricingContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getOptionPriceRulesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }