@voyant-travel/charters-react 0.117.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.
- package/LICENSE +201 -0
- package/README.md +40 -0
- package/dist/client.d.ts +14 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +59 -0
- package/dist/components/apa-tracker.d.ts +18 -0
- package/dist/components/apa-tracker.d.ts.map +1 -0
- package/dist/components/apa-tracker.js +69 -0
- package/dist/components/charter-catalog-card.d.ts +13 -0
- package/dist/components/charter-catalog-card.d.ts.map +1 -0
- package/dist/components/charter-catalog-card.js +58 -0
- package/dist/components/external-badge.d.ts +13 -0
- package/dist/components/external-badge.d.ts.map +1 -0
- package/dist/components/external-badge.js +16 -0
- package/dist/components/voyage-suite-grid.d.ts +26 -0
- package/dist/components/voyage-suite-grid.d.ts.map +1 -0
- package/dist/components/voyage-suite-grid.js +77 -0
- package/dist/components/whole-yacht-quote-card.d.ts +21 -0
- package/dist/components/whole-yacht-quote-card.d.ts.map +1 -0
- package/dist/components/whole-yacht-quote-card.js +46 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/use-apa.d.ts +130 -0
- package/dist/hooks/use-apa.d.ts.map +1 -0
- package/dist/hooks/use-apa.js +60 -0
- package/dist/hooks/use-charter-booking.d.ts +175 -0
- package/dist/hooks/use-charter-booking.d.ts.map +1 -0
- package/dist/hooks/use-charter-booking.js +39 -0
- package/dist/hooks/use-charter-product-mutation.d.ts +124 -0
- package/dist/hooks/use-charter-product-mutation.d.ts.map +1 -0
- package/dist/hooks/use-charter-product-mutation.js +55 -0
- package/dist/hooks/use-charter-products.d.ts +150 -0
- package/dist/hooks/use-charter-products.d.ts.map +1 -0
- package/dist/hooks/use-charter-products.js +29 -0
- package/dist/hooks/use-charter-public.d.ts +232 -0
- package/dist/hooks/use-charter-public.d.ts.map +1 -0
- package/dist/hooks/use-charter-public.js +41 -0
- package/dist/hooks/use-charter-quote.d.ts +42 -0
- package/dist/hooks/use-charter-quote.d.ts.map +1 -0
- package/dist/hooks/use-charter-quote.js +30 -0
- package/dist/hooks/use-charter-voyages.d.ts +111 -0
- package/dist/hooks/use-charter-voyages.d.ts.map +1 -0
- package/dist/hooks/use-charter-voyages.js +19 -0
- package/dist/hooks/use-charter-yachts.d.ts +72 -0
- package/dist/hooks/use-charter-yachts.d.ts.map +1 -0
- package/dist/hooks/use-charter-yachts.js +19 -0
- package/dist/hooks/use-myba-contract.d.ts +28 -0
- package/dist/hooks/use-myba-contract.d.ts.map +1 -0
- package/dist/hooks/use-myba-contract.js +31 -0
- package/dist/i18n/en.d.ts +3 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +78 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/messages.d.ts +70 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/i18n/messages.js +1 -0
- package/dist/i18n/provider.d.ts +26 -0
- package/dist/i18n/provider.d.ts.map +1 -0
- package/dist/i18n/provider.js +44 -0
- package/dist/i18n/ro.d.ts +3 -0
- package/dist/i18n/ro.d.ts.map +1 -0
- package/dist/i18n/ro.js +78 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -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 +61 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +31 -0
- package/dist/query-options.d.ts +2108 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +110 -0
- package/dist/schemas.d.ts +1066 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +323 -0
- package/dist/ui.d.ts +6 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +5 -0
- package/package.json +121 -0
- package/src/styles.css +11 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
2
|
+
import { fetchWithValidation } from "../client.js";
|
|
3
|
+
import { useVoyantChartersContext } from "../provider.js";
|
|
4
|
+
import { chartersQueryKeys } from "../query-keys.js";
|
|
5
|
+
import { productSingleResponse } from "../schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Mutation set for self-managed charter products: create / update / archive /
|
|
8
|
+
* recompute aggregates. Writes against external products return 409 from
|
|
9
|
+
* the server; this hook surfaces those as VoyantApiError.
|
|
10
|
+
*/
|
|
11
|
+
export function useCharterProductMutation() {
|
|
12
|
+
const { baseUrl, fetcher } = useVoyantChartersContext();
|
|
13
|
+
const client = { baseUrl, fetcher };
|
|
14
|
+
const queryClient = useQueryClient();
|
|
15
|
+
const create = useMutation({
|
|
16
|
+
mutationFn: async (input) => {
|
|
17
|
+
const result = await fetchWithValidation("/v1/admin/charters/products", productSingleResponse, client, { method: "POST", body: JSON.stringify(input) });
|
|
18
|
+
return result.data;
|
|
19
|
+
},
|
|
20
|
+
onSuccess: () => {
|
|
21
|
+
void queryClient.invalidateQueries({ queryKey: chartersQueryKeys.products() });
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const update = useMutation({
|
|
25
|
+
mutationFn: async ({ key, input, }) => {
|
|
26
|
+
const result = await fetchWithValidation(`/v1/admin/charters/products/${encodeURIComponent(key)}`, productSingleResponse, client, { method: "PUT", body: JSON.stringify(input) });
|
|
27
|
+
return result.data;
|
|
28
|
+
},
|
|
29
|
+
onSuccess: (data) => {
|
|
30
|
+
void queryClient.invalidateQueries({ queryKey: chartersQueryKeys.products() });
|
|
31
|
+
queryClient.setQueryData(chartersQueryKeys.product(data.id), data);
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const archive = useMutation({
|
|
35
|
+
mutationFn: async (key) => {
|
|
36
|
+
const result = await fetchWithValidation(`/v1/admin/charters/products/${encodeURIComponent(key)}`, productSingleResponse, client, { method: "DELETE" });
|
|
37
|
+
return result.data;
|
|
38
|
+
},
|
|
39
|
+
onSuccess: (data) => {
|
|
40
|
+
void queryClient.invalidateQueries({ queryKey: chartersQueryKeys.products() });
|
|
41
|
+
queryClient.setQueryData(chartersQueryKeys.product(data.id), data);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
const recomputeAggregates = useMutation({
|
|
45
|
+
mutationFn: async (key) => {
|
|
46
|
+
const result = await fetchWithValidation(`/v1/admin/charters/products/${encodeURIComponent(key)}/aggregates/recompute`, productSingleResponse, client, { method: "POST" });
|
|
47
|
+
return result.data;
|
|
48
|
+
},
|
|
49
|
+
onSuccess: (data) => {
|
|
50
|
+
void queryClient.invalidateQueries({ queryKey: chartersQueryKeys.products() });
|
|
51
|
+
queryClient.setQueryData(chartersQueryKeys.product(data.id), data);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
return { create, update, archive, recomputeAggregates };
|
|
55
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { ProductsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseCharterProductsOptions extends ProductsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Admin product list — fans out to local DB + every registered charter
|
|
7
|
+
* adapter. Items are tagged with `source: 'local' | 'external'` for the
|
|
8
|
+
* UI to render an external badge.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useCharterProducts(options?: UseCharterProductsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
11
|
+
data: ({
|
|
12
|
+
source: "local";
|
|
13
|
+
sourceProvider: null;
|
|
14
|
+
sourceRef: null;
|
|
15
|
+
key: string;
|
|
16
|
+
product: {
|
|
17
|
+
id: string;
|
|
18
|
+
slug: string;
|
|
19
|
+
name: string;
|
|
20
|
+
lineSupplierId: string | null;
|
|
21
|
+
defaultYachtId: string | null;
|
|
22
|
+
description: string | null;
|
|
23
|
+
shortDescription: string | null;
|
|
24
|
+
heroImageUrl: string | null;
|
|
25
|
+
mapImageUrl: string | null;
|
|
26
|
+
regions: string[] | null;
|
|
27
|
+
themes: string[] | null;
|
|
28
|
+
status: "draft" | "awaiting_review" | "live" | "archived";
|
|
29
|
+
defaultBookingModes: ("per_suite" | "whole_yacht")[] | null;
|
|
30
|
+
defaultMybaTemplateId: string | null;
|
|
31
|
+
defaultApaPercent: string | null;
|
|
32
|
+
lowestPriceCachedAmount: string | null;
|
|
33
|
+
lowestPriceCachedCurrency: string | null;
|
|
34
|
+
earliestVoyageCached: string | null;
|
|
35
|
+
latestVoyageCached: string | null;
|
|
36
|
+
externalRefs: Record<string, string> | null;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
updatedAt: string;
|
|
39
|
+
};
|
|
40
|
+
} | {
|
|
41
|
+
source: "external";
|
|
42
|
+
sourceProvider: string;
|
|
43
|
+
sourceRef: Record<string, unknown>;
|
|
44
|
+
key: string;
|
|
45
|
+
product: unknown;
|
|
46
|
+
})[];
|
|
47
|
+
total: number;
|
|
48
|
+
localTotal: number;
|
|
49
|
+
adapterCount: number;
|
|
50
|
+
limit: number;
|
|
51
|
+
offset: number;
|
|
52
|
+
adapterErrors?: {
|
|
53
|
+
adapter: string;
|
|
54
|
+
error: string;
|
|
55
|
+
}[] | undefined;
|
|
56
|
+
}, Error>;
|
|
57
|
+
export interface UseCharterProductOptions {
|
|
58
|
+
enabled?: boolean;
|
|
59
|
+
include?: ReadonlyArray<"voyages" | "yacht">;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Admin product detail. Accepts both local TypeIDs (`chrt_*`) and
|
|
63
|
+
* external `<provider>:<ref>` keys; the server dispatches to the local
|
|
64
|
+
* DB or the registered adapter accordingly.
|
|
65
|
+
*/
|
|
66
|
+
export declare function useCharterProduct(key: string | null | undefined, options?: UseCharterProductOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
67
|
+
id: string;
|
|
68
|
+
slug: string;
|
|
69
|
+
name: string;
|
|
70
|
+
lineSupplierId: string | null;
|
|
71
|
+
defaultYachtId: string | null;
|
|
72
|
+
description: string | null;
|
|
73
|
+
shortDescription: string | null;
|
|
74
|
+
heroImageUrl: string | null;
|
|
75
|
+
mapImageUrl: string | null;
|
|
76
|
+
regions: string[] | null;
|
|
77
|
+
themes: string[] | null;
|
|
78
|
+
status: "draft" | "awaiting_review" | "live" | "archived";
|
|
79
|
+
defaultBookingModes: ("per_suite" | "whole_yacht")[] | null;
|
|
80
|
+
defaultMybaTemplateId: string | null;
|
|
81
|
+
defaultApaPercent: string | null;
|
|
82
|
+
lowestPriceCachedAmount: string | null;
|
|
83
|
+
lowestPriceCachedCurrency: string | null;
|
|
84
|
+
earliestVoyageCached: string | null;
|
|
85
|
+
latestVoyageCached: string | null;
|
|
86
|
+
externalRefs: Record<string, string> | null;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
updatedAt: string;
|
|
89
|
+
voyages?: {
|
|
90
|
+
id: string;
|
|
91
|
+
productId: string;
|
|
92
|
+
yachtId: string;
|
|
93
|
+
voyageCode: string;
|
|
94
|
+
name: string | null;
|
|
95
|
+
embarkPortFacilityId: string | null;
|
|
96
|
+
embarkPortName: string | null;
|
|
97
|
+
disembarkPortFacilityId: string | null;
|
|
98
|
+
disembarkPortName: string | null;
|
|
99
|
+
departureDate: string;
|
|
100
|
+
returnDate: string;
|
|
101
|
+
nights: number;
|
|
102
|
+
bookingModes: ("per_suite" | "whole_yacht")[];
|
|
103
|
+
appointmentOnly: boolean;
|
|
104
|
+
wholeYachtPricesByCurrency: Record<string, string>;
|
|
105
|
+
apaPercentOverride: string | null;
|
|
106
|
+
mybaTemplateIdOverride: string | null;
|
|
107
|
+
charterAreaOverride: string | null;
|
|
108
|
+
salesStatus: "open" | "on_request" | "wait_list" | "sold_out" | "closed";
|
|
109
|
+
availabilityNote: string | null;
|
|
110
|
+
externalRefs: Record<string, string> | null;
|
|
111
|
+
lastSyncedAt: string | null;
|
|
112
|
+
createdAt: string;
|
|
113
|
+
updatedAt: string;
|
|
114
|
+
}[] | undefined;
|
|
115
|
+
yacht?: {
|
|
116
|
+
id: string;
|
|
117
|
+
lineSupplierId: string | null;
|
|
118
|
+
name: string;
|
|
119
|
+
slug: string;
|
|
120
|
+
yachtClass: "luxury_motor" | "luxury_sailing" | "expedition" | "small_cruise";
|
|
121
|
+
capacityGuests: number | null;
|
|
122
|
+
capacityCrew: number | null;
|
|
123
|
+
lengthMeters: string | null;
|
|
124
|
+
yearBuilt: number | null;
|
|
125
|
+
yearRefurbished: number | null;
|
|
126
|
+
imo: string | null;
|
|
127
|
+
description: string | null;
|
|
128
|
+
gallery: string[] | null;
|
|
129
|
+
amenities: Record<string, unknown> | null;
|
|
130
|
+
crewBios: {
|
|
131
|
+
role: string;
|
|
132
|
+
name: string;
|
|
133
|
+
bio?: string | undefined;
|
|
134
|
+
photoUrl?: string | undefined;
|
|
135
|
+
}[] | null;
|
|
136
|
+
defaultCharterAreas: string[] | null;
|
|
137
|
+
externalRefs: Record<string, string> | null;
|
|
138
|
+
isActive: boolean;
|
|
139
|
+
createdAt: string;
|
|
140
|
+
updatedAt: string;
|
|
141
|
+
} | null | undefined;
|
|
142
|
+
} | {
|
|
143
|
+
source: "external";
|
|
144
|
+
sourceProvider: string;
|
|
145
|
+
sourceRef: Record<string, unknown>;
|
|
146
|
+
product: Record<string, unknown>;
|
|
147
|
+
voyages?: unknown[] | undefined;
|
|
148
|
+
yacht?: unknown;
|
|
149
|
+
}, Error>;
|
|
150
|
+
//# sourceMappingURL=use-charter-products.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-charter-products.d.ts","sourceRoot":"","sources":["../../src/hooks/use-charter-products.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAG3D,MAAM,WAAW,yBAA0B,SAAQ,mBAAmB;IACpE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAOzE;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,aAAa,CAAC,SAAS,GAAG,OAAO,CAAC,CAAA;CAC7C;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,OAAO,GAAE,wBAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAQvC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { useVoyantChartersContext } from "../provider.js";
|
|
3
|
+
import { getProductQueryOptions, getProductsQueryOptions } from "../query-options.js";
|
|
4
|
+
/**
|
|
5
|
+
* Admin product list — fans out to local DB + every registered charter
|
|
6
|
+
* adapter. Items are tagged with `source: 'local' | 'external'` for the
|
|
7
|
+
* UI to render an external badge.
|
|
8
|
+
*/
|
|
9
|
+
export function useCharterProducts(options = {}) {
|
|
10
|
+
const { baseUrl, fetcher } = useVoyantChartersContext();
|
|
11
|
+
const { enabled = true, ...filters } = options;
|
|
12
|
+
return useQuery({
|
|
13
|
+
...getProductsQueryOptions({ baseUrl, fetcher }, filters),
|
|
14
|
+
enabled,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Admin product detail. Accepts both local TypeIDs (`chrt_*`) and
|
|
19
|
+
* external `<provider>:<ref>` keys; the server dispatches to the local
|
|
20
|
+
* DB or the registered adapter accordingly.
|
|
21
|
+
*/
|
|
22
|
+
export function useCharterProduct(key, options = {}) {
|
|
23
|
+
const { baseUrl, fetcher } = useVoyantChartersContext();
|
|
24
|
+
const { enabled = true, include } = options;
|
|
25
|
+
return useQuery({
|
|
26
|
+
...getProductQueryOptions({ baseUrl, fetcher }, key ?? "", { include }),
|
|
27
|
+
enabled: enabled && !!key,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import type { PublicProductsListFilters } from "../query-keys.js";
|
|
2
|
+
/**
|
|
3
|
+
* Public charter products list (anonymous browse). Forces `status='live'`
|
|
4
|
+
* server-side regardless of any extra filters; fans out to local DB +
|
|
5
|
+
* registered adapters.
|
|
6
|
+
*/
|
|
7
|
+
export declare function usePublicCharterProducts(options?: PublicProductsListFilters & {
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
}): import("@tanstack/react-query").UseQueryResult<{
|
|
10
|
+
data: {
|
|
11
|
+
id: string;
|
|
12
|
+
slug: string;
|
|
13
|
+
name: string;
|
|
14
|
+
lineSupplierId: string | null;
|
|
15
|
+
defaultYachtId: string | null;
|
|
16
|
+
description: string | null;
|
|
17
|
+
shortDescription: string | null;
|
|
18
|
+
heroImageUrl: string | null;
|
|
19
|
+
mapImageUrl: string | null;
|
|
20
|
+
regions: string[] | null;
|
|
21
|
+
themes: string[] | null;
|
|
22
|
+
status: "draft" | "awaiting_review" | "live" | "archived";
|
|
23
|
+
defaultBookingModes: ("per_suite" | "whole_yacht")[] | null;
|
|
24
|
+
defaultMybaTemplateId: string | null;
|
|
25
|
+
defaultApaPercent: string | null;
|
|
26
|
+
lowestPriceCachedAmount: string | null;
|
|
27
|
+
lowestPriceCachedCurrency: string | null;
|
|
28
|
+
earliestVoyageCached: string | null;
|
|
29
|
+
latestVoyageCached: string | null;
|
|
30
|
+
externalRefs: Record<string, string> | null;
|
|
31
|
+
createdAt: string;
|
|
32
|
+
updatedAt: string;
|
|
33
|
+
}[];
|
|
34
|
+
total: number;
|
|
35
|
+
limit: number;
|
|
36
|
+
offset: number;
|
|
37
|
+
}, Error>;
|
|
38
|
+
/** Public product detail by slug or external `<provider>:<ref>` key. */
|
|
39
|
+
export declare function usePublicCharterProduct(key: string | null | undefined, options?: {
|
|
40
|
+
enabled?: boolean;
|
|
41
|
+
}): import("@tanstack/react-query").UseQueryResult<{
|
|
42
|
+
id: string;
|
|
43
|
+
slug: string;
|
|
44
|
+
name: string;
|
|
45
|
+
lineSupplierId: string | null;
|
|
46
|
+
defaultYachtId: string | null;
|
|
47
|
+
description: string | null;
|
|
48
|
+
shortDescription: string | null;
|
|
49
|
+
heroImageUrl: string | null;
|
|
50
|
+
mapImageUrl: string | null;
|
|
51
|
+
regions: string[] | null;
|
|
52
|
+
themes: string[] | null;
|
|
53
|
+
status: "draft" | "awaiting_review" | "live" | "archived";
|
|
54
|
+
defaultBookingModes: ("per_suite" | "whole_yacht")[] | null;
|
|
55
|
+
defaultMybaTemplateId: string | null;
|
|
56
|
+
defaultApaPercent: string | null;
|
|
57
|
+
lowestPriceCachedAmount: string | null;
|
|
58
|
+
lowestPriceCachedCurrency: string | null;
|
|
59
|
+
earliestVoyageCached: string | null;
|
|
60
|
+
latestVoyageCached: string | null;
|
|
61
|
+
externalRefs: Record<string, string> | null;
|
|
62
|
+
createdAt: string;
|
|
63
|
+
updatedAt: string;
|
|
64
|
+
voyages?: {
|
|
65
|
+
id: string;
|
|
66
|
+
productId: string;
|
|
67
|
+
yachtId: string;
|
|
68
|
+
voyageCode: string;
|
|
69
|
+
name: string | null;
|
|
70
|
+
embarkPortFacilityId: string | null;
|
|
71
|
+
embarkPortName: string | null;
|
|
72
|
+
disembarkPortFacilityId: string | null;
|
|
73
|
+
disembarkPortName: string | null;
|
|
74
|
+
departureDate: string;
|
|
75
|
+
returnDate: string;
|
|
76
|
+
nights: number;
|
|
77
|
+
bookingModes: ("per_suite" | "whole_yacht")[];
|
|
78
|
+
appointmentOnly: boolean;
|
|
79
|
+
wholeYachtPricesByCurrency: Record<string, string>;
|
|
80
|
+
apaPercentOverride: string | null;
|
|
81
|
+
mybaTemplateIdOverride: string | null;
|
|
82
|
+
charterAreaOverride: string | null;
|
|
83
|
+
salesStatus: "open" | "on_request" | "wait_list" | "sold_out" | "closed";
|
|
84
|
+
availabilityNote: string | null;
|
|
85
|
+
externalRefs: Record<string, string> | null;
|
|
86
|
+
lastSyncedAt: string | null;
|
|
87
|
+
createdAt: string;
|
|
88
|
+
updatedAt: string;
|
|
89
|
+
}[] | undefined;
|
|
90
|
+
yacht?: {
|
|
91
|
+
id: string;
|
|
92
|
+
lineSupplierId: string | null;
|
|
93
|
+
name: string;
|
|
94
|
+
slug: string;
|
|
95
|
+
yachtClass: "luxury_motor" | "luxury_sailing" | "expedition" | "small_cruise";
|
|
96
|
+
capacityGuests: number | null;
|
|
97
|
+
capacityCrew: number | null;
|
|
98
|
+
lengthMeters: string | null;
|
|
99
|
+
yearBuilt: number | null;
|
|
100
|
+
yearRefurbished: number | null;
|
|
101
|
+
imo: string | null;
|
|
102
|
+
description: string | null;
|
|
103
|
+
gallery: string[] | null;
|
|
104
|
+
amenities: Record<string, unknown> | null;
|
|
105
|
+
crewBios: {
|
|
106
|
+
role: string;
|
|
107
|
+
name: string;
|
|
108
|
+
bio?: string | undefined;
|
|
109
|
+
photoUrl?: string | undefined;
|
|
110
|
+
}[] | null;
|
|
111
|
+
defaultCharterAreas: string[] | null;
|
|
112
|
+
externalRefs: Record<string, string> | null;
|
|
113
|
+
isActive: boolean;
|
|
114
|
+
createdAt: string;
|
|
115
|
+
updatedAt: string;
|
|
116
|
+
} | null | undefined;
|
|
117
|
+
} | {
|
|
118
|
+
source: "external";
|
|
119
|
+
sourceProvider: string;
|
|
120
|
+
sourceRef: Record<string, unknown>;
|
|
121
|
+
product: Record<string, unknown>;
|
|
122
|
+
voyages?: unknown[] | undefined;
|
|
123
|
+
yacht?: unknown;
|
|
124
|
+
}, Error>;
|
|
125
|
+
export declare function usePublicCharterVoyage(key: string | null | undefined, options?: {
|
|
126
|
+
enabled?: boolean;
|
|
127
|
+
}): import("@tanstack/react-query").UseQueryResult<{
|
|
128
|
+
id: string;
|
|
129
|
+
productId: string;
|
|
130
|
+
yachtId: string;
|
|
131
|
+
voyageCode: string;
|
|
132
|
+
name: string | null;
|
|
133
|
+
embarkPortFacilityId: string | null;
|
|
134
|
+
embarkPortName: string | null;
|
|
135
|
+
disembarkPortFacilityId: string | null;
|
|
136
|
+
disembarkPortName: string | null;
|
|
137
|
+
departureDate: string;
|
|
138
|
+
returnDate: string;
|
|
139
|
+
nights: number;
|
|
140
|
+
bookingModes: ("per_suite" | "whole_yacht")[];
|
|
141
|
+
appointmentOnly: boolean;
|
|
142
|
+
wholeYachtPricesByCurrency: Record<string, string>;
|
|
143
|
+
apaPercentOverride: string | null;
|
|
144
|
+
mybaTemplateIdOverride: string | null;
|
|
145
|
+
charterAreaOverride: string | null;
|
|
146
|
+
salesStatus: "open" | "on_request" | "wait_list" | "sold_out" | "closed";
|
|
147
|
+
availabilityNote: string | null;
|
|
148
|
+
externalRefs: Record<string, string> | null;
|
|
149
|
+
lastSyncedAt: string | null;
|
|
150
|
+
createdAt: string;
|
|
151
|
+
updatedAt: string;
|
|
152
|
+
suites?: {
|
|
153
|
+
id: string;
|
|
154
|
+
voyageId: string;
|
|
155
|
+
suiteCode: string;
|
|
156
|
+
suiteName: string;
|
|
157
|
+
suiteCategory: "standard" | "deluxe" | "suite" | "penthouse" | "owners" | "signature" | null;
|
|
158
|
+
description: string | null;
|
|
159
|
+
squareFeet: string | null;
|
|
160
|
+
images: string[] | null;
|
|
161
|
+
floorplanImages: string[] | null;
|
|
162
|
+
maxGuests: number | null;
|
|
163
|
+
pricesByCurrency: Record<string, string>;
|
|
164
|
+
portFeesByCurrency: Record<string, string>;
|
|
165
|
+
availability: "on_request" | "wait_list" | "sold_out" | "available" | "limited";
|
|
166
|
+
unitsAvailable: number | null;
|
|
167
|
+
appointmentOnly: boolean;
|
|
168
|
+
notes: string | null;
|
|
169
|
+
extra: Record<string, unknown> | null;
|
|
170
|
+
externalRefs: Record<string, string> | null;
|
|
171
|
+
lastSyncedAt: string | null;
|
|
172
|
+
createdAt: string;
|
|
173
|
+
updatedAt: string;
|
|
174
|
+
}[] | undefined;
|
|
175
|
+
schedule?: {
|
|
176
|
+
id: string;
|
|
177
|
+
voyageId: string;
|
|
178
|
+
dayNumber: number;
|
|
179
|
+
portFacilityId: string | null;
|
|
180
|
+
portName: string | null;
|
|
181
|
+
scheduleDate: string | null;
|
|
182
|
+
arrivalTime: string | null;
|
|
183
|
+
departureTime: string | null;
|
|
184
|
+
isSeaDay: boolean;
|
|
185
|
+
description: string | null;
|
|
186
|
+
activities: string[] | null;
|
|
187
|
+
createdAt: string;
|
|
188
|
+
updatedAt: string;
|
|
189
|
+
}[] | undefined;
|
|
190
|
+
} | {
|
|
191
|
+
source: "external";
|
|
192
|
+
sourceProvider: string;
|
|
193
|
+
sourceRef: Record<string, unknown>;
|
|
194
|
+
voyage: Record<string, unknown>;
|
|
195
|
+
suites?: unknown[] | undefined;
|
|
196
|
+
schedule?: unknown[] | undefined;
|
|
197
|
+
}, Error>;
|
|
198
|
+
export declare function usePublicCharterYacht(key: string | null | undefined, options?: {
|
|
199
|
+
enabled?: boolean;
|
|
200
|
+
}): import("@tanstack/react-query").UseQueryResult<{
|
|
201
|
+
id: string;
|
|
202
|
+
lineSupplierId: string | null;
|
|
203
|
+
name: string;
|
|
204
|
+
slug: string;
|
|
205
|
+
yachtClass: "luxury_motor" | "luxury_sailing" | "expedition" | "small_cruise";
|
|
206
|
+
capacityGuests: number | null;
|
|
207
|
+
capacityCrew: number | null;
|
|
208
|
+
lengthMeters: string | null;
|
|
209
|
+
yearBuilt: number | null;
|
|
210
|
+
yearRefurbished: number | null;
|
|
211
|
+
imo: string | null;
|
|
212
|
+
description: string | null;
|
|
213
|
+
gallery: string[] | null;
|
|
214
|
+
amenities: Record<string, unknown> | null;
|
|
215
|
+
crewBios: {
|
|
216
|
+
role: string;
|
|
217
|
+
name: string;
|
|
218
|
+
bio?: string | undefined;
|
|
219
|
+
photoUrl?: string | undefined;
|
|
220
|
+
}[] | null;
|
|
221
|
+
defaultCharterAreas: string[] | null;
|
|
222
|
+
externalRefs: Record<string, string> | null;
|
|
223
|
+
isActive: boolean;
|
|
224
|
+
createdAt: string;
|
|
225
|
+
updatedAt: string;
|
|
226
|
+
} | {
|
|
227
|
+
source: "external";
|
|
228
|
+
sourceProvider: string;
|
|
229
|
+
sourceRef: Record<string, unknown>;
|
|
230
|
+
yacht: Record<string, unknown>;
|
|
231
|
+
}, Error>;
|
|
232
|
+
//# sourceMappingURL=use-charter-public.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-charter-public.d.ts","sourceRoot":"","sources":["../../src/hooks/use-charter-public.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAQjE;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,GAAE,yBAAyB,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAQhE;AAED,wEAAwE;AACxE,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAQpC;AAED,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAQpC;AAED,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAQpC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { useVoyantChartersContext } from "../provider.js";
|
|
3
|
+
import { getPublicProductQueryOptions, getPublicProductsQueryOptions, getPublicVoyageQueryOptions, getPublicYachtQueryOptions, } from "../query-options.js";
|
|
4
|
+
/**
|
|
5
|
+
* Public charter products list (anonymous browse). Forces `status='live'`
|
|
6
|
+
* server-side regardless of any extra filters; fans out to local DB +
|
|
7
|
+
* registered adapters.
|
|
8
|
+
*/
|
|
9
|
+
export function usePublicCharterProducts(options = {}) {
|
|
10
|
+
const { baseUrl, fetcher } = useVoyantChartersContext();
|
|
11
|
+
const { enabled = true, ...filters } = options;
|
|
12
|
+
return useQuery({
|
|
13
|
+
...getPublicProductsQueryOptions({ baseUrl, fetcher }, filters),
|
|
14
|
+
enabled,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/** Public product detail by slug or external `<provider>:<ref>` key. */
|
|
18
|
+
export function usePublicCharterProduct(key, options = {}) {
|
|
19
|
+
const { baseUrl, fetcher } = useVoyantChartersContext();
|
|
20
|
+
const { enabled = true } = options;
|
|
21
|
+
return useQuery({
|
|
22
|
+
...getPublicProductQueryOptions({ baseUrl, fetcher }, key ?? ""),
|
|
23
|
+
enabled: enabled && !!key,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export function usePublicCharterVoyage(key, options = {}) {
|
|
27
|
+
const { baseUrl, fetcher } = useVoyantChartersContext();
|
|
28
|
+
const { enabled = true } = options;
|
|
29
|
+
return useQuery({
|
|
30
|
+
...getPublicVoyageQueryOptions({ baseUrl, fetcher }, key ?? ""),
|
|
31
|
+
enabled: enabled && !!key,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export function usePublicCharterYacht(key, options = {}) {
|
|
35
|
+
const { baseUrl, fetcher } = useVoyantChartersContext();
|
|
36
|
+
const { enabled = true } = options;
|
|
37
|
+
return useQuery({
|
|
38
|
+
...getPublicYachtQueryOptions({ baseUrl, fetcher }, key ?? ""),
|
|
39
|
+
enabled: enabled && !!key,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface PerSuiteQuoteRequest {
|
|
2
|
+
/** For local voyages this is a `chst_*` TypeID; for external voyages it's the upstream suite externalId. */
|
|
3
|
+
suiteId: string;
|
|
4
|
+
/** ISO-4217 currency code. The server resolves it against the suite's `pricesByCurrency` map. */
|
|
5
|
+
currency: string;
|
|
6
|
+
}
|
|
7
|
+
export interface WholeYachtQuoteRequest {
|
|
8
|
+
/** ISO-4217 currency code. The server resolves it against the voyage's `wholeYachtPricesByCurrency` map. */
|
|
9
|
+
currency: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Compose a per-suite quote against a voyage. Mutation rather than query
|
|
13
|
+
* because the server validates inputs and runs the composePerSuiteQuote
|
|
14
|
+
* pipeline — caching is the caller's choice.
|
|
15
|
+
*/
|
|
16
|
+
export declare function usePerSuiteQuote(): import("@tanstack/react-query").UseMutationResult<{
|
|
17
|
+
mode: "per_suite";
|
|
18
|
+
voyageId: string;
|
|
19
|
+
suiteId: string;
|
|
20
|
+
suiteName: string;
|
|
21
|
+
currency: string;
|
|
22
|
+
suitePrice: string;
|
|
23
|
+
portFee: string | null;
|
|
24
|
+
total: string;
|
|
25
|
+
}, Error, {
|
|
26
|
+
voyageKey: string;
|
|
27
|
+
input: PerSuiteQuoteRequest;
|
|
28
|
+
}, unknown>;
|
|
29
|
+
/** Whole-yacht quote (charter fee + APA). Same mutation-shape as per-suite. */
|
|
30
|
+
export declare function useWholeYachtQuote(): import("@tanstack/react-query").UseMutationResult<{
|
|
31
|
+
mode: "whole_yacht";
|
|
32
|
+
voyageId: string;
|
|
33
|
+
currency: string;
|
|
34
|
+
charterFee: string;
|
|
35
|
+
apaPercent: string;
|
|
36
|
+
apaAmount: string;
|
|
37
|
+
total: string;
|
|
38
|
+
}, Error, {
|
|
39
|
+
voyageKey: string;
|
|
40
|
+
input: WholeYachtQuoteRequest;
|
|
41
|
+
}, unknown>;
|
|
42
|
+
//# sourceMappingURL=use-charter-quote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-charter-quote.d.ts","sourceRoot":"","sources":["../../src/hooks/use-charter-quote.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,oBAAoB;IACnC,4GAA4G;IAC5G,OAAO,EAAE,MAAM,CAAA;IACf,iGAAiG;IACjG,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,4GAA4G;IAC5G,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB;;;;;;;;;;eAQf,MAAM;WACV,oBAAoB;YAWhC;AAED,+EAA+E;AAC/E,wBAAgB,kBAAkB;;;;;;;;;eAQjB,MAAM;WACV,sBAAsB;YAWlC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useMutation } from "@tanstack/react-query";
|
|
2
|
+
import { fetchWithValidation } from "../client.js";
|
|
3
|
+
import { useVoyantChartersContext } from "../provider.js";
|
|
4
|
+
import { perSuiteQuoteResponse, wholeYachtQuoteResponse, } from "../schemas.js";
|
|
5
|
+
/**
|
|
6
|
+
* Compose a per-suite quote against a voyage. Mutation rather than query
|
|
7
|
+
* because the server validates inputs and runs the composePerSuiteQuote
|
|
8
|
+
* pipeline — caching is the caller's choice.
|
|
9
|
+
*/
|
|
10
|
+
export function usePerSuiteQuote() {
|
|
11
|
+
const { baseUrl, fetcher } = useVoyantChartersContext();
|
|
12
|
+
const client = { baseUrl, fetcher };
|
|
13
|
+
return useMutation({
|
|
14
|
+
mutationFn: async ({ voyageKey, input, }) => {
|
|
15
|
+
const result = await fetchWithValidation(`/v1/admin/charters/voyages/${encodeURIComponent(voyageKey)}/quote/per-suite`, perSuiteQuoteResponse, client, { method: "POST", body: JSON.stringify(input) });
|
|
16
|
+
return result.data;
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/** Whole-yacht quote (charter fee + APA). Same mutation-shape as per-suite. */
|
|
21
|
+
export function useWholeYachtQuote() {
|
|
22
|
+
const { baseUrl, fetcher } = useVoyantChartersContext();
|
|
23
|
+
const client = { baseUrl, fetcher };
|
|
24
|
+
return useMutation({
|
|
25
|
+
mutationFn: async ({ voyageKey, input, }) => {
|
|
26
|
+
const result = await fetchWithValidation(`/v1/admin/charters/voyages/${encodeURIComponent(voyageKey)}/quote/whole-yacht`, wholeYachtQuoteResponse, client, { method: "POST", body: JSON.stringify(input) });
|
|
27
|
+
return result.data;
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|