@voyantjs/booking-requirements-react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/client.d.ts +14 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +59 -0
- package/dist/constants.d.ts +114 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +45 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/use-booking-questions.d.ts +24 -0
- package/dist/hooks/use-booking-questions.d.ts.map +1 -0
- package/dist/hooks/use-booking-questions.js +9 -0
- package/dist/hooks/use-contact-requirements.d.ts +22 -0
- package/dist/hooks/use-contact-requirements.d.ts.map +1 -0
- package/dist/hooks/use-contact-requirements.js +9 -0
- package/dist/hooks/use-products.d.ts +16 -0
- package/dist/hooks/use-products.d.ts.map +1 -0
- package/dist/hooks/use-products.js +9 -0
- package/dist/hooks/use-question-options.d.ts +19 -0
- package/dist/hooks/use-question-options.d.ts.map +1 -0
- package/dist/hooks/use-question-options.js +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +1 -0
- package/dist/query-keys.d.ts +27 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +11 -0
- package/dist/query-options.d.ts +266 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +66 -0
- package/dist/schemas.d.ts +238 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +91 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +4 -0
- package/package.json +79 -0
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @voyantjs/booking-requirements-react
|
|
2
|
+
|
|
3
|
+
React runtime package for Voyant booking requirements. Provides the shared provider, typed fetch client, query keys, constants, and TanStack Query hooks that power booking-requirements-focused frontend experiences.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @voyantjs/booking-requirements-react @voyantjs/booking-requirements @tanstack/react-query react react-dom zod
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import {
|
|
15
|
+
VoyantBookingRequirementsProvider,
|
|
16
|
+
useProducts,
|
|
17
|
+
} from "@voyantjs/booking-requirements-react"
|
|
18
|
+
|
|
19
|
+
function App() {
|
|
20
|
+
return (
|
|
21
|
+
<VoyantBookingRequirementsProvider baseUrl="/api">
|
|
22
|
+
<ProductsList />
|
|
23
|
+
</VoyantBookingRequirementsProvider>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function ProductsList() {
|
|
28
|
+
const { data } = useProducts({ limit: 50 })
|
|
29
|
+
return <>{data?.data.map((product) => <div key={product.id}>{product.name}</div>)}</>
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
FSL-1.1-Apache-2.0
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
export type VoyantFetcher = (url: string, init?: RequestInit) => Promise<Response>;
|
|
3
|
+
export declare const defaultFetcher: VoyantFetcher;
|
|
4
|
+
export declare class VoyantApiError extends Error {
|
|
5
|
+
readonly status: number;
|
|
6
|
+
readonly body: unknown;
|
|
7
|
+
constructor(message: string, status: number, body: unknown);
|
|
8
|
+
}
|
|
9
|
+
export interface FetchWithValidationOptions {
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
fetcher: VoyantFetcher;
|
|
12
|
+
}
|
|
13
|
+
export declare function fetchWithValidation<TOut>(path: string, schema: z.ZodType<TOut>, options: FetchWithValidationOptions, init?: RequestInit): Promise<TOut>;
|
|
14
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAElF,eAAO,MAAM,cAAc,EAAE,aACoB,CAAA;AAEjD,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;gBAEV,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAM3D;AAcD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,aAAa,CAAA;CACvB;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAC5C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EACvB,OAAO,EAAE,0BAA0B,EACnC,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,IAAI,CAAC,CAiCf"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export const defaultFetcher = (url, init) => fetch(url, { credentials: "include", ...init });
|
|
2
|
+
export class VoyantApiError extends Error {
|
|
3
|
+
status;
|
|
4
|
+
body;
|
|
5
|
+
constructor(message, status, body) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "VoyantApiError";
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.body = body;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function extractErrorMessage(status, statusText, body) {
|
|
13
|
+
if (typeof body === "object" && body !== null && "error" in body) {
|
|
14
|
+
const err = body.error;
|
|
15
|
+
if (typeof err === "string")
|
|
16
|
+
return err;
|
|
17
|
+
if (typeof err === "object" && err !== null && "message" in err) {
|
|
18
|
+
return String(err.message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return `Voyant API error: ${status} ${statusText}`;
|
|
22
|
+
}
|
|
23
|
+
export async function fetchWithValidation(path, schema, options, init) {
|
|
24
|
+
const url = joinUrl(options.baseUrl, path);
|
|
25
|
+
const headers = new Headers(init?.headers);
|
|
26
|
+
if (init?.body !== undefined && !headers.has("Content-Type")) {
|
|
27
|
+
headers.set("Content-Type", "application/json");
|
|
28
|
+
}
|
|
29
|
+
const response = await options.fetcher(url, { ...init, headers });
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
const body = await safeJson(response);
|
|
32
|
+
throw new VoyantApiError(extractErrorMessage(response.status, response.statusText, body), response.status, body);
|
|
33
|
+
}
|
|
34
|
+
if (response.status === 204) {
|
|
35
|
+
return schema.parse(undefined);
|
|
36
|
+
}
|
|
37
|
+
const body = await safeJson(response);
|
|
38
|
+
const parsed = schema.safeParse(body);
|
|
39
|
+
if (!parsed.success) {
|
|
40
|
+
throw new VoyantApiError(`Voyant API response failed validation: ${parsed.error.message}`, response.status, body);
|
|
41
|
+
}
|
|
42
|
+
return parsed.data;
|
|
43
|
+
}
|
|
44
|
+
async function safeJson(response) {
|
|
45
|
+
const text = await response.text();
|
|
46
|
+
if (!text)
|
|
47
|
+
return undefined;
|
|
48
|
+
try {
|
|
49
|
+
return JSON.parse(text);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return text;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function joinUrl(baseUrl, path) {
|
|
56
|
+
const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
57
|
+
const trimmedPath = path.startsWith("/") ? path : `/${path}`;
|
|
58
|
+
return `${trimmedBase}${trimmedPath}`;
|
|
59
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export declare const SELECT_TYPES: Set<string>;
|
|
2
|
+
export declare const QUESTION_TARGETS: readonly [{
|
|
3
|
+
readonly value: "booking";
|
|
4
|
+
readonly label: "Booking";
|
|
5
|
+
}, {
|
|
6
|
+
readonly value: "participant";
|
|
7
|
+
readonly label: "Participant";
|
|
8
|
+
}, {
|
|
9
|
+
readonly value: "lead_traveler";
|
|
10
|
+
readonly label: "Lead traveler";
|
|
11
|
+
}, {
|
|
12
|
+
readonly value: "booker";
|
|
13
|
+
readonly label: "Booker";
|
|
14
|
+
}, {
|
|
15
|
+
readonly value: "extra";
|
|
16
|
+
readonly label: "Extra";
|
|
17
|
+
}, {
|
|
18
|
+
readonly value: "service";
|
|
19
|
+
readonly label: "Service";
|
|
20
|
+
}];
|
|
21
|
+
export declare const QUESTION_FIELD_TYPES: readonly [{
|
|
22
|
+
readonly value: "text";
|
|
23
|
+
readonly label: "Text";
|
|
24
|
+
}, {
|
|
25
|
+
readonly value: "textarea";
|
|
26
|
+
readonly label: "Long text";
|
|
27
|
+
}, {
|
|
28
|
+
readonly value: "number";
|
|
29
|
+
readonly label: "Number";
|
|
30
|
+
}, {
|
|
31
|
+
readonly value: "email";
|
|
32
|
+
readonly label: "Email";
|
|
33
|
+
}, {
|
|
34
|
+
readonly value: "phone";
|
|
35
|
+
readonly label: "Phone";
|
|
36
|
+
}, {
|
|
37
|
+
readonly value: "date";
|
|
38
|
+
readonly label: "Date";
|
|
39
|
+
}, {
|
|
40
|
+
readonly value: "datetime";
|
|
41
|
+
readonly label: "Date & time";
|
|
42
|
+
}, {
|
|
43
|
+
readonly value: "boolean";
|
|
44
|
+
readonly label: "Yes / no";
|
|
45
|
+
}, {
|
|
46
|
+
readonly value: "single_select";
|
|
47
|
+
readonly label: "Single select";
|
|
48
|
+
}, {
|
|
49
|
+
readonly value: "multi_select";
|
|
50
|
+
readonly label: "Multi select";
|
|
51
|
+
}, {
|
|
52
|
+
readonly value: "file";
|
|
53
|
+
readonly label: "File upload";
|
|
54
|
+
}, {
|
|
55
|
+
readonly value: "country";
|
|
56
|
+
readonly label: "Country";
|
|
57
|
+
}, {
|
|
58
|
+
readonly value: "other";
|
|
59
|
+
readonly label: "Other";
|
|
60
|
+
}];
|
|
61
|
+
export declare const CONTACT_FIELDS: readonly [{
|
|
62
|
+
readonly value: "first_name";
|
|
63
|
+
readonly label: "First name";
|
|
64
|
+
}, {
|
|
65
|
+
readonly value: "last_name";
|
|
66
|
+
readonly label: "Last name";
|
|
67
|
+
}, {
|
|
68
|
+
readonly value: "email";
|
|
69
|
+
readonly label: "Email";
|
|
70
|
+
}, {
|
|
71
|
+
readonly value: "phone";
|
|
72
|
+
readonly label: "Phone";
|
|
73
|
+
}, {
|
|
74
|
+
readonly value: "date_of_birth";
|
|
75
|
+
readonly label: "Date of birth";
|
|
76
|
+
}, {
|
|
77
|
+
readonly value: "nationality";
|
|
78
|
+
readonly label: "Nationality";
|
|
79
|
+
}, {
|
|
80
|
+
readonly value: "passport_number";
|
|
81
|
+
readonly label: "Passport number";
|
|
82
|
+
}, {
|
|
83
|
+
readonly value: "passport_expiry";
|
|
84
|
+
readonly label: "Passport expiry";
|
|
85
|
+
}, {
|
|
86
|
+
readonly value: "dietary_requirements";
|
|
87
|
+
readonly label: "Dietary requirements";
|
|
88
|
+
}, {
|
|
89
|
+
readonly value: "accessibility_needs";
|
|
90
|
+
readonly label: "Accessibility needs";
|
|
91
|
+
}, {
|
|
92
|
+
readonly value: "special_requests";
|
|
93
|
+
readonly label: "Special requests";
|
|
94
|
+
}, {
|
|
95
|
+
readonly value: "address";
|
|
96
|
+
readonly label: "Address";
|
|
97
|
+
}, {
|
|
98
|
+
readonly value: "other";
|
|
99
|
+
readonly label: "Other";
|
|
100
|
+
}];
|
|
101
|
+
export declare const CONTACT_SCOPES: readonly [{
|
|
102
|
+
readonly value: "booking";
|
|
103
|
+
readonly label: "Booking";
|
|
104
|
+
}, {
|
|
105
|
+
readonly value: "lead_traveler";
|
|
106
|
+
readonly label: "Lead traveler";
|
|
107
|
+
}, {
|
|
108
|
+
readonly value: "participant";
|
|
109
|
+
readonly label: "Participant";
|
|
110
|
+
}, {
|
|
111
|
+
readonly value: "booker";
|
|
112
|
+
readonly label: "Booker";
|
|
113
|
+
}];
|
|
114
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,aAA6C,CAAA;AAEtE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;EAOnB,CAAA;AAEV,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcvB,CAAA;AAEV,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcjB,CAAA;AAEV,eAAO,MAAM,cAAc;;;;;;;;;;;;EAKjB,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const SELECT_TYPES = new Set(["single_select", "multi_select"]);
|
|
2
|
+
export const QUESTION_TARGETS = [
|
|
3
|
+
{ value: "booking", label: "Booking" },
|
|
4
|
+
{ value: "participant", label: "Participant" },
|
|
5
|
+
{ value: "lead_traveler", label: "Lead traveler" },
|
|
6
|
+
{ value: "booker", label: "Booker" },
|
|
7
|
+
{ value: "extra", label: "Extra" },
|
|
8
|
+
{ value: "service", label: "Service" },
|
|
9
|
+
];
|
|
10
|
+
export const QUESTION_FIELD_TYPES = [
|
|
11
|
+
{ value: "text", label: "Text" },
|
|
12
|
+
{ value: "textarea", label: "Long text" },
|
|
13
|
+
{ value: "number", label: "Number" },
|
|
14
|
+
{ value: "email", label: "Email" },
|
|
15
|
+
{ value: "phone", label: "Phone" },
|
|
16
|
+
{ value: "date", label: "Date" },
|
|
17
|
+
{ value: "datetime", label: "Date & time" },
|
|
18
|
+
{ value: "boolean", label: "Yes / no" },
|
|
19
|
+
{ value: "single_select", label: "Single select" },
|
|
20
|
+
{ value: "multi_select", label: "Multi select" },
|
|
21
|
+
{ value: "file", label: "File upload" },
|
|
22
|
+
{ value: "country", label: "Country" },
|
|
23
|
+
{ value: "other", label: "Other" },
|
|
24
|
+
];
|
|
25
|
+
export const CONTACT_FIELDS = [
|
|
26
|
+
{ value: "first_name", label: "First name" },
|
|
27
|
+
{ value: "last_name", label: "Last name" },
|
|
28
|
+
{ value: "email", label: "Email" },
|
|
29
|
+
{ value: "phone", label: "Phone" },
|
|
30
|
+
{ value: "date_of_birth", label: "Date of birth" },
|
|
31
|
+
{ value: "nationality", label: "Nationality" },
|
|
32
|
+
{ value: "passport_number", label: "Passport number" },
|
|
33
|
+
{ value: "passport_expiry", label: "Passport expiry" },
|
|
34
|
+
{ value: "dietary_requirements", label: "Dietary requirements" },
|
|
35
|
+
{ value: "accessibility_needs", label: "Accessibility needs" },
|
|
36
|
+
{ value: "special_requests", label: "Special requests" },
|
|
37
|
+
{ value: "address", label: "Address" },
|
|
38
|
+
{ value: "other", label: "Other" },
|
|
39
|
+
];
|
|
40
|
+
export const CONTACT_SCOPES = [
|
|
41
|
+
{ value: "booking", label: "Booking" },
|
|
42
|
+
{ value: "lead_traveler", label: "Lead traveler" },
|
|
43
|
+
{ value: "participant", label: "Participant" },
|
|
44
|
+
{ value: "booker", label: "Booker" },
|
|
45
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAEA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,mBAAmB,CAAA;AACjC,cAAc,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BookingQuestionsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseBookingQuestionsOptions extends BookingQuestionsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useBookingQuestions(options?: UseBookingQuestionsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
productId: string;
|
|
9
|
+
code: string | null;
|
|
10
|
+
label: string;
|
|
11
|
+
description: string | null;
|
|
12
|
+
target: "booking" | "participant" | "lead_traveler" | "booker" | "extra" | "service";
|
|
13
|
+
fieldType: "number" | "boolean" | "single_select" | "multi_select" | "text" | "textarea" | "email" | "phone" | "date" | "datetime" | "file" | "country" | "other";
|
|
14
|
+
placeholder: string | null;
|
|
15
|
+
helpText: string | null;
|
|
16
|
+
isRequired: boolean;
|
|
17
|
+
active: boolean;
|
|
18
|
+
sortOrder: number;
|
|
19
|
+
}[];
|
|
20
|
+
total: number;
|
|
21
|
+
limit: number;
|
|
22
|
+
offset: number;
|
|
23
|
+
}, Error>;
|
|
24
|
+
//# sourceMappingURL=use-booking-questions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-booking-questions.d.ts","sourceRoot":"","sources":["../../src/hooks/use-booking-questions.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;;;;;;;;;;;;;;;;;;UAI3E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantBookingRequirementsContext } from "../provider.js";
|
|
4
|
+
import { getBookingQuestionsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useBookingQuestions(options = {}) {
|
|
6
|
+
const client = useVoyantBookingRequirementsContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({ ...getBookingQuestionsQueryOptions(client, options), enabled });
|
|
9
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ContactRequirementsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseContactRequirementsOptions extends ContactRequirementsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useContactRequirements(options?: UseContactRequirementsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
productId: string;
|
|
9
|
+
optionId: string | null;
|
|
10
|
+
fieldKey: "email" | "phone" | "other" | "first_name" | "last_name" | "date_of_birth" | "nationality" | "passport_number" | "passport_expiry" | "dietary_requirements" | "accessibility_needs" | "special_requests" | "address";
|
|
11
|
+
scope: "booking" | "participant" | "lead_traveler" | "booker";
|
|
12
|
+
isRequired: boolean;
|
|
13
|
+
perParticipant: boolean;
|
|
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-contact-requirements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-contact-requirements.d.ts","sourceRoot":"","sources":["../../src/hooks/use-contact-requirements.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAA;AAGtE,MAAM,WAAW,6BAA8B,SAAQ,8BAA8B;IACnF,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,6BAAkC;;;;;;;;;;;;;;;;UAIjF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantBookingRequirementsContext } from "../provider.js";
|
|
4
|
+
import { getContactRequirementsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useContactRequirements(options = {}) {
|
|
6
|
+
const client = useVoyantBookingRequirementsContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({ ...getContactRequirementsQueryOptions(client, options), enabled });
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ProductsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseProductsOptions extends ProductsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useProducts(options?: UseProductsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
code: string | null;
|
|
10
|
+
status: string;
|
|
11
|
+
}[];
|
|
12
|
+
total: number;
|
|
13
|
+
limit: number;
|
|
14
|
+
offset: number;
|
|
15
|
+
}, Error>;
|
|
16
|
+
//# sourceMappingURL=use-products.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-products.d.ts","sourceRoot":"","sources":["../../src/hooks/use-products.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAG3D,MAAM,WAAW,kBAAmB,SAAQ,mBAAmB;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB;;;;;;;;;;UAI3D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantBookingRequirementsContext } from "../provider.js";
|
|
4
|
+
import { getProductsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useProducts(options = {}) {
|
|
6
|
+
const client = useVoyantBookingRequirementsContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({ ...getProductsQueryOptions(client, options), enabled });
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BookingQuestionOptionsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseQuestionOptionsOptions extends BookingQuestionOptionsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useQuestionOptions(options?: UseQuestionOptionsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
productBookingQuestionId: string;
|
|
9
|
+
value: string;
|
|
10
|
+
label: string;
|
|
11
|
+
sortOrder: number;
|
|
12
|
+
isDefault: boolean;
|
|
13
|
+
active: boolean;
|
|
14
|
+
}[];
|
|
15
|
+
total: number;
|
|
16
|
+
limit: number;
|
|
17
|
+
offset: number;
|
|
18
|
+
}, Error>;
|
|
19
|
+
//# sourceMappingURL=use-question-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-question-options.d.ts","sourceRoot":"","sources":["../../src/hooks/use-question-options.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAA;AAGzE,MAAM,WAAW,yBAA0B,SAAQ,iCAAiC;IAClF,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B;;;;;;;;;;;;;UAIzE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantBookingRequirementsContext } from "../provider.js";
|
|
4
|
+
import { getQuestionOptionsQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useQuestionOptions(options = {}) {
|
|
6
|
+
const client = useVoyantBookingRequirementsContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({ ...getQuestionOptionsQueryOptions(client, options), enabled });
|
|
9
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { defaultFetcher, fetchWithValidation, VoyantApiError, type VoyantFetcher, } from "./client.js";
|
|
2
|
+
export * from "./constants.js";
|
|
3
|
+
export * from "./hooks/index.js";
|
|
4
|
+
export { useVoyantBookingRequirementsContext, type VoyantBookingRequirementsContextValue, VoyantBookingRequirementsProvider, type VoyantBookingRequirementsProviderProps, } from "./provider.js";
|
|
5
|
+
export { bookingRequirementsQueryKeys } from "./query-keys.js";
|
|
6
|
+
export { getBookingQuestionsQueryOptions, getContactRequirementsQueryOptions, getProductsQueryOptions, getQuestionOptionsQueryOptions, } from "./query-options.js";
|
|
7
|
+
export * from "./schemas.js";
|
|
8
|
+
export * from "./utils.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA;AACpB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,mCAAmC,EACnC,KAAK,qCAAqC,EAC1C,iCAAiC,EACjC,KAAK,sCAAsC,GAC5C,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,EACL,+BAA+B,EAC/B,kCAAkC,EAClC,uBAAuB,EACvB,8BAA8B,GAC/B,MAAM,oBAAoB,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { defaultFetcher, fetchWithValidation, VoyantApiError, } from "./client.js";
|
|
2
|
+
export * from "./constants.js";
|
|
3
|
+
export * from "./hooks/index.js";
|
|
4
|
+
export { useVoyantBookingRequirementsContext, VoyantBookingRequirementsProvider, } from "./provider.js";
|
|
5
|
+
export { bookingRequirementsQueryKeys } from "./query-keys.js";
|
|
6
|
+
export { getBookingQuestionsQueryOptions, getContactRequirementsQueryOptions, getProductsQueryOptions, getQuestionOptionsQueryOptions, } from "./query-options.js";
|
|
7
|
+
export * from "./schemas.js";
|
|
8
|
+
export * from "./utils.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { useVoyantReactContext as useVoyantBookingRequirementsContext, type VoyantReactContextValue as VoyantBookingRequirementsContextValue, VoyantReactProvider as VoyantBookingRequirementsProvider, type VoyantReactProviderProps as VoyantBookingRequirementsProviderProps, } from "@voyantjs/react";
|
|
2
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,mCAAmC,EAC5D,KAAK,uBAAuB,IAAI,qCAAqC,EACrE,mBAAmB,IAAI,iCAAiC,EACxD,KAAK,wBAAwB,IAAI,sCAAsC,GACxE,MAAM,iBAAiB,CAAA"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useVoyantReactContext as useVoyantBookingRequirementsContext, VoyantReactProvider as VoyantBookingRequirementsProvider, } from "@voyantjs/react";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface PaginationFilters {
|
|
2
|
+
limit?: number | undefined;
|
|
3
|
+
offset?: number | undefined;
|
|
4
|
+
}
|
|
5
|
+
export interface ProductsListFilters extends PaginationFilters {
|
|
6
|
+
}
|
|
7
|
+
export interface ContactRequirementsListFilters extends PaginationFilters {
|
|
8
|
+
productId?: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface BookingQuestionsListFilters extends PaginationFilters {
|
|
11
|
+
productId?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface BookingQuestionOptionsListFilters extends PaginationFilters {
|
|
14
|
+
productBookingQuestionId?: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare const bookingRequirementsQueryKeys: {
|
|
17
|
+
readonly all: readonly ["voyant", "booking-requirements"];
|
|
18
|
+
readonly products: () => readonly ["voyant", "booking-requirements", "products"];
|
|
19
|
+
readonly productsList: (filters: ProductsListFilters) => readonly ["voyant", "booking-requirements", "products", "list", ProductsListFilters];
|
|
20
|
+
readonly contactRequirements: () => readonly ["voyant", "booking-requirements", "contact-requirements"];
|
|
21
|
+
readonly contactRequirementsList: (filters: ContactRequirementsListFilters) => readonly ["voyant", "booking-requirements", "contact-requirements", "list", ContactRequirementsListFilters];
|
|
22
|
+
readonly questions: () => readonly ["voyant", "booking-requirements", "questions"];
|
|
23
|
+
readonly questionsList: (filters: BookingQuestionsListFilters) => readonly ["voyant", "booking-requirements", "questions", "list", BookingQuestionsListFilters];
|
|
24
|
+
readonly questionOptions: () => readonly ["voyant", "booking-requirements", "question-options"];
|
|
25
|
+
readonly questionOptionsList: (filters: BookingQuestionOptionsListFilters) => readonly ["voyant", "booking-requirements", "question-options", "list", BookingQuestionOptionsListFilters];
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=query-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-keys.d.ts","sourceRoot":"","sources":["../src/query-keys.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;CAAG;AAEjE,MAAM,WAAW,8BAA+B,SAAQ,iBAAiB;IACvE,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B;AAED,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB;IACpE,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B;AAED,MAAM,WAAW,iCAAkC,SAAQ,iBAAiB;IAC1E,wBAAwB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9C;AAED,eAAO,MAAM,4BAA4B;;;qCAIf,mBAAmB;;gDAIR,8BAA8B;;sCAIxC,2BAA2B;;4CAIrB,iCAAiC;CAExD,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const bookingRequirementsQueryKeys = {
|
|
2
|
+
all: ["voyant", "booking-requirements"],
|
|
3
|
+
products: () => [...bookingRequirementsQueryKeys.all, "products"],
|
|
4
|
+
productsList: (filters) => [...bookingRequirementsQueryKeys.products(), "list", filters],
|
|
5
|
+
contactRequirements: () => [...bookingRequirementsQueryKeys.all, "contact-requirements"],
|
|
6
|
+
contactRequirementsList: (filters) => [...bookingRequirementsQueryKeys.contactRequirements(), "list", filters],
|
|
7
|
+
questions: () => [...bookingRequirementsQueryKeys.all, "questions"],
|
|
8
|
+
questionsList: (filters) => [...bookingRequirementsQueryKeys.questions(), "list", filters],
|
|
9
|
+
questionOptions: () => [...bookingRequirementsQueryKeys.all, "question-options"],
|
|
10
|
+
questionOptionsList: (filters) => [...bookingRequirementsQueryKeys.questionOptions(), "list", filters],
|
|
11
|
+
};
|