@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,64 @@
1
+ import { z } from "zod";
2
+ declare const pickupPriceRuleInputSchema: z.ZodObject<{
3
+ optionPriceRuleId: z.ZodString;
4
+ optionId: z.ZodString;
5
+ pickupPointId: z.ZodString;
6
+ pricingMode: z.ZodEnum<{
7
+ included: "included";
8
+ per_person: "per_person";
9
+ per_booking: "per_booking";
10
+ on_request: "on_request";
11
+ unavailable: "unavailable";
12
+ }>;
13
+ sellAmountCents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
14
+ costAmountCents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
15
+ active: z.ZodOptional<z.ZodBoolean>;
16
+ sortOrder: z.ZodOptional<z.ZodNumber>;
17
+ notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
18
+ }, z.core.$strip>;
19
+ export type CreatePickupPriceRuleInput = z.input<typeof pickupPriceRuleInputSchema>;
20
+ export type UpdatePickupPriceRuleInput = Partial<CreatePickupPriceRuleInput>;
21
+ export declare function usePickupPriceRuleMutation(): {
22
+ create: import("@tanstack/react-query").UseMutationResult<{
23
+ id: string;
24
+ optionPriceRuleId: string;
25
+ optionId: string;
26
+ pickupPointId: string;
27
+ pricingMode: "included" | "per_person" | "per_booking" | "on_request" | "unavailable";
28
+ sellAmountCents: number | null;
29
+ costAmountCents: number | null;
30
+ active: boolean;
31
+ sortOrder: number;
32
+ notes: string | null;
33
+ }, Error, {
34
+ optionPriceRuleId: string;
35
+ optionId: string;
36
+ pickupPointId: string;
37
+ pricingMode: "included" | "per_person" | "per_booking" | "on_request" | "unavailable";
38
+ sellAmountCents?: number | null | undefined;
39
+ costAmountCents?: number | null | undefined;
40
+ active?: boolean | undefined;
41
+ sortOrder?: number | undefined;
42
+ notes?: string | null | undefined;
43
+ }, unknown>;
44
+ update: import("@tanstack/react-query").UseMutationResult<{
45
+ id: string;
46
+ optionPriceRuleId: string;
47
+ optionId: string;
48
+ pickupPointId: string;
49
+ pricingMode: "included" | "per_person" | "per_booking" | "on_request" | "unavailable";
50
+ sellAmountCents: number | null;
51
+ costAmountCents: number | null;
52
+ active: boolean;
53
+ sortOrder: number;
54
+ notes: string | null;
55
+ }, Error, {
56
+ id: string;
57
+ input: UpdatePickupPriceRuleInput;
58
+ }, unknown>;
59
+ remove: import("@tanstack/react-query").UseMutationResult<{
60
+ success: boolean;
61
+ }, Error, string, unknown>;
62
+ };
63
+ export {};
64
+ //# sourceMappingURL=use-pickup-price-rule-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pickup-price-rule-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pickup-price-rule-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB,QAAA,MAAM,0BAA0B;;;;;;;;;;;;;;;;iBAU9B,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,50 @@
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 { pickupPriceRuleSingleResponse, successEnvelope } from "../schemas.js";
8
+ const pickupPriceRuleInputSchema = z.object({
9
+ optionPriceRuleId: z.string(),
10
+ optionId: z.string(),
11
+ pickupPointId: z.string(),
12
+ pricingMode: z.enum(["included", "per_person", "per_booking", "on_request", "unavailable"]),
13
+ sellAmountCents: z.number().int().min(0).nullable().optional(),
14
+ costAmountCents: z.number().int().min(0).nullable().optional(),
15
+ active: z.boolean().optional(),
16
+ sortOrder: z.number().int().optional(),
17
+ notes: z.string().nullable().optional(),
18
+ });
19
+ export function usePickupPriceRuleMutation() {
20
+ const { baseUrl, fetcher } = useVoyantPricingContext();
21
+ const queryClient = useQueryClient();
22
+ const create = useMutation({
23
+ mutationFn: async (input) => {
24
+ const { data } = await fetchWithValidation("/v1/pricing/pickup-price-rules", pickupPriceRuleSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
25
+ return data;
26
+ },
27
+ onSuccess: (data) => {
28
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.pickupPriceRules() });
29
+ queryClient.setQueryData(pricingQueryKeys.pickupPriceRule(data.id), data);
30
+ },
31
+ });
32
+ const update = useMutation({
33
+ mutationFn: async ({ id, input }) => {
34
+ const { data } = await fetchWithValidation(`/v1/pricing/pickup-price-rules/${id}`, pickupPriceRuleSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
35
+ return data;
36
+ },
37
+ onSuccess: (data) => {
38
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.pickupPriceRules() });
39
+ queryClient.setQueryData(pricingQueryKeys.pickupPriceRule(data.id), data);
40
+ },
41
+ });
42
+ const remove = useMutation({
43
+ mutationFn: async (id) => fetchWithValidation(`/v1/pricing/pickup-price-rules/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
44
+ onSuccess: (_data, id) => {
45
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.pickupPriceRules() });
46
+ queryClient.removeQueries({ queryKey: pricingQueryKeys.pickupPriceRule(id) });
47
+ },
48
+ });
49
+ return { create, update, remove };
50
+ }
@@ -0,0 +1,16 @@
1
+ export interface UsePickupPriceRuleOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function usePickupPriceRule(id: string | null | undefined, options?: UsePickupPriceRuleOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ optionPriceRuleId: string;
7
+ optionId: string;
8
+ pickupPointId: string;
9
+ pricingMode: "included" | "per_person" | "per_booking" | "on_request" | "unavailable";
10
+ sellAmountCents: number | null;
11
+ costAmountCents: number | null;
12
+ active: boolean;
13
+ sortOrder: number;
14
+ notes: string | null;
15
+ }, Error>;
16
+ //# sourceMappingURL=use-pickup-price-rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pickup-price-rule.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pickup-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 { getPickupPriceRuleQueryOptions } from "../query-options.js";
5
+ export function usePickupPriceRule(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantPricingContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getPickupPriceRuleQueryOptions({ baseUrl, fetcher }, id ?? "__missing__"),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,22 @@
1
+ import type { PickupPriceRulesListFilters } from "../query-keys.js";
2
+ export interface UsePickupPriceRulesOptions extends PickupPriceRulesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function usePickupPriceRules(options?: UsePickupPriceRulesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ optionPriceRuleId: string;
9
+ optionId: string;
10
+ pickupPointId: 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
+ }[];
18
+ total: number;
19
+ limit: number;
20
+ offset: number;
21
+ }, Error>;
22
+ //# sourceMappingURL=use-pickup-price-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pickup-price-rules.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pickup-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 { getPickupPriceRulesQueryOptions } from "../query-options.js";
5
+ export function usePickupPriceRules(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantPricingContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getPickupPriceRulesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,60 @@
1
+ import { z } from "zod";
2
+ declare const priceCatalogInputSchema: z.ZodObject<{
3
+ code: z.ZodString;
4
+ name: z.ZodString;
5
+ currencyCode: z.ZodOptional<z.ZodNullable<z.ZodString>>;
6
+ catalogType: z.ZodEnum<{
7
+ public: "public";
8
+ contract: "contract";
9
+ net: "net";
10
+ gross: "gross";
11
+ promo: "promo";
12
+ internal: "internal";
13
+ other: "other";
14
+ }>;
15
+ isDefault: z.ZodOptional<z.ZodBoolean>;
16
+ active: z.ZodOptional<z.ZodBoolean>;
17
+ notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
18
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
19
+ }, z.core.$strip>;
20
+ export type CreatePriceCatalogInput = z.input<typeof priceCatalogInputSchema>;
21
+ export type UpdatePriceCatalogInput = Partial<CreatePriceCatalogInput>;
22
+ export declare function usePriceCatalogMutation(): {
23
+ create: import("@tanstack/react-query").UseMutationResult<{
24
+ id: string;
25
+ code: string;
26
+ name: string;
27
+ currencyCode: string;
28
+ catalogType: "public" | "contract" | "net" | "gross" | "promo" | "internal" | "other";
29
+ isDefault: boolean;
30
+ active: boolean;
31
+ notes: string | null;
32
+ }, Error, {
33
+ code: string;
34
+ name: string;
35
+ catalogType: "public" | "contract" | "net" | "gross" | "promo" | "internal" | "other";
36
+ currencyCode?: string | null | undefined;
37
+ isDefault?: boolean | undefined;
38
+ active?: boolean | undefined;
39
+ notes?: string | null | undefined;
40
+ metadata?: Record<string, unknown> | null | undefined;
41
+ }, unknown>;
42
+ update: import("@tanstack/react-query").UseMutationResult<{
43
+ id: string;
44
+ code: string;
45
+ name: string;
46
+ currencyCode: string;
47
+ catalogType: "public" | "contract" | "net" | "gross" | "promo" | "internal" | "other";
48
+ isDefault: boolean;
49
+ active: boolean;
50
+ notes: string | null;
51
+ }, Error, {
52
+ id: string;
53
+ input: UpdatePriceCatalogInput;
54
+ }, unknown>;
55
+ remove: import("@tanstack/react-query").UseMutationResult<{
56
+ success: boolean;
57
+ }, Error, string, unknown>;
58
+ };
59
+ export {};
60
+ //# sourceMappingURL=use-price-catalog-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-price-catalog-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-price-catalog-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAOvB,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;iBAS3B,CAAA;AAEF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAC7E,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AAEtE,wBAAgB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBK,MAAM;eAAS,uBAAuB;;;;;EAgCjF"}
@@ -0,0 +1,51 @@
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 { priceCatalogSingleResponse, successEnvelope } from "../schemas.js";
8
+ const priceCatalogInputSchema = z.object({
9
+ code: z.string().min(1).max(100),
10
+ name: z.string().min(1).max(255),
11
+ currencyCode: z.string().length(3).nullable().optional(),
12
+ catalogType: z.enum(["public", "contract", "net", "gross", "promo", "internal", "other"]),
13
+ isDefault: z.boolean().optional(),
14
+ active: z.boolean().optional(),
15
+ notes: z.string().nullable().optional(),
16
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
17
+ });
18
+ export function usePriceCatalogMutation() {
19
+ const { baseUrl, fetcher } = useVoyantPricingContext();
20
+ const queryClient = useQueryClient();
21
+ const create = useMutation({
22
+ mutationFn: async (input) => {
23
+ const { data } = await fetchWithValidation("/v1/pricing/price-catalogs", priceCatalogSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
24
+ return data;
25
+ },
26
+ onSuccess: (data) => {
27
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.priceCatalogs() });
28
+ queryClient.setQueryData(pricingQueryKeys.priceCatalog(data.id), data);
29
+ },
30
+ });
31
+ const update = useMutation({
32
+ mutationFn: async ({ id, input }) => {
33
+ const { data } = await fetchWithValidation(`/v1/pricing/price-catalogs/${id}`, priceCatalogSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
34
+ return data;
35
+ },
36
+ onSuccess: (data) => {
37
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.priceCatalogs() });
38
+ queryClient.setQueryData(pricingQueryKeys.priceCatalog(data.id), data);
39
+ },
40
+ });
41
+ const remove = useMutation({
42
+ mutationFn: async (id) => fetchWithValidation(`/v1/pricing/price-catalogs/${id}`, successEnvelope, { baseUrl, fetcher }, {
43
+ method: "DELETE",
44
+ }),
45
+ onSuccess: (_data, id) => {
46
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.priceCatalogs() });
47
+ queryClient.removeQueries({ queryKey: pricingQueryKeys.priceCatalog(id) });
48
+ },
49
+ });
50
+ return { create, update, remove };
51
+ }
@@ -0,0 +1,14 @@
1
+ export interface UsePriceCatalogOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function usePriceCatalog(id: string | null | undefined, options?: UsePriceCatalogOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ code: string;
7
+ name: string;
8
+ currencyCode: string;
9
+ catalogType: "public" | "contract" | "net" | "gross" | "promo" | "internal" | "other";
10
+ isDefault: boolean;
11
+ active: boolean;
12
+ notes: string | null;
13
+ }, Error>;
14
+ //# sourceMappingURL=use-price-catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-price-catalog.d.ts","sourceRoot":"","sources":["../../src/hooks/use-price-catalog.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,eAAe,CAC7B,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7B,OAAO,GAAE,sBAA2B;;;;;;;;;UASrC"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantPricingContext } from "../provider.js";
4
+ import { getPriceCatalogQueryOptions } from "../query-options.js";
5
+ export function usePriceCatalog(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantPricingContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getPriceCatalogQueryOptions({ baseUrl, fetcher }, id ?? "__missing__"),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,20 @@
1
+ import type { PriceCatalogsListFilters } from "../query-keys.js";
2
+ export interface UsePriceCatalogsOptions extends PriceCatalogsListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function usePriceCatalogs(options?: UsePriceCatalogsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ code: string;
9
+ name: string;
10
+ currencyCode: string;
11
+ catalogType: "public" | "contract" | "net" | "gross" | "promo" | "internal" | "other";
12
+ isDefault: boolean;
13
+ active: boolean;
14
+ notes: string | null;
15
+ }[];
16
+ total: number;
17
+ limit: number;
18
+ offset: number;
19
+ }, Error>;
20
+ //# sourceMappingURL=use-price-catalogs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-price-catalogs.d.ts","sourceRoot":"","sources":["../../src/hooks/use-price-catalogs.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAGhE,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACvE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B;;;;;;;;;;;;;;UAQrE"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantPricingContext } from "../provider.js";
4
+ import { getPriceCatalogsQueryOptions } from "../query-options.js";
5
+ export function usePriceCatalogs(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantPricingContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getPriceCatalogsQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,76 @@
1
+ import { z } from "zod";
2
+ declare const priceScheduleInputSchema: z.ZodObject<{
3
+ priceCatalogId: z.ZodString;
4
+ code: z.ZodOptional<z.ZodNullable<z.ZodString>>;
5
+ name: z.ZodString;
6
+ recurrenceRule: z.ZodString;
7
+ timezone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ validFrom: z.ZodOptional<z.ZodNullable<z.ZodString>>;
9
+ validTo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
10
+ weekdays: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
11
+ monday: "monday";
12
+ tuesday: "tuesday";
13
+ wednesday: "wednesday";
14
+ thursday: "thursday";
15
+ friday: "friday";
16
+ saturday: "saturday";
17
+ sunday: "sunday";
18
+ }>>>>;
19
+ priority: z.ZodOptional<z.ZodNumber>;
20
+ active: z.ZodOptional<z.ZodBoolean>;
21
+ notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
22
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
23
+ }, z.core.$strip>;
24
+ export type CreatePriceScheduleInput = z.input<typeof priceScheduleInputSchema>;
25
+ export type UpdatePriceScheduleInput = Partial<CreatePriceScheduleInput>;
26
+ export declare function usePriceScheduleMutation(): {
27
+ create: import("@tanstack/react-query").UseMutationResult<{
28
+ id: string;
29
+ priceCatalogId: string;
30
+ code: string | null;
31
+ name: string;
32
+ recurrenceRule: string;
33
+ timezone: string | null;
34
+ validFrom: string | null;
35
+ validTo: string | null;
36
+ weekdays: string[] | null;
37
+ priority: number;
38
+ active: boolean;
39
+ notes: string | null;
40
+ }, Error, {
41
+ priceCatalogId: string;
42
+ name: string;
43
+ recurrenceRule: string;
44
+ code?: string | null | undefined;
45
+ timezone?: string | null | undefined;
46
+ validFrom?: string | null | undefined;
47
+ validTo?: string | null | undefined;
48
+ weekdays?: ("monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday")[] | null | undefined;
49
+ priority?: number | undefined;
50
+ active?: boolean | undefined;
51
+ notes?: string | null | undefined;
52
+ metadata?: Record<string, unknown> | null | undefined;
53
+ }, unknown>;
54
+ update: import("@tanstack/react-query").UseMutationResult<{
55
+ id: string;
56
+ priceCatalogId: string;
57
+ code: string | null;
58
+ name: string;
59
+ recurrenceRule: string;
60
+ timezone: string | null;
61
+ validFrom: string | null;
62
+ validTo: string | null;
63
+ weekdays: string[] | null;
64
+ priority: number;
65
+ active: boolean;
66
+ notes: string | null;
67
+ }, Error, {
68
+ id: string;
69
+ input: UpdatePriceScheduleInput;
70
+ }, unknown>;
71
+ remove: import("@tanstack/react-query").UseMutationResult<{
72
+ success: boolean;
73
+ }, Error, string, unknown>;
74
+ };
75
+ export {};
76
+ //# sourceMappingURL=use-price-schedule-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-price-schedule-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-price-schedule-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAiBvB,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;iBAa5B,CAAA;AAEF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAC/E,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAA;AAExE,wBAAgB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBI,MAAM;eAAS,wBAAwB;;;;;EAgClF"}
@@ -0,0 +1,64 @@
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 { priceScheduleSingleResponse, successEnvelope } from "../schemas.js";
8
+ const weekdaySchema = z.enum([
9
+ "monday",
10
+ "tuesday",
11
+ "wednesday",
12
+ "thursday",
13
+ "friday",
14
+ "saturday",
15
+ "sunday",
16
+ ]);
17
+ const priceScheduleInputSchema = z.object({
18
+ priceCatalogId: z.string(),
19
+ code: z.string().max(100).nullable().optional(),
20
+ name: z.string().min(1).max(255),
21
+ recurrenceRule: z.string().min(1),
22
+ timezone: z.string().max(100).nullable().optional(),
23
+ validFrom: z.string().nullable().optional(),
24
+ validTo: z.string().nullable().optional(),
25
+ weekdays: z.array(weekdaySchema).nullable().optional(),
26
+ priority: z.number().int().optional(),
27
+ active: z.boolean().optional(),
28
+ notes: z.string().nullable().optional(),
29
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
30
+ });
31
+ export function usePriceScheduleMutation() {
32
+ const { baseUrl, fetcher } = useVoyantPricingContext();
33
+ const queryClient = useQueryClient();
34
+ const create = useMutation({
35
+ mutationFn: async (input) => {
36
+ const { data } = await fetchWithValidation("/v1/pricing/price-schedules", priceScheduleSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
37
+ return data;
38
+ },
39
+ onSuccess: (data) => {
40
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.priceSchedules() });
41
+ queryClient.setQueryData(pricingQueryKeys.priceSchedule(data.id), data);
42
+ },
43
+ });
44
+ const update = useMutation({
45
+ mutationFn: async ({ id, input }) => {
46
+ const { data } = await fetchWithValidation(`/v1/pricing/price-schedules/${id}`, priceScheduleSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
47
+ return data;
48
+ },
49
+ onSuccess: (data) => {
50
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.priceSchedules() });
51
+ queryClient.setQueryData(pricingQueryKeys.priceSchedule(data.id), data);
52
+ },
53
+ });
54
+ const remove = useMutation({
55
+ mutationFn: async (id) => fetchWithValidation(`/v1/pricing/price-schedules/${id}`, successEnvelope, { baseUrl, fetcher }, {
56
+ method: "DELETE",
57
+ }),
58
+ onSuccess: (_data, id) => {
59
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.priceSchedules() });
60
+ queryClient.removeQueries({ queryKey: pricingQueryKeys.priceSchedule(id) });
61
+ },
62
+ });
63
+ return { create, update, remove };
64
+ }
@@ -0,0 +1,18 @@
1
+ export interface UsePriceScheduleOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function usePriceSchedule(id: string | null | undefined, options?: UsePriceScheduleOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ priceCatalogId: string;
7
+ code: string | null;
8
+ name: string;
9
+ recurrenceRule: string;
10
+ timezone: string | null;
11
+ validFrom: string | null;
12
+ validTo: string | null;
13
+ weekdays: string[] | null;
14
+ priority: number;
15
+ active: boolean;
16
+ notes: string | null;
17
+ }, Error>;
18
+ //# sourceMappingURL=use-price-schedule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-price-schedule.d.ts","sourceRoot":"","sources":["../../src/hooks/use-price-schedule.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 { useVoyantPricingContext } from "../provider.js";
4
+ import { getPriceScheduleQueryOptions } from "../query-options.js";
5
+ export function usePriceSchedule(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantPricingContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getPriceScheduleQueryOptions({ baseUrl, fetcher }, id ?? "__missing__"),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,28 @@
1
+ export interface UsePriceSchedulesOptions {
2
+ priceCatalogId?: string | undefined;
3
+ active?: boolean | undefined;
4
+ search?: string | undefined;
5
+ limit?: number | undefined;
6
+ offset?: number | undefined;
7
+ enabled?: boolean | undefined;
8
+ }
9
+ export declare function usePriceSchedules(options?: UsePriceSchedulesOptions): import("@tanstack/react-query").UseQueryResult<{
10
+ data: {
11
+ id: string;
12
+ priceCatalogId: string;
13
+ code: string | null;
14
+ name: string;
15
+ recurrenceRule: string;
16
+ timezone: string | null;
17
+ validFrom: string | null;
18
+ validTo: string | null;
19
+ weekdays: string[] | null;
20
+ priority: number;
21
+ active: boolean;
22
+ notes: string | null;
23
+ }[];
24
+ total: number;
25
+ limit: number;
26
+ offset: number;
27
+ }, Error>;
28
+ //# sourceMappingURL=use-price-schedules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-price-schedules.d.ts","sourceRoot":"","sources":["../../src/hooks/use-price-schedules.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,wBAAwB;IACvC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B;;;;;;;;;;;;;;;;;;UAOvE"}
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantPricingContext } from "../provider.js";
4
+ import { getPriceSchedulesQueryOptions } from "../query-options.js";
5
+ export function usePriceSchedules(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantPricingContext();
7
+ return useQuery({
8
+ ...getPriceSchedulesQueryOptions({ baseUrl, fetcher }, options),
9
+ enabled: Boolean(options.enabled ?? true),
10
+ });
11
+ }
@@ -10,7 +10,7 @@ export declare function usePricingCategories(options?: UsePricingCategoriesOptio
10
10
  unitId: string | null;
11
11
  code: string | null;
12
12
  name: string;
13
- categoryType: "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle" | "service" | "other";
13
+ categoryType: "other" | "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle" | "service";
14
14
  seatOccupancy: number;
15
15
  groupSize: number | null;
16
16
  isAgeQualified: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"use-pricing-categories.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pricing-categories.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,4BAA4B,EAAoB,MAAM,kBAAkB,CAAA;AAGtF,MAAM,WAAW,2BAA4B,SAAQ,4BAA4B;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC;;;;;;;;;;;;;;;;;;;;;;;;UAwB7E"}
1
+ {"version":3,"file":"use-pricing-categories.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pricing-categories.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,4BAA4B,EAAoB,MAAM,kBAAkB,CAAA;AAGtF,MAAM,WAAW,2BAA4B,SAAQ,4BAA4B;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC;;;;;;;;;;;;;;;;;;;;;;;;UAyB7E"}
@@ -21,6 +21,8 @@ export function usePricingCategories(options = {}) {
21
21
  params.set("categoryType", filters.categoryType);
22
22
  if (filters.active !== undefined)
23
23
  params.set("active", String(filters.active));
24
+ if (filters.search)
25
+ params.set("search", filters.search);
24
26
  if (filters.limit !== undefined)
25
27
  params.set("limit", String(filters.limit));
26
28
  if (filters.offset !== undefined)