@voyantjs/hospitality-react 0.2.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/dist/client.d.ts +14 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +59 -0
- package/dist/hooks/index.d.ts +35 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +34 -0
- package/dist/hooks/use-housekeeping-task-mutation.d.ts +54 -0
- package/dist/hooks/use-housekeeping-task-mutation.d.ts.map +1 -0
- package/dist/hooks/use-housekeeping-task-mutation.js +38 -0
- package/dist/hooks/use-housekeeping-tasks.d.ts +30 -0
- package/dist/hooks/use-housekeeping-tasks.d.ts.map +1 -0
- package/dist/hooks/use-housekeeping-tasks.js +11 -0
- package/dist/hooks/use-maintenance-block-mutation.d.ts +47 -0
- package/dist/hooks/use-maintenance-block-mutation.d.ts.map +1 -0
- package/dist/hooks/use-maintenance-block-mutation.js +38 -0
- package/dist/hooks/use-maintenance-blocks.d.ts +24 -0
- package/dist/hooks/use-maintenance-blocks.d.ts.map +1 -0
- package/dist/hooks/use-maintenance-blocks.js +11 -0
- package/dist/hooks/use-meal-plan-mutation.d.ts +53 -0
- package/dist/hooks/use-meal-plan-mutation.d.ts.map +1 -0
- package/dist/hooks/use-meal-plan-mutation.js +38 -0
- package/dist/hooks/use-meal-plan.d.ts +18 -0
- package/dist/hooks/use-meal-plan.d.ts.map +1 -0
- package/dist/hooks/use-meal-plan.js +12 -0
- package/dist/hooks/use-meal-plans.d.ts +27 -0
- package/dist/hooks/use-meal-plans.d.ts.map +1 -0
- package/dist/hooks/use-meal-plans.js +11 -0
- package/dist/hooks/use-rate-plan-inventory-override-mutation.d.ts +47 -0
- package/dist/hooks/use-rate-plan-inventory-override-mutation.d.ts.map +1 -0
- package/dist/hooks/use-rate-plan-inventory-override-mutation.js +44 -0
- package/dist/hooks/use-rate-plan-inventory-overrides.d.ts +27 -0
- package/dist/hooks/use-rate-plan-inventory-overrides.d.ts.map +1 -0
- package/dist/hooks/use-rate-plan-inventory-overrides.js +11 -0
- package/dist/hooks/use-rate-plan-mutation.d.ts +68 -0
- package/dist/hooks/use-rate-plan-mutation.d.ts.map +1 -0
- package/dist/hooks/use-rate-plan-mutation.js +38 -0
- package/dist/hooks/use-rate-plan-room-type-mutation.d.ts +41 -0
- package/dist/hooks/use-rate-plan-room-type-mutation.d.ts.map +1 -0
- package/dist/hooks/use-rate-plan-room-type-mutation.js +38 -0
- package/dist/hooks/use-rate-plan-room-types.d.ts +25 -0
- package/dist/hooks/use-rate-plan-room-types.d.ts.map +1 -0
- package/dist/hooks/use-rate-plan-room-types.js +11 -0
- package/dist/hooks/use-rate-plan.d.ts +23 -0
- package/dist/hooks/use-rate-plan.d.ts.map +1 -0
- package/dist/hooks/use-rate-plan.js +12 -0
- package/dist/hooks/use-rate-plans.d.ts +32 -0
- package/dist/hooks/use-rate-plans.d.ts.map +1 -0
- package/dist/hooks/use-rate-plans.js +11 -0
- package/dist/hooks/use-room-block-mutation.d.ts +51 -0
- package/dist/hooks/use-room-block-mutation.d.ts.map +1 -0
- package/dist/hooks/use-room-block-mutation.js +38 -0
- package/dist/hooks/use-room-blocks.d.ts +25 -0
- package/dist/hooks/use-room-blocks.d.ts.map +1 -0
- package/dist/hooks/use-room-blocks.js +11 -0
- package/dist/hooks/use-room-inventory-mutation.d.ts +53 -0
- package/dist/hooks/use-room-inventory-mutation.d.ts.map +1 -0
- package/dist/hooks/use-room-inventory-mutation.js +38 -0
- package/dist/hooks/use-room-inventory.d.ts +29 -0
- package/dist/hooks/use-room-inventory.d.ts.map +1 -0
- package/dist/hooks/use-room-inventory.js +11 -0
- package/dist/hooks/use-room-type-mutation.d.ts +83 -0
- package/dist/hooks/use-room-type-mutation.d.ts.map +1 -0
- package/dist/hooks/use-room-type-mutation.js +38 -0
- package/dist/hooks/use-room-type-rate-mutation.d.ts +50 -0
- package/dist/hooks/use-room-type-rate-mutation.d.ts.map +1 -0
- package/dist/hooks/use-room-type-rate-mutation.js +38 -0
- package/dist/hooks/use-room-type-rates.d.ts +28 -0
- package/dist/hooks/use-room-type-rates.d.ts.map +1 -0
- package/dist/hooks/use-room-type-rates.js +11 -0
- package/dist/hooks/use-room-type.d.ts +28 -0
- package/dist/hooks/use-room-type.d.ts.map +1 -0
- package/dist/hooks/use-room-type.js +12 -0
- package/dist/hooks/use-room-types.d.ts +37 -0
- package/dist/hooks/use-room-types.d.ts.map +1 -0
- package/dist/hooks/use-room-types.js +11 -0
- package/dist/hooks/use-room-unit-mutation.d.ts +56 -0
- package/dist/hooks/use-room-unit-mutation.d.ts.map +1 -0
- package/dist/hooks/use-room-unit-mutation.js +38 -0
- package/dist/hooks/use-room-unit.d.ts +19 -0
- package/dist/hooks/use-room-unit.d.ts.map +1 -0
- package/dist/hooks/use-room-unit.js +12 -0
- package/dist/hooks/use-room-units.d.ts +28 -0
- package/dist/hooks/use-room-units.d.ts.map +1 -0
- package/dist/hooks/use-room-units.js +11 -0
- package/dist/hooks/use-stay-booking-item-mutation.d.ts +72 -0
- package/dist/hooks/use-stay-booking-item-mutation.d.ts.map +1 -0
- package/dist/hooks/use-stay-booking-item-mutation.js +38 -0
- package/dist/hooks/use-stay-booking-items.d.ts +39 -0
- package/dist/hooks/use-stay-booking-items.d.ts.map +1 -0
- package/dist/hooks/use-stay-booking-items.js +11 -0
- package/dist/hooks/use-stay-folio-mutation.d.ts +39 -0
- package/dist/hooks/use-stay-folio-mutation.d.ts.map +1 -0
- package/dist/hooks/use-stay-folio-mutation.js +38 -0
- package/dist/hooks/use-stay-folios.d.ts +22 -0
- package/dist/hooks/use-stay-folios.d.ts.map +1 -0
- package/dist/hooks/use-stay-folios.js +11 -0
- package/dist/hooks/use-stay-operation-mutation.d.ts +51 -0
- package/dist/hooks/use-stay-operation-mutation.d.ts.map +1 -0
- package/dist/hooks/use-stay-operation-mutation.js +38 -0
- package/dist/hooks/use-stay-operations.d.ts +28 -0
- package/dist/hooks/use-stay-operations.d.ts.map +1 -0
- package/dist/hooks/use-stay-operations.js +11 -0
- package/dist/hooks/use-stay-rule-mutation.d.ts +74 -0
- package/dist/hooks/use-stay-rule-mutation.d.ts.map +1 -0
- package/dist/hooks/use-stay-rule-mutation.js +38 -0
- package/dist/hooks/use-stay-rules.d.ts +33 -0
- package/dist/hooks/use-stay-rules.d.ts.map +1 -0
- package/dist/hooks/use-stay-rules.js +11 -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 +129 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +48 -0
- package/dist/query-options.d.ts +1678 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +189 -0
- package/dist/schemas.d.ts +965 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +225 -0
- package/package.json +79 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { insertRatePlanInventoryOverrideSchema, updateRatePlanInventoryOverrideSchema } from "@voyantjs/hospitality";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateRatePlanInventoryOverrideInput = z.input<typeof insertRatePlanInventoryOverrideSchema>;
|
|
4
|
+
export type UpdateRatePlanInventoryOverrideInput = z.input<typeof updateRatePlanInventoryOverrideSchema>;
|
|
5
|
+
export declare function useRatePlanInventoryOverrideMutation(): {
|
|
6
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
ratePlanId: string;
|
|
8
|
+
roomTypeId: string;
|
|
9
|
+
date: string;
|
|
10
|
+
stopSell: boolean;
|
|
11
|
+
closedToArrival: boolean;
|
|
12
|
+
closedToDeparture: boolean;
|
|
13
|
+
id: string;
|
|
14
|
+
minNightsOverride: number | null;
|
|
15
|
+
maxNightsOverride: number | null;
|
|
16
|
+
notes: string | null;
|
|
17
|
+
}, Error, {
|
|
18
|
+
ratePlanId: string;
|
|
19
|
+
roomTypeId: string;
|
|
20
|
+
date: string;
|
|
21
|
+
stopSell?: boolean | undefined;
|
|
22
|
+
closedToArrival?: boolean | undefined;
|
|
23
|
+
closedToDeparture?: boolean | undefined;
|
|
24
|
+
minNightsOverride?: number | null | undefined;
|
|
25
|
+
maxNightsOverride?: number | null | undefined;
|
|
26
|
+
notes?: string | null | undefined;
|
|
27
|
+
}, unknown>;
|
|
28
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
29
|
+
ratePlanId: string;
|
|
30
|
+
roomTypeId: string;
|
|
31
|
+
date: string;
|
|
32
|
+
stopSell: boolean;
|
|
33
|
+
closedToArrival: boolean;
|
|
34
|
+
closedToDeparture: boolean;
|
|
35
|
+
id: string;
|
|
36
|
+
minNightsOverride: number | null;
|
|
37
|
+
maxNightsOverride: number | null;
|
|
38
|
+
notes: string | null;
|
|
39
|
+
}, Error, {
|
|
40
|
+
id: string;
|
|
41
|
+
input: UpdateRatePlanInventoryOverrideInput;
|
|
42
|
+
}, unknown>;
|
|
43
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
44
|
+
success: boolean;
|
|
45
|
+
}, Error, string, unknown>;
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=use-rate-plan-inventory-override-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-rate-plan-inventory-override-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-rate-plan-inventory-override-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,qCAAqC,EACrC,qCAAqC,EACtC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,oCAAoC,GAAG,CAAC,CAAC,KAAK,CACxD,OAAO,qCAAqC,CAC7C,CAAA;AACD,MAAM,MAAM,oCAAoC,GAAG,CAAC,CAAC,KAAK,CACxD,OAAO,qCAAqC,CAC7C,CAAA;AAED,wBAAgB,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA2B1C,MAAM;eACH,oCAAoC;;;;;EAmChD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantHospitalityContext } from "../provider.js";
|
|
5
|
+
import { hospitalityQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { ratePlanInventoryOverrideSingleResponse, successEnvelope } from "../schemas.js";
|
|
7
|
+
export function useRatePlanInventoryOverrideMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async (input) => {
|
|
12
|
+
const { data } = await fetchWithValidation("/v1/hospitality/rate-plan-inventory-overrides", ratePlanInventoryOverrideSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (data) => {
|
|
16
|
+
void queryClient.invalidateQueries({
|
|
17
|
+
queryKey: hospitalityQueryKeys.ratePlanInventoryOverrides(),
|
|
18
|
+
});
|
|
19
|
+
queryClient.setQueryData(hospitalityQueryKeys.ratePlanInventoryOverride(data.id), { data });
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
const update = useMutation({
|
|
23
|
+
mutationFn: async ({ id, input, }) => {
|
|
24
|
+
const { data } = await fetchWithValidation(`/v1/hospitality/rate-plan-inventory-overrides/${id}`, ratePlanInventoryOverrideSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
25
|
+
return data;
|
|
26
|
+
},
|
|
27
|
+
onSuccess: (data) => {
|
|
28
|
+
void queryClient.invalidateQueries({
|
|
29
|
+
queryKey: hospitalityQueryKeys.ratePlanInventoryOverrides(),
|
|
30
|
+
});
|
|
31
|
+
queryClient.setQueryData(hospitalityQueryKeys.ratePlanInventoryOverride(data.id), { data });
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const remove = useMutation({
|
|
35
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/hospitality/rate-plan-inventory-overrides/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
36
|
+
onSuccess: (_data, id) => {
|
|
37
|
+
void queryClient.invalidateQueries({
|
|
38
|
+
queryKey: hospitalityQueryKeys.ratePlanInventoryOverrides(),
|
|
39
|
+
});
|
|
40
|
+
queryClient.removeQueries({ queryKey: hospitalityQueryKeys.ratePlanInventoryOverride(id) });
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
return { create, update, remove };
|
|
44
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface UseRatePlanInventoryOverridesOptions {
|
|
2
|
+
ratePlanId?: string | undefined;
|
|
3
|
+
roomTypeId?: string | undefined;
|
|
4
|
+
dateFrom?: string | undefined;
|
|
5
|
+
dateTo?: string | undefined;
|
|
6
|
+
limit?: number | undefined;
|
|
7
|
+
offset?: number | undefined;
|
|
8
|
+
enabled?: boolean | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function useRatePlanInventoryOverrides(options: UseRatePlanInventoryOverridesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
11
|
+
data: {
|
|
12
|
+
ratePlanId: string;
|
|
13
|
+
roomTypeId: string;
|
|
14
|
+
date: string;
|
|
15
|
+
stopSell: boolean;
|
|
16
|
+
closedToArrival: boolean;
|
|
17
|
+
closedToDeparture: boolean;
|
|
18
|
+
id: string;
|
|
19
|
+
minNightsOverride: number | null;
|
|
20
|
+
maxNightsOverride: number | null;
|
|
21
|
+
notes: string | null;
|
|
22
|
+
}[];
|
|
23
|
+
total: number;
|
|
24
|
+
limit: number;
|
|
25
|
+
offset: number;
|
|
26
|
+
}, Error>;
|
|
27
|
+
//# sourceMappingURL=use-rate-plan-inventory-overrides.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-rate-plan-inventory-overrides.d.ts","sourceRoot":"","sources":["../../src/hooks/use-rate-plan-inventory-overrides.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,oCAAoC;IACnD,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,oCAAoC;;;;;;;;;;;;;;;;UAO1F"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantHospitalityContext } from "../provider.js";
|
|
4
|
+
import { getRatePlanInventoryOverridesQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useRatePlanInventoryOverrides(options) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
7
|
+
return useQuery({
|
|
8
|
+
...getRatePlanInventoryOverridesQueryOptions({ baseUrl, fetcher }, options),
|
|
9
|
+
enabled: Boolean(options.enabled ?? true),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { insertRatePlanSchema, updateRatePlanSchema } from "@voyantjs/hospitality";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateRatePlanInput = z.input<typeof insertRatePlanSchema>;
|
|
4
|
+
export type UpdateRatePlanInput = z.input<typeof updateRatePlanSchema>;
|
|
5
|
+
export declare function useRatePlanMutation(): {
|
|
6
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
propertyId: string;
|
|
8
|
+
code: string;
|
|
9
|
+
name: string;
|
|
10
|
+
currencyCode: string;
|
|
11
|
+
id: string;
|
|
12
|
+
description: string | null;
|
|
13
|
+
mealPlanId: string | null;
|
|
14
|
+
priceCatalogId: string | null;
|
|
15
|
+
cancellationPolicyId: string | null;
|
|
16
|
+
chargeFrequency: "per_night" | "per_stay" | "per_person_per_night" | "per_person_per_stay";
|
|
17
|
+
guaranteeMode: "none" | "card_hold" | "deposit" | "full_prepay" | "on_request";
|
|
18
|
+
commissionable: boolean;
|
|
19
|
+
refundable: boolean;
|
|
20
|
+
active: boolean;
|
|
21
|
+
sortOrder: number;
|
|
22
|
+
marketId?: string | null | undefined;
|
|
23
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
24
|
+
}, Error, {
|
|
25
|
+
propertyId: string;
|
|
26
|
+
code: string;
|
|
27
|
+
name: string;
|
|
28
|
+
currencyCode: string;
|
|
29
|
+
description?: string | null | undefined;
|
|
30
|
+
mealPlanId?: string | null | undefined;
|
|
31
|
+
priceCatalogId?: string | null | undefined;
|
|
32
|
+
cancellationPolicyId?: string | null | undefined;
|
|
33
|
+
marketId?: string | null | undefined;
|
|
34
|
+
chargeFrequency?: "per_night" | "per_stay" | "per_person_per_night" | "per_person_per_stay" | undefined;
|
|
35
|
+
guaranteeMode?: "none" | "card_hold" | "deposit" | "full_prepay" | "on_request" | undefined;
|
|
36
|
+
commissionable?: boolean | undefined;
|
|
37
|
+
refundable?: boolean | undefined;
|
|
38
|
+
active?: boolean | undefined;
|
|
39
|
+
sortOrder?: number | undefined;
|
|
40
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
41
|
+
}, unknown>;
|
|
42
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
43
|
+
propertyId: string;
|
|
44
|
+
code: string;
|
|
45
|
+
name: string;
|
|
46
|
+
currencyCode: string;
|
|
47
|
+
id: string;
|
|
48
|
+
description: string | null;
|
|
49
|
+
mealPlanId: string | null;
|
|
50
|
+
priceCatalogId: string | null;
|
|
51
|
+
cancellationPolicyId: string | null;
|
|
52
|
+
chargeFrequency: "per_night" | "per_stay" | "per_person_per_night" | "per_person_per_stay";
|
|
53
|
+
guaranteeMode: "none" | "card_hold" | "deposit" | "full_prepay" | "on_request";
|
|
54
|
+
commissionable: boolean;
|
|
55
|
+
refundable: boolean;
|
|
56
|
+
active: boolean;
|
|
57
|
+
sortOrder: number;
|
|
58
|
+
marketId?: string | null | undefined;
|
|
59
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
60
|
+
}, Error, {
|
|
61
|
+
id: string;
|
|
62
|
+
input: UpdateRatePlanInput;
|
|
63
|
+
}, unknown>;
|
|
64
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
65
|
+
success: boolean;
|
|
66
|
+
}, Error, string, unknown>;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=use-rate-plan-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-rate-plan-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-rate-plan-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACvF,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AACtE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEtE,wBAAgB,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBS,MAAM;eAAS,mBAAmB;;;;;EA8B7E"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantHospitalityContext } from "../provider.js";
|
|
5
|
+
import { hospitalityQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { ratePlanSingleResponse, successEnvelope } from "../schemas.js";
|
|
7
|
+
export function useRatePlanMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async (input) => {
|
|
12
|
+
const { data } = await fetchWithValidation("/v1/hospitality/rate-plans", ratePlanSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (data) => {
|
|
16
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.ratePlans() });
|
|
17
|
+
queryClient.setQueryData(hospitalityQueryKeys.ratePlan(data.id), { data });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const update = useMutation({
|
|
21
|
+
mutationFn: async ({ id, input }) => {
|
|
22
|
+
const { data } = await fetchWithValidation(`/v1/hospitality/rate-plans/${id}`, ratePlanSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
onSuccess: (data) => {
|
|
26
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.ratePlans() });
|
|
27
|
+
queryClient.setQueryData(hospitalityQueryKeys.ratePlan(data.id), { data });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const remove = useMutation({
|
|
31
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/hospitality/rate-plans/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
32
|
+
onSuccess: (_data, id) => {
|
|
33
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.ratePlans() });
|
|
34
|
+
queryClient.removeQueries({ queryKey: hospitalityQueryKeys.ratePlan(id) });
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return { create, update, remove };
|
|
38
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { insertRatePlanRoomTypeSchema, updateRatePlanRoomTypeSchema } from "@voyantjs/hospitality";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateRatePlanRoomTypeInput = z.input<typeof insertRatePlanRoomTypeSchema>;
|
|
4
|
+
export type UpdateRatePlanRoomTypeInput = z.input<typeof updateRatePlanRoomTypeSchema>;
|
|
5
|
+
export declare function useRatePlanRoomTypeMutation(): {
|
|
6
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
ratePlanId: string;
|
|
8
|
+
roomTypeId: string;
|
|
9
|
+
id: string;
|
|
10
|
+
productId: string | null;
|
|
11
|
+
optionId: string | null;
|
|
12
|
+
unitId: string | null;
|
|
13
|
+
active: boolean;
|
|
14
|
+
sortOrder: number;
|
|
15
|
+
}, Error, {
|
|
16
|
+
ratePlanId: string;
|
|
17
|
+
roomTypeId: string;
|
|
18
|
+
productId?: string | null | undefined;
|
|
19
|
+
optionId?: string | null | undefined;
|
|
20
|
+
unitId?: string | null | undefined;
|
|
21
|
+
active?: boolean | undefined;
|
|
22
|
+
sortOrder?: number | undefined;
|
|
23
|
+
}, unknown>;
|
|
24
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
25
|
+
ratePlanId: string;
|
|
26
|
+
roomTypeId: string;
|
|
27
|
+
id: string;
|
|
28
|
+
productId: string | null;
|
|
29
|
+
optionId: string | null;
|
|
30
|
+
unitId: string | null;
|
|
31
|
+
active: boolean;
|
|
32
|
+
sortOrder: number;
|
|
33
|
+
}, Error, {
|
|
34
|
+
id: string;
|
|
35
|
+
input: UpdateRatePlanRoomTypeInput;
|
|
36
|
+
}, unknown>;
|
|
37
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
38
|
+
success: boolean;
|
|
39
|
+
}, Error, string, unknown>;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=use-rate-plan-room-type-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-rate-plan-room-type-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-rate-plan-room-type-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,4BAA4B,EAC5B,4BAA4B,EAC7B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AACtF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAEtF,wBAAgB,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBC,MAAM;eAAS,2BAA2B;;;;;EA8BrF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantHospitalityContext } from "../provider.js";
|
|
5
|
+
import { hospitalityQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { ratePlanRoomTypeSingleResponse, successEnvelope } from "../schemas.js";
|
|
7
|
+
export function useRatePlanRoomTypeMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async (input) => {
|
|
12
|
+
const { data } = await fetchWithValidation("/v1/hospitality/rate-plan-room-types", ratePlanRoomTypeSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (data) => {
|
|
16
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.ratePlanRoomTypes() });
|
|
17
|
+
queryClient.setQueryData(hospitalityQueryKeys.ratePlanRoomType(data.id), { data });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const update = useMutation({
|
|
21
|
+
mutationFn: async ({ id, input }) => {
|
|
22
|
+
const { data } = await fetchWithValidation(`/v1/hospitality/rate-plan-room-types/${id}`, ratePlanRoomTypeSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
onSuccess: (data) => {
|
|
26
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.ratePlanRoomTypes() });
|
|
27
|
+
queryClient.setQueryData(hospitalityQueryKeys.ratePlanRoomType(data.id), { data });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const remove = useMutation({
|
|
31
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/hospitality/rate-plan-room-types/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
32
|
+
onSuccess: (_data, id) => {
|
|
33
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.ratePlanRoomTypes() });
|
|
34
|
+
queryClient.removeQueries({ queryKey: hospitalityQueryKeys.ratePlanRoomType(id) });
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return { create, update, remove };
|
|
38
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface UseRatePlanRoomTypesOptions {
|
|
2
|
+
ratePlanId?: string | undefined;
|
|
3
|
+
roomTypeId?: string | undefined;
|
|
4
|
+
productId?: string | undefined;
|
|
5
|
+
active?: boolean | undefined;
|
|
6
|
+
limit?: number | undefined;
|
|
7
|
+
offset?: number | undefined;
|
|
8
|
+
enabled?: boolean | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function useRatePlanRoomTypes(options: UseRatePlanRoomTypesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
11
|
+
data: {
|
|
12
|
+
ratePlanId: string;
|
|
13
|
+
roomTypeId: string;
|
|
14
|
+
id: string;
|
|
15
|
+
productId: string | null;
|
|
16
|
+
optionId: string | null;
|
|
17
|
+
unitId: string | null;
|
|
18
|
+
active: boolean;
|
|
19
|
+
sortOrder: number;
|
|
20
|
+
}[];
|
|
21
|
+
total: number;
|
|
22
|
+
limit: number;
|
|
23
|
+
offset: number;
|
|
24
|
+
}, Error>;
|
|
25
|
+
//# sourceMappingURL=use-rate-plan-room-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-rate-plan-room-types.d.ts","sourceRoot":"","sources":["../../src/hooks/use-rate-plan-room-types.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,2BAA2B;IAC1C,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B;;;;;;;;;;;;;;UAOxE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantHospitalityContext } from "../provider.js";
|
|
4
|
+
import { getRatePlanRoomTypesQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useRatePlanRoomTypes(options) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
7
|
+
return useQuery({
|
|
8
|
+
...getRatePlanRoomTypesQueryOptions({ baseUrl, fetcher }, options),
|
|
9
|
+
enabled: Boolean(options.enabled ?? true),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface UseRatePlanOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useRatePlan(id: string | null | undefined, options?: UseRatePlanOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
propertyId: string;
|
|
6
|
+
code: string;
|
|
7
|
+
name: string;
|
|
8
|
+
currencyCode: string;
|
|
9
|
+
id: string;
|
|
10
|
+
description: string | null;
|
|
11
|
+
mealPlanId: string | null;
|
|
12
|
+
priceCatalogId: string | null;
|
|
13
|
+
cancellationPolicyId: string | null;
|
|
14
|
+
chargeFrequency: "per_night" | "per_stay" | "per_person_per_night" | "per_person_per_stay";
|
|
15
|
+
guaranteeMode: "none" | "card_hold" | "deposit" | "full_prepay" | "on_request";
|
|
16
|
+
commissionable: boolean;
|
|
17
|
+
refundable: boolean;
|
|
18
|
+
active: boolean;
|
|
19
|
+
sortOrder: number;
|
|
20
|
+
marketId?: string | null | undefined;
|
|
21
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
22
|
+
}, Error>;
|
|
23
|
+
//# sourceMappingURL=use-rate-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-rate-plan.d.ts","sourceRoot":"","sources":["../../src/hooks/use-rate-plan.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,GAAE,kBAAuB;;;;;;;;;;;;;;;;;;UAQ1F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantHospitalityContext } from "../provider.js";
|
|
4
|
+
import { getRatePlanQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useRatePlan(id, options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getRatePlanQueryOptions({ baseUrl, fetcher }, id ?? "__missing__"),
|
|
10
|
+
enabled: enabled && Boolean(id),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface UseRatePlansOptions {
|
|
2
|
+
propertyId: string | null | undefined;
|
|
3
|
+
search?: string | undefined;
|
|
4
|
+
limit?: number | undefined;
|
|
5
|
+
offset?: number | undefined;
|
|
6
|
+
enabled?: boolean | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare function useRatePlans(options: UseRatePlansOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
9
|
+
data: {
|
|
10
|
+
propertyId: string;
|
|
11
|
+
code: string;
|
|
12
|
+
name: string;
|
|
13
|
+
currencyCode: string;
|
|
14
|
+
id: string;
|
|
15
|
+
description: string | null;
|
|
16
|
+
mealPlanId: string | null;
|
|
17
|
+
priceCatalogId: string | null;
|
|
18
|
+
cancellationPolicyId: string | null;
|
|
19
|
+
chargeFrequency: "per_night" | "per_stay" | "per_person_per_night" | "per_person_per_stay";
|
|
20
|
+
guaranteeMode: "none" | "card_hold" | "deposit" | "full_prepay" | "on_request";
|
|
21
|
+
commissionable: boolean;
|
|
22
|
+
refundable: boolean;
|
|
23
|
+
active: boolean;
|
|
24
|
+
sortOrder: number;
|
|
25
|
+
marketId?: string | null | undefined;
|
|
26
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
27
|
+
}[];
|
|
28
|
+
total: number;
|
|
29
|
+
limit: number;
|
|
30
|
+
offset: number;
|
|
31
|
+
}, Error>;
|
|
32
|
+
//# sourceMappingURL=use-rate-plans.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-rate-plans.d.ts","sourceRoot":"","sources":["../../src/hooks/use-rate-plans.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACrC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;UAOxD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantHospitalityContext } from "../provider.js";
|
|
4
|
+
import { getRatePlansQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useRatePlans(options) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
7
|
+
return useQuery({
|
|
8
|
+
...getRatePlansQueryOptions({ baseUrl, fetcher }, options),
|
|
9
|
+
enabled: Boolean(options.enabled ?? true) && Boolean(options.propertyId),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { insertRoomBlockSchema, updateRoomBlockSchema } from "@voyantjs/hospitality";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateRoomBlockInput = z.input<typeof insertRoomBlockSchema>;
|
|
4
|
+
export type UpdateRoomBlockInput = z.input<typeof updateRoomBlockSchema>;
|
|
5
|
+
export declare function useRoomBlockMutation(): {
|
|
6
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
id: string;
|
|
8
|
+
propertyId: string;
|
|
9
|
+
roomTypeId: string | null;
|
|
10
|
+
roomUnitId: string | null;
|
|
11
|
+
startsOn: string;
|
|
12
|
+
endsOn: string;
|
|
13
|
+
status: "draft" | "confirmed" | "cancelled" | "held" | "released";
|
|
14
|
+
blockReason: string | null;
|
|
15
|
+
quantity: number;
|
|
16
|
+
releaseAt: string | null;
|
|
17
|
+
notes: string | null;
|
|
18
|
+
}, Error, {
|
|
19
|
+
propertyId: string;
|
|
20
|
+
startsOn: string;
|
|
21
|
+
endsOn: string;
|
|
22
|
+
roomTypeId?: string | null | undefined;
|
|
23
|
+
roomUnitId?: string | null | undefined;
|
|
24
|
+
status?: "draft" | "confirmed" | "cancelled" | "held" | "released" | undefined;
|
|
25
|
+
blockReason?: string | null | undefined;
|
|
26
|
+
quantity?: number | undefined;
|
|
27
|
+
releaseAt?: string | null | undefined;
|
|
28
|
+
notes?: string | null | undefined;
|
|
29
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
30
|
+
}, unknown>;
|
|
31
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
32
|
+
id: string;
|
|
33
|
+
propertyId: string;
|
|
34
|
+
roomTypeId: string | null;
|
|
35
|
+
roomUnitId: string | null;
|
|
36
|
+
startsOn: string;
|
|
37
|
+
endsOn: string;
|
|
38
|
+
status: "draft" | "confirmed" | "cancelled" | "held" | "released";
|
|
39
|
+
blockReason: string | null;
|
|
40
|
+
quantity: number;
|
|
41
|
+
releaseAt: string | null;
|
|
42
|
+
notes: string | null;
|
|
43
|
+
}, Error, {
|
|
44
|
+
id: string;
|
|
45
|
+
input: UpdateRoomBlockInput;
|
|
46
|
+
}, unknown>;
|
|
47
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
48
|
+
success: boolean;
|
|
49
|
+
}, Error, string, unknown>;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=use-room-block-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-room-block-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-room-block-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AACzF,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AACxE,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAExE,wBAAgB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBQ,MAAM;eAAS,oBAAoB;;;;;EA8B9E"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantHospitalityContext } from "../provider.js";
|
|
5
|
+
import { hospitalityQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { roomBlockSingleResponse, successEnvelope } from "../schemas.js";
|
|
7
|
+
export function useRoomBlockMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async (input) => {
|
|
12
|
+
const { data } = await fetchWithValidation("/v1/hospitality/room-blocks", roomBlockSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (data) => {
|
|
16
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomBlocks() });
|
|
17
|
+
queryClient.setQueryData(hospitalityQueryKeys.roomBlock(data.id), { data });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const update = useMutation({
|
|
21
|
+
mutationFn: async ({ id, input }) => {
|
|
22
|
+
const { data } = await fetchWithValidation(`/v1/hospitality/room-blocks/${id}`, roomBlockSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
onSuccess: (data) => {
|
|
26
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomBlocks() });
|
|
27
|
+
queryClient.setQueryData(hospitalityQueryKeys.roomBlock(data.id), { data });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const remove = useMutation({
|
|
31
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/hospitality/room-blocks/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
32
|
+
onSuccess: (_data, id) => {
|
|
33
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomBlocks() });
|
|
34
|
+
queryClient.removeQueries({ queryKey: hospitalityQueryKeys.roomBlock(id) });
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return { create, update, remove };
|
|
38
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface UseRoomBlocksOptions {
|
|
2
|
+
propertyId: string | null | undefined;
|
|
3
|
+
limit?: number | undefined;
|
|
4
|
+
offset?: number | undefined;
|
|
5
|
+
enabled?: boolean | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare function useRoomBlocks(options: UseRoomBlocksOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
8
|
+
data: {
|
|
9
|
+
id: string;
|
|
10
|
+
propertyId: string;
|
|
11
|
+
roomTypeId: string | null;
|
|
12
|
+
roomUnitId: string | null;
|
|
13
|
+
startsOn: string;
|
|
14
|
+
endsOn: string;
|
|
15
|
+
status: "draft" | "confirmed" | "cancelled" | "held" | "released";
|
|
16
|
+
blockReason: string | null;
|
|
17
|
+
quantity: number;
|
|
18
|
+
releaseAt: string | null;
|
|
19
|
+
notes: string | null;
|
|
20
|
+
}[];
|
|
21
|
+
total: number;
|
|
22
|
+
limit: number;
|
|
23
|
+
offset: number;
|
|
24
|
+
}, Error>;
|
|
25
|
+
//# sourceMappingURL=use-room-blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-room-blocks.d.ts","sourceRoot":"","sources":["../../src/hooks/use-room-blocks.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACrC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB;;;;;;;;;;;;;;;;;UAO1D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantHospitalityContext } from "../provider.js";
|
|
4
|
+
import { getRoomBlocksQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useRoomBlocks(options) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
7
|
+
return useQuery({
|
|
8
|
+
...getRoomBlocksQueryOptions({ baseUrl, fetcher }, options),
|
|
9
|
+
enabled: Boolean(options.enabled ?? true) && Boolean(options.propertyId),
|
|
10
|
+
});
|
|
11
|
+
}
|