@voyant-travel/legal-react 0.119.2

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 (238) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +66 -0
  3. package/dist/admin/contract-detail-host.d.ts +21 -0
  4. package/dist/admin/contract-detail-host.d.ts.map +1 -0
  5. package/dist/admin/contract-detail-host.js +118 -0
  6. package/dist/admin/contract-dialog-fields.d.ts +79 -0
  7. package/dist/admin/contract-dialog-fields.d.ts.map +1 -0
  8. package/dist/admin/contract-dialog-fields.js +178 -0
  9. package/dist/admin/contract-dialog.d.ts +4 -0
  10. package/dist/admin/contract-dialog.d.ts.map +1 -0
  11. package/dist/admin/contract-dialog.js +479 -0
  12. package/dist/admin/contract-upload-field.d.ts +12 -0
  13. package/dist/admin/contract-upload-field.d.ts.map +1 -0
  14. package/dist/admin/contract-upload-field.js +31 -0
  15. package/dist/admin/contracts-host.d.ts +10 -0
  16. package/dist/admin/contracts-host.d.ts.map +1 -0
  17. package/dist/admin/contracts-host.js +32 -0
  18. package/dist/admin/index.d.ts +78 -0
  19. package/dist/admin/index.d.ts.map +1 -0
  20. package/dist/admin/index.js +193 -0
  21. package/dist/admin/legal-admin-shared.d.ts +31 -0
  22. package/dist/admin/legal-admin-shared.d.ts.map +1 -0
  23. package/dist/admin/legal-admin-shared.js +48 -0
  24. package/dist/admin/number-series-dialog.d.ts +11 -0
  25. package/dist/admin/number-series-dialog.d.ts.map +1 -0
  26. package/dist/admin/number-series-dialog.js +110 -0
  27. package/dist/admin/number-series-host.d.ts +7 -0
  28. package/dist/admin/number-series-host.d.ts.map +1 -0
  29. package/dist/admin/number-series-host.js +12 -0
  30. package/dist/admin/pages/contract-detail-page.d.ts +7 -0
  31. package/dist/admin/pages/contract-detail-page.d.ts.map +1 -0
  32. package/dist/admin/pages/contract-detail-page.js +9 -0
  33. package/dist/admin/pages/policy-detail-page.d.ts +7 -0
  34. package/dist/admin/pages/policy-detail-page.d.ts.map +1 -0
  35. package/dist/admin/pages/policy-detail-page.js +9 -0
  36. package/dist/admin/pages/template-detail-page.d.ts +7 -0
  37. package/dist/admin/pages/template-detail-page.d.ts.map +1 -0
  38. package/dist/admin/pages/template-detail-page.js +9 -0
  39. package/dist/admin/policies-host.d.ts +9 -0
  40. package/dist/admin/policies-host.d.ts.map +1 -0
  41. package/dist/admin/policies-host.js +16 -0
  42. package/dist/admin/policy-assignment-dialog.d.ts +11 -0
  43. package/dist/admin/policy-assignment-dialog.d.ts.map +1 -0
  44. package/dist/admin/policy-assignment-dialog.js +234 -0
  45. package/dist/admin/policy-detail-host.d.ts +12 -0
  46. package/dist/admin/policy-detail-host.d.ts.map +1 -0
  47. package/dist/admin/policy-detail-host.js +17 -0
  48. package/dist/admin/policy-dialog.d.ts +10 -0
  49. package/dist/admin/policy-dialog.d.ts.map +1 -0
  50. package/dist/admin/policy-dialog.js +81 -0
  51. package/dist/admin/template-detail-host.d.ts +11 -0
  52. package/dist/admin/template-detail-host.d.ts.map +1 -0
  53. package/dist/admin/template-detail-host.js +20 -0
  54. package/dist/admin/template-dialog.d.ts +10 -0
  55. package/dist/admin/template-dialog.d.ts.map +1 -0
  56. package/dist/admin/template-dialog.js +117 -0
  57. package/dist/admin/template-version-dialog.d.ts +9 -0
  58. package/dist/admin/template-version-dialog.d.ts.map +1 -0
  59. package/dist/admin/template-version-dialog.js +67 -0
  60. package/dist/admin/templates-host.d.ts +9 -0
  61. package/dist/admin/templates-host.d.ts.map +1 -0
  62. package/dist/admin/templates-host.js +20 -0
  63. package/dist/client.d.ts +14 -0
  64. package/dist/client.d.ts.map +1 -0
  65. package/dist/client.js +69 -0
  66. package/dist/components/attachment-dialog.d.ts +11 -0
  67. package/dist/components/attachment-dialog.d.ts.map +1 -0
  68. package/dist/components/attachment-dialog.js +154 -0
  69. package/dist/components/booking-contract-card.d.ts +37 -0
  70. package/dist/components/booking-contract-card.d.ts.map +1 -0
  71. package/dist/components/booking-contract-card.js +101 -0
  72. package/dist/components/contract-detail-page.d.ts +36 -0
  73. package/dist/components/contract-detail-page.d.ts.map +1 -0
  74. package/dist/components/contract-detail-page.js +156 -0
  75. package/dist/components/contract-dialog-fields.d.ts +114 -0
  76. package/dist/components/contract-dialog-fields.d.ts.map +1 -0
  77. package/dist/components/contract-dialog-fields.js +233 -0
  78. package/dist/components/contract-dialog.d.ts +5 -0
  79. package/dist/components/contract-dialog.d.ts.map +1 -0
  80. package/dist/components/contract-dialog.js +345 -0
  81. package/dist/components/contract-send-dialog.d.ts +37 -0
  82. package/dist/components/contract-send-dialog.d.ts.map +1 -0
  83. package/dist/components/contract-send-dialog.js +56 -0
  84. package/dist/components/contracts-page.d.ts +30 -0
  85. package/dist/components/contracts-page.d.ts.map +1 -0
  86. package/dist/components/contracts-page.js +192 -0
  87. package/dist/components/number-series-page.d.ts +13 -0
  88. package/dist/components/number-series-page.d.ts.map +1 -0
  89. package/dist/components/number-series-page.js +37 -0
  90. package/dist/components/policies-page.d.ts +13 -0
  91. package/dist/components/policies-page.d.ts.map +1 -0
  92. package/dist/components/policies-page.js +70 -0
  93. package/dist/components/policy-detail-page.d.ts +23 -0
  94. package/dist/components/policy-detail-page.d.ts.map +1 -0
  95. package/dist/components/policy-detail-page.js +171 -0
  96. package/dist/components/policy-rule-dialog.d.ts +12 -0
  97. package/dist/components/policy-rule-dialog.d.ts.map +1 -0
  98. package/dist/components/policy-rule-dialog.js +101 -0
  99. package/dist/components/policy-version-dialog.d.ts +11 -0
  100. package/dist/components/policy-version-dialog.d.ts.map +1 -0
  101. package/dist/components/policy-version-dialog.js +62 -0
  102. package/dist/components/signature-dialog.d.ts +9 -0
  103. package/dist/components/signature-dialog.d.ts.map +1 -0
  104. package/dist/components/signature-dialog.js +64 -0
  105. package/dist/components/template-detail-page.d.ts +10 -0
  106. package/dist/components/template-detail-page.d.ts.map +1 -0
  107. package/dist/components/template-detail-page.js +84 -0
  108. package/dist/components/templates-page.d.ts +27 -0
  109. package/dist/components/templates-page.d.ts.map +1 -0
  110. package/dist/components/templates-page.js +65 -0
  111. package/dist/hooks/index.d.ts +31 -0
  112. package/dist/hooks/index.d.ts.map +1 -0
  113. package/dist/hooks/index.js +30 -0
  114. package/dist/hooks/use-contract-attachment-mutation.d.ts +119 -0
  115. package/dist/hooks/use-contract-attachment-mutation.d.ts.map +1 -0
  116. package/dist/hooks/use-contract-attachment-mutation.js +72 -0
  117. package/dist/hooks/use-contract-attachments.d.ts +23 -0
  118. package/dist/hooks/use-contract-attachments.d.ts.map +1 -0
  119. package/dist/hooks/use-contract-attachments.js +12 -0
  120. package/dist/hooks/use-contract-mutation.d.ts +427 -0
  121. package/dist/hooks/use-contract-mutation.d.ts.map +1 -0
  122. package/dist/hooks/use-contract-mutation.js +151 -0
  123. package/dist/hooks/use-contract-signature-mutation.d.ts +35 -0
  124. package/dist/hooks/use-contract-signature-mutation.d.ts.map +1 -0
  125. package/dist/hooks/use-contract-signature-mutation.js +23 -0
  126. package/dist/hooks/use-contract-signatures.d.ts +28 -0
  127. package/dist/hooks/use-contract-signatures.d.ts.map +1 -0
  128. package/dist/hooks/use-contract-signatures.js +12 -0
  129. package/dist/hooks/use-contract-template-authoring.d.ts +5 -0
  130. package/dist/hooks/use-contract-template-authoring.d.ts.map +1 -0
  131. package/dist/hooks/use-contract-template-authoring.js +7 -0
  132. package/dist/hooks/use-contract-template-mutation.d.ts +56 -0
  133. package/dist/hooks/use-contract-template-mutation.d.ts.map +1 -0
  134. package/dist/hooks/use-contract-template-mutation.js +39 -0
  135. package/dist/hooks/use-contract-template-version-mutation.d.ts +22 -0
  136. package/dist/hooks/use-contract-template-version-mutation.d.ts.map +1 -0
  137. package/dist/hooks/use-contract-template-version-mutation.js +22 -0
  138. package/dist/hooks/use-contract-template-versions.d.ts +15 -0
  139. package/dist/hooks/use-contract-template-versions.d.ts.map +1 -0
  140. package/dist/hooks/use-contract-template-versions.js +12 -0
  141. package/dist/hooks/use-contract-template.d.ts +20 -0
  142. package/dist/hooks/use-contract-template.d.ts.map +1 -0
  143. package/dist/hooks/use-contract-template.js +12 -0
  144. package/dist/hooks/use-contract-templates.d.ts +26 -0
  145. package/dist/hooks/use-contract-templates.d.ts.map +1 -0
  146. package/dist/hooks/use-contract-templates.js +12 -0
  147. package/dist/hooks/use-contract.d.ts +47 -0
  148. package/dist/hooks/use-contract.d.ts.map +1 -0
  149. package/dist/hooks/use-contract.js +12 -0
  150. package/dist/hooks/use-contracts.d.ts +53 -0
  151. package/dist/hooks/use-contracts.d.ts.map +1 -0
  152. package/dist/hooks/use-contracts.js +12 -0
  153. package/dist/hooks/use-default-contract-template.d.ts +21 -0
  154. package/dist/hooks/use-default-contract-template.d.ts.map +1 -0
  155. package/dist/hooks/use-default-contract-template.js +12 -0
  156. package/dist/hooks/use-evaluate-cancellation.d.ts +46 -0
  157. package/dist/hooks/use-evaluate-cancellation.d.ts.map +1 -0
  158. package/dist/hooks/use-evaluate-cancellation.js +43 -0
  159. package/dist/hooks/use-number-series-mutation.d.ts +58 -0
  160. package/dist/hooks/use-number-series-mutation.d.ts.map +1 -0
  161. package/dist/hooks/use-number-series-mutation.js +38 -0
  162. package/dist/hooks/use-number-series.d.ts +24 -0
  163. package/dist/hooks/use-number-series.d.ts.map +1 -0
  164. package/dist/hooks/use-number-series.js +12 -0
  165. package/dist/hooks/use-policies.d.ts +22 -0
  166. package/dist/hooks/use-policies.d.ts.map +1 -0
  167. package/dist/hooks/use-policies.js +12 -0
  168. package/dist/hooks/use-policy-acceptances.d.ts +26 -0
  169. package/dist/hooks/use-policy-acceptances.d.ts.map +1 -0
  170. package/dist/hooks/use-policy-acceptances.js +12 -0
  171. package/dist/hooks/use-policy-assignment-mutation.d.ts +63 -0
  172. package/dist/hooks/use-policy-assignment-mutation.d.ts.map +1 -0
  173. package/dist/hooks/use-policy-assignment-mutation.js +41 -0
  174. package/dist/hooks/use-policy-assignments.d.ts +23 -0
  175. package/dist/hooks/use-policy-assignments.d.ts.map +1 -0
  176. package/dist/hooks/use-policy-assignments.js +12 -0
  177. package/dist/hooks/use-policy-mutation.d.ts +44 -0
  178. package/dist/hooks/use-policy-mutation.d.ts.map +1 -0
  179. package/dist/hooks/use-policy-mutation.js +40 -0
  180. package/dist/hooks/use-policy-rule-mutation.d.ts +56 -0
  181. package/dist/hooks/use-policy-rule-mutation.d.ts.map +1 -0
  182. package/dist/hooks/use-policy-rule-mutation.js +39 -0
  183. package/dist/hooks/use-policy-rules.d.ts +22 -0
  184. package/dist/hooks/use-policy-rules.d.ts.map +1 -0
  185. package/dist/hooks/use-policy-rules.js +12 -0
  186. package/dist/hooks/use-policy-version-mutation.d.ts +69 -0
  187. package/dist/hooks/use-policy-version-mutation.d.ts.map +1 -0
  188. package/dist/hooks/use-policy-version-mutation.js +50 -0
  189. package/dist/hooks/use-policy-versions.d.ts +19 -0
  190. package/dist/hooks/use-policy-versions.d.ts.map +1 -0
  191. package/dist/hooks/use-policy-versions.js +12 -0
  192. package/dist/hooks/use-policy.d.ts +16 -0
  193. package/dist/hooks/use-policy.d.ts.map +1 -0
  194. package/dist/hooks/use-policy.js +12 -0
  195. package/dist/hooks/use-resolve-policy.d.ts +72 -0
  196. package/dist/hooks/use-resolve-policy.d.ts.map +1 -0
  197. package/dist/hooks/use-resolve-policy.js +16 -0
  198. package/dist/hooks/use-term.d.ts +27 -0
  199. package/dist/hooks/use-term.d.ts.map +1 -0
  200. package/dist/hooks/use-term.js +12 -0
  201. package/dist/hooks/use-terms.d.ts +33 -0
  202. package/dist/hooks/use-terms.d.ts.map +1 -0
  203. package/dist/hooks/use-terms.js +12 -0
  204. package/dist/i18n/en.d.ts +548 -0
  205. package/dist/i18n/en.d.ts.map +1 -0
  206. package/dist/i18n/en.js +547 -0
  207. package/dist/i18n/index.d.ts +6 -0
  208. package/dist/i18n/index.d.ts.map +1 -0
  209. package/dist/i18n/index.js +4 -0
  210. package/dist/i18n/messages.d.ts +504 -0
  211. package/dist/i18n/messages.d.ts.map +1 -0
  212. package/dist/i18n/messages.js +29 -0
  213. package/dist/i18n/provider.d.ts +1118 -0
  214. package/dist/i18n/provider.d.ts.map +1 -0
  215. package/dist/i18n/provider.js +44 -0
  216. package/dist/i18n/ro.d.ts +548 -0
  217. package/dist/i18n/ro.d.ts.map +1 -0
  218. package/dist/i18n/ro.js +547 -0
  219. package/dist/index.d.ts +7 -0
  220. package/dist/index.d.ts.map +1 -0
  221. package/dist/index.js +6 -0
  222. package/dist/provider.d.ts +2 -0
  223. package/dist/provider.d.ts.map +1 -0
  224. package/dist/provider.js +1 -0
  225. package/dist/query-keys.d.ts +120 -0
  226. package/dist/query-keys.d.ts.map +1 -0
  227. package/dist/query-keys.js +27 -0
  228. package/dist/query-options.d.ts +1929 -0
  229. package/dist/query-options.d.ts.map +1 -0
  230. package/dist/query-options.js +183 -0
  231. package/dist/schemas.d.ts +1547 -0
  232. package/dist/schemas.d.ts.map +1 -0
  233. package/dist/schemas.js +269 -0
  234. package/dist/ui.d.ts +16 -0
  235. package/dist/ui.d.ts.map +1 -0
  236. package/dist/ui.js +15 -0
  237. package/package.json +159 -0
  238. package/src/styles.css +11 -0
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantLegalContext } from "../provider.js";
5
+ import { legalQueryKeys } from "../query-keys.js";
6
+ import { legalPolicySingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useLegalPolicyMutation() {
8
+ const { baseUrl, fetcher } = useVoyantLegalContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/admin/legal/policies", legalPolicySingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policies() });
17
+ queryClient.setQueryData(legalQueryKeys.policy(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input }) => {
22
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/${id}`, legalPolicySingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policies() });
27
+ queryClient.setQueryData(legalQueryKeys.policy(data.id), data);
28
+ },
29
+ });
30
+ const remove = useMutation({
31
+ mutationFn: async (id) => fetchWithValidation(`/v1/admin/legal/policies/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
32
+ onSuccess: (_data, id) => {
33
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policies() });
34
+ queryClient.removeQueries({ queryKey: legalQueryKeys.policy(id) });
35
+ queryClient.removeQueries({ queryKey: legalQueryKeys.policyVersions(id) });
36
+ queryClient.removeQueries({ queryKey: legalQueryKeys.policyAssignments({ policyId: id }) });
37
+ },
38
+ });
39
+ return { create, update, remove };
40
+ }
@@ -0,0 +1,56 @@
1
+ import type { insertPolicyRuleSchema, updatePolicyRuleSchema } from "@voyant-travel/legal/policies/validation";
2
+ import type { z } from "zod";
3
+ export type CreateLegalPolicyRuleInput = z.input<typeof insertPolicyRuleSchema>;
4
+ export type UpdateLegalPolicyRuleInput = z.input<typeof updatePolicyRuleSchema>;
5
+ export declare function useLegalPolicyRuleMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ ruleType: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
8
+ sortOrder: number;
9
+ id: string;
10
+ policyVersionId: string;
11
+ label: string | null;
12
+ daysBeforeDeparture: number | null;
13
+ refundPercent: number | null;
14
+ flatAmountCents: number | null;
15
+ currency: string | null;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ refundType?: "cash" | "credit" | "cash_or_credit" | "none" | null | undefined;
19
+ validFrom?: string | null | undefined;
20
+ validTo?: string | null | undefined;
21
+ conditions?: Record<string, unknown> | null | undefined;
22
+ }, Error, {
23
+ versionId: string;
24
+ input: CreateLegalPolicyRuleInput;
25
+ }, unknown>;
26
+ update: import("@tanstack/react-query").UseMutationResult<{
27
+ ruleType: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
28
+ sortOrder: number;
29
+ id: string;
30
+ policyVersionId: string;
31
+ label: string | null;
32
+ daysBeforeDeparture: number | null;
33
+ refundPercent: number | null;
34
+ flatAmountCents: number | null;
35
+ currency: string | null;
36
+ createdAt: string;
37
+ updatedAt: string;
38
+ refundType?: "cash" | "credit" | "cash_or_credit" | "none" | null | undefined;
39
+ validFrom?: string | null | undefined;
40
+ validTo?: string | null | undefined;
41
+ conditions?: Record<string, unknown> | null | undefined;
42
+ }, Error, {
43
+ id: string;
44
+ input: UpdateLegalPolicyRuleInput;
45
+ }, unknown>;
46
+ remove: import("@tanstack/react-query").UseMutationResult<{
47
+ versionId: string;
48
+ data: {
49
+ success: boolean;
50
+ };
51
+ }, Error, {
52
+ versionId: string;
53
+ id: string;
54
+ }, unknown>;
55
+ };
56
+ //# sourceMappingURL=use-policy-rule-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy-rule-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy-rule-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,0CAA0C,CAAA;AACjD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAM5B,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAC/E,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAE/E,wBAAgB,0BAA0B;;;;;;;;;;;;;;;;;;mBASzB,MAAM;eACV,0BAA0B;;;;;;;;;;;;;;;;;;;YAkBK,MAAM;eAAS,0BAA0B;;;;;;;;mBAiB9B,MAAM;YAAM,MAAM;;EAaxE"}
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantLegalContext } from "../provider.js";
5
+ import { legalQueryKeys } from "../query-keys.js";
6
+ import { legalPolicyRuleSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useLegalPolicyRuleMutation() {
8
+ const { baseUrl, fetcher } = useVoyantLegalContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async ({ versionId, input, }) => {
12
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/versions/${versionId}/rules`, legalPolicyRuleSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({
17
+ queryKey: legalQueryKeys.policyRules(data.policyVersionId),
18
+ });
19
+ },
20
+ });
21
+ const update = useMutation({
22
+ mutationFn: async ({ id, input }) => {
23
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/rules/${id}`, legalPolicyRuleSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
24
+ return data;
25
+ },
26
+ onSuccess: (data) => {
27
+ void queryClient.invalidateQueries({
28
+ queryKey: legalQueryKeys.policyRules(data.policyVersionId),
29
+ });
30
+ },
31
+ });
32
+ const remove = useMutation({
33
+ mutationFn: async ({ versionId, id }) => fetchWithValidation(`/v1/admin/legal/policies/rules/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }).then((data) => ({ versionId, data })),
34
+ onSuccess: ({ versionId }) => {
35
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policyRules(versionId) });
36
+ },
37
+ });
38
+ return { create, update, remove };
39
+ }
@@ -0,0 +1,22 @@
1
+ export interface UseLegalPolicyRulesOptions {
2
+ versionId: string;
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useLegalPolicyRules(options: UseLegalPolicyRulesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ ruleType: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
7
+ sortOrder: number;
8
+ id: string;
9
+ policyVersionId: string;
10
+ label: string | null;
11
+ daysBeforeDeparture: number | null;
12
+ refundPercent: number | null;
13
+ flatAmountCents: number | null;
14
+ currency: string | null;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ refundType?: "cash" | "credit" | "cash_or_credit" | "none" | null | undefined;
18
+ validFrom?: string | null | undefined;
19
+ validTo?: string | null | undefined;
20
+ conditions?: Record<string, unknown> | null | undefined;
21
+ }[], Error>;
22
+ //# sourceMappingURL=use-policy-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy-rules.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy-rules.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B;;;;;;;;;;;;;;;;YAOtE"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantLegalContext } from "../provider.js";
4
+ import { getLegalPolicyRulesQueryOptions } from "../query-options.js";
5
+ export function useLegalPolicyRules(options) {
6
+ const { baseUrl, fetcher } = useVoyantLegalContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getLegalPolicyRulesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,69 @@
1
+ import type { insertPolicyVersionSchema, updatePolicyVersionSchema } from "@voyant-travel/legal/policies/validation";
2
+ import type { z } from "zod";
3
+ export type CreateLegalPolicyVersionInput = z.input<typeof insertPolicyVersionSchema>;
4
+ export type UpdateLegalPolicyVersionInput = z.input<typeof updatePolicyVersionSchema>;
5
+ export declare function useLegalPolicyVersionMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ title: string;
8
+ id: string;
9
+ policyId: string;
10
+ version: number;
11
+ status: "draft" | "published" | "retired";
12
+ body: string | null;
13
+ publishedAt: string | null;
14
+ publishedBy: string | null;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ retiredAt?: string | null | undefined;
18
+ metadata?: Record<string, unknown> | null | undefined;
19
+ }, Error, {
20
+ policyId: string;
21
+ input: CreateLegalPolicyVersionInput;
22
+ }, unknown>;
23
+ update: import("@tanstack/react-query").UseMutationResult<{
24
+ title: string;
25
+ id: string;
26
+ policyId: string;
27
+ version: number;
28
+ status: "draft" | "published" | "retired";
29
+ body: string | null;
30
+ publishedAt: string | null;
31
+ publishedBy: string | null;
32
+ createdAt: string;
33
+ updatedAt: string;
34
+ retiredAt?: string | null | undefined;
35
+ metadata?: Record<string, unknown> | null | undefined;
36
+ }, Error, {
37
+ id: string;
38
+ input: UpdateLegalPolicyVersionInput;
39
+ }, unknown>;
40
+ publish: import("@tanstack/react-query").UseMutationResult<{
41
+ title: string;
42
+ id: string;
43
+ policyId: string;
44
+ version: number;
45
+ status: "draft" | "published" | "retired";
46
+ body: string | null;
47
+ publishedAt: string | null;
48
+ publishedBy: string | null;
49
+ createdAt: string;
50
+ updatedAt: string;
51
+ retiredAt?: string | null | undefined;
52
+ metadata?: Record<string, unknown> | null | undefined;
53
+ }, Error, string, unknown>;
54
+ retire: import("@tanstack/react-query").UseMutationResult<{
55
+ title: string;
56
+ id: string;
57
+ policyId: string;
58
+ version: number;
59
+ status: "draft" | "published" | "retired";
60
+ body: string | null;
61
+ publishedAt: string | null;
62
+ publishedBy: string | null;
63
+ createdAt: string;
64
+ updatedAt: string;
65
+ retiredAt?: string | null | undefined;
66
+ metadata?: Record<string, unknown> | null | undefined;
67
+ }, Error, string, unknown>;
68
+ };
69
+ //# sourceMappingURL=use-policy-version-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy-version-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy-version-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,yBAAyB,EACzB,yBAAyB,EAC1B,MAAM,0CAA0C,CAAA;AACjD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAM5B,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AACrF,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAErF,wBAAgB,6BAA6B;;;;;;;;;;;;;;;kBAS7B,MAAM;eACT,6BAA6B;;;;;;;;;;;;;;;;YAgBE,MAAM;eAAS,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDvF"}
@@ -0,0 +1,50 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantLegalContext } from "../provider.js";
5
+ import { legalQueryKeys } from "../query-keys.js";
6
+ import { legalPolicyVersionSingleResponse } from "../schemas.js";
7
+ export function useLegalPolicyVersionMutation() {
8
+ const { baseUrl, fetcher } = useVoyantLegalContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async ({ policyId, input, }) => {
12
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/${policyId}/versions`, legalPolicyVersionSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policyVersions(data.policyId) });
17
+ },
18
+ });
19
+ const update = useMutation({
20
+ mutationFn: async ({ id, input }) => {
21
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/versions/${id}`, legalPolicyVersionSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
22
+ return data;
23
+ },
24
+ onSuccess: (data) => {
25
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policyVersions(data.policyId) });
26
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policy(data.policyId) });
27
+ },
28
+ });
29
+ const publish = useMutation({
30
+ mutationFn: async (id) => {
31
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/versions/${id}/publish`, legalPolicyVersionSingleResponse, { baseUrl, fetcher }, { method: "POST" });
32
+ return data;
33
+ },
34
+ onSuccess: (data) => {
35
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policyVersions(data.policyId) });
36
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policy(data.policyId) });
37
+ },
38
+ });
39
+ const retire = useMutation({
40
+ mutationFn: async (id) => {
41
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/versions/${id}/retire`, legalPolicyVersionSingleResponse, { baseUrl, fetcher }, { method: "POST" });
42
+ return data;
43
+ },
44
+ onSuccess: (data) => {
45
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policyVersions(data.policyId) });
46
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policy(data.policyId) });
47
+ },
48
+ });
49
+ return { create, update, publish, retire };
50
+ }
@@ -0,0 +1,19 @@
1
+ export interface UseLegalPolicyVersionsOptions {
2
+ policyId: string;
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useLegalPolicyVersions(options: UseLegalPolicyVersionsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ title: string;
7
+ id: string;
8
+ policyId: string;
9
+ version: number;
10
+ status: "draft" | "published" | "retired";
11
+ body: string | null;
12
+ publishedAt: string | null;
13
+ publishedBy: string | null;
14
+ createdAt: string;
15
+ updatedAt: string;
16
+ retiredAt?: string | null | undefined;
17
+ metadata?: Record<string, unknown> | null | undefined;
18
+ }[], Error>;
19
+ //# sourceMappingURL=use-policy-versions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy-versions.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy-versions.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,6BAA6B;;;;;;;;;;;;;YAO5E"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantLegalContext } from "../provider.js";
4
+ import { getLegalPolicyVersionsQueryOptions } from "../query-options.js";
5
+ export function useLegalPolicyVersions(options) {
6
+ const { baseUrl, fetcher } = useVoyantLegalContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getLegalPolicyVersionsQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,16 @@
1
+ export interface UseLegalPolicyOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useLegalPolicy(id: string, options?: UseLegalPolicyOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ kind: "other" | "cancellation" | "payment" | "terms_and_conditions" | "privacy" | "refund" | "commission" | "guarantee";
6
+ name: string;
7
+ slug: string;
8
+ language: string;
9
+ id: string;
10
+ description: string | null;
11
+ createdAt: string;
12
+ updatedAt: string;
13
+ metadata?: Record<string, unknown> | null | undefined;
14
+ currentVersionId?: string | null | undefined;
15
+ }, Error>;
16
+ //# sourceMappingURL=use-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B;;;;;;;;;;;UAO7E"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantLegalContext } from "../provider.js";
4
+ import { getLegalPolicyQueryOptions } from "../query-options.js";
5
+ export function useLegalPolicy(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantLegalContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getLegalPolicyQueryOptions({ baseUrl, fetcher }, id),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,72 @@
1
+ import type { ResolvePolicyFilters } from "../query-keys.js";
2
+ export interface UseResolvePolicyOptions {
3
+ enabled?: boolean;
4
+ }
5
+ /**
6
+ * Resolves the applicable policy for the given scope (kind + productId, channelId, etc.).
7
+ * Typically used with `kind: "cancellation"` to find the policy that applies to a booking.
8
+ */
9
+ export declare function useResolvePolicy(filters: ResolvePolicyFilters, options?: UseResolvePolicyOptions): import("@tanstack/react-query").UseQueryResult<{
10
+ data: {
11
+ policy: {
12
+ kind: "other" | "cancellation" | "payment" | "terms_and_conditions" | "privacy" | "refund" | "commission" | "guarantee";
13
+ name: string;
14
+ slug: string;
15
+ language: string;
16
+ id: string;
17
+ description: string | null;
18
+ createdAt: string;
19
+ updatedAt: string;
20
+ metadata?: Record<string, unknown> | null | undefined;
21
+ currentVersionId?: string | null | undefined;
22
+ };
23
+ assignment: {
24
+ policyId: string;
25
+ scope: "product" | "supplier" | "channel" | "market" | "organization" | "global";
26
+ priority: number;
27
+ id: string;
28
+ productId: string | null;
29
+ channelId: string | null;
30
+ supplierId: string | null;
31
+ marketId: string | null;
32
+ organizationId: string | null;
33
+ createdAt: string;
34
+ updatedAt: string;
35
+ validFrom?: string | null | undefined;
36
+ validTo?: string | null | undefined;
37
+ metadata?: Record<string, unknown> | null | undefined;
38
+ };
39
+ version: {
40
+ title: string;
41
+ id: string;
42
+ policyId: string;
43
+ version: number;
44
+ status: "draft" | "published" | "retired";
45
+ body: string | null;
46
+ publishedAt: string | null;
47
+ publishedBy: string | null;
48
+ createdAt: string;
49
+ updatedAt: string;
50
+ retiredAt?: string | null | undefined;
51
+ metadata?: Record<string, unknown> | null | undefined;
52
+ } | null;
53
+ rules: {
54
+ ruleType: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
55
+ sortOrder: number;
56
+ id: string;
57
+ policyVersionId: string;
58
+ label: string | null;
59
+ daysBeforeDeparture: number | null;
60
+ refundPercent: number | null;
61
+ flatAmountCents: number | null;
62
+ currency: string | null;
63
+ createdAt: string;
64
+ updatedAt: string;
65
+ refundType?: "cash" | "credit" | "cash_or_credit" | "none" | null | undefined;
66
+ validFrom?: string | null | undefined;
67
+ validTo?: string | null | undefined;
68
+ conditions?: Record<string, unknown> | null | undefined;
69
+ }[];
70
+ } | null;
71
+ }, Error>;
72
+ //# sourceMappingURL=use-resolve-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-resolve-policy.d.ts","sourceRoot":"","sources":["../../src/hooks/use-resolve-policy.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAG5D,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,oBAAoB,EAC7B,OAAO,GAAE,uBAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAStC"}
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantLegalContext } from "../provider.js";
4
+ import { getResolvePolicyQueryOptions } from "../query-options.js";
5
+ /**
6
+ * Resolves the applicable policy for the given scope (kind + productId, channelId, etc.).
7
+ * Typically used with `kind: "cancellation"` to find the policy that applies to a booking.
8
+ */
9
+ export function useResolvePolicy(filters, options = {}) {
10
+ const { baseUrl, fetcher } = useVoyantLegalContext();
11
+ const { enabled = true } = options;
12
+ return useQuery({
13
+ ...getResolvePolicyQueryOptions({ baseUrl, fetcher }, filters),
14
+ enabled: enabled && Boolean(filters.kind),
15
+ });
16
+ }
@@ -0,0 +1,27 @@
1
+ export interface UseLegalTermOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useLegalTerm(id: string, options?: UseLegalTermOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ termType: "other" | "cancellation" | "payment" | "terms_and_conditions" | "commission" | "guarantee" | "pricing";
7
+ title: string;
8
+ body: string;
9
+ required: boolean;
10
+ sortOrder: number;
11
+ acceptanceStatus: "pending" | "not_required" | "accepted" | "declined";
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ contractId?: string | null | undefined;
15
+ policyVersionId?: string | null | undefined;
16
+ targetKind?: "booking" | "quote_version" | "program" | "product" | "inventory_item" | "supplier_channel_relationship" | "provider_source_ref" | null | undefined;
17
+ targetId?: string | null | undefined;
18
+ targetProvider?: string | null | undefined;
19
+ targetSourceRef?: string | null | undefined;
20
+ legacyTransactionOfferId?: string | null | undefined;
21
+ legacyTransactionOrderId?: string | null | undefined;
22
+ language?: string | null | undefined;
23
+ acceptedAt?: string | null | undefined;
24
+ acceptedBy?: string | null | undefined;
25
+ metadata?: Record<string, unknown> | null | undefined;
26
+ }, Error>;
27
+ //# sourceMappingURL=use-term.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-term.d.ts","sourceRoot":"","sources":["../../src/hooks/use-term.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB;;;;;;;;;;;;;;;;;;;;;;UAQzE"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantLegalContext } from "../provider.js";
4
+ import { getLegalTermQueryOptions } from "../query-options.js";
5
+ export function useLegalTerm(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantLegalContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getLegalTermQueryOptions({ baseUrl, fetcher }, id),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,33 @@
1
+ import type { LegalTermsListFilters } from "../query-keys.js";
2
+ export interface UseLegalTermsOptions extends LegalTermsListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useLegalTerms(options?: UseLegalTermsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ termType: "other" | "cancellation" | "payment" | "terms_and_conditions" | "commission" | "guarantee" | "pricing";
9
+ title: string;
10
+ body: string;
11
+ required: boolean;
12
+ sortOrder: number;
13
+ acceptanceStatus: "pending" | "not_required" | "accepted" | "declined";
14
+ createdAt: string;
15
+ updatedAt: string;
16
+ contractId?: string | null | undefined;
17
+ policyVersionId?: string | null | undefined;
18
+ targetKind?: "booking" | "quote_version" | "program" | "product" | "inventory_item" | "supplier_channel_relationship" | "provider_source_ref" | null | undefined;
19
+ targetId?: string | null | undefined;
20
+ targetProvider?: string | null | undefined;
21
+ targetSourceRef?: string | null | undefined;
22
+ legacyTransactionOfferId?: string | null | undefined;
23
+ legacyTransactionOrderId?: string | null | undefined;
24
+ language?: string | null | undefined;
25
+ acceptedAt?: string | null | undefined;
26
+ acceptedBy?: string | null | undefined;
27
+ metadata?: Record<string, unknown> | null | undefined;
28
+ }[];
29
+ total: number;
30
+ limit: number;
31
+ offset: number;
32
+ }, Error>;
33
+ //# sourceMappingURL=use-terms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-terms.d.ts","sourceRoot":"","sources":["../../src/hooks/use-terms.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAG7D,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,aAAa,CAAC,OAAO,GAAE,oBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;UAQ/D"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantLegalContext } from "../provider.js";
4
+ import { getLegalTermsQueryOptions } from "../query-options.js";
5
+ export function useLegalTerms(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantLegalContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getLegalTermsQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }