@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,53 @@
|
|
|
1
|
+
import type { insertRoomInventorySchema, updateRoomInventorySchema } from "@voyantjs/hospitality";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateRoomInventoryInput = z.input<typeof insertRoomInventorySchema>;
|
|
4
|
+
export type UpdateRoomInventoryInput = z.input<typeof updateRoomInventorySchema>;
|
|
5
|
+
export declare function useRoomInventoryMutation(): {
|
|
6
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
id: string;
|
|
8
|
+
propertyId: string;
|
|
9
|
+
roomTypeId: string;
|
|
10
|
+
date: string;
|
|
11
|
+
totalUnits: number;
|
|
12
|
+
availableUnits: number;
|
|
13
|
+
heldUnits: number;
|
|
14
|
+
soldUnits: number;
|
|
15
|
+
outOfOrderUnits: number;
|
|
16
|
+
overbookLimit: number | null;
|
|
17
|
+
stopSell: boolean;
|
|
18
|
+
notes: string | null;
|
|
19
|
+
}, Error, {
|
|
20
|
+
propertyId: string;
|
|
21
|
+
roomTypeId: string;
|
|
22
|
+
date: string;
|
|
23
|
+
totalUnits?: number | undefined;
|
|
24
|
+
availableUnits?: number | undefined;
|
|
25
|
+
heldUnits?: number | undefined;
|
|
26
|
+
soldUnits?: number | undefined;
|
|
27
|
+
outOfOrderUnits?: number | undefined;
|
|
28
|
+
overbookLimit?: number | null | undefined;
|
|
29
|
+
stopSell?: boolean | undefined;
|
|
30
|
+
notes?: string | null | undefined;
|
|
31
|
+
}, unknown>;
|
|
32
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
33
|
+
id: string;
|
|
34
|
+
propertyId: string;
|
|
35
|
+
roomTypeId: string;
|
|
36
|
+
date: string;
|
|
37
|
+
totalUnits: number;
|
|
38
|
+
availableUnits: number;
|
|
39
|
+
heldUnits: number;
|
|
40
|
+
soldUnits: number;
|
|
41
|
+
outOfOrderUnits: number;
|
|
42
|
+
overbookLimit: number | null;
|
|
43
|
+
stopSell: boolean;
|
|
44
|
+
notes: string | null;
|
|
45
|
+
}, Error, {
|
|
46
|
+
id: string;
|
|
47
|
+
input: UpdateRoomInventoryInput;
|
|
48
|
+
}, unknown>;
|
|
49
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
50
|
+
success: boolean;
|
|
51
|
+
}, Error, string, unknown>;
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=use-room-inventory-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-room-inventory-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-room-inventory-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACjG,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAChF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAEhF,wBAAgB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBI,MAAM;eAAS,wBAAwB;;;;;EA8BlF"}
|
|
@@ -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 { roomInventorySingleResponse, successEnvelope } from "../schemas.js";
|
|
7
|
+
export function useRoomInventoryMutation() {
|
|
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-inventory", roomInventorySingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (data) => {
|
|
16
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomInventory() });
|
|
17
|
+
queryClient.setQueryData(hospitalityQueryKeys.roomInventoryItem(data.id), { data });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const update = useMutation({
|
|
21
|
+
mutationFn: async ({ id, input }) => {
|
|
22
|
+
const { data } = await fetchWithValidation(`/v1/hospitality/room-inventory/${id}`, roomInventorySingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
onSuccess: (data) => {
|
|
26
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomInventory() });
|
|
27
|
+
queryClient.setQueryData(hospitalityQueryKeys.roomInventoryItem(data.id), { data });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const remove = useMutation({
|
|
31
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/hospitality/room-inventory/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
32
|
+
onSuccess: (_data, id) => {
|
|
33
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomInventory() });
|
|
34
|
+
queryClient.removeQueries({ queryKey: hospitalityQueryKeys.roomInventoryItem(id) });
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return { create, update, remove };
|
|
38
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface UseRoomInventoryOptions {
|
|
2
|
+
propertyId: string | null | 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 useRoomInventory(options: UseRoomInventoryOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
11
|
+
data: {
|
|
12
|
+
id: string;
|
|
13
|
+
propertyId: string;
|
|
14
|
+
roomTypeId: string;
|
|
15
|
+
date: string;
|
|
16
|
+
totalUnits: number;
|
|
17
|
+
availableUnits: number;
|
|
18
|
+
heldUnits: number;
|
|
19
|
+
soldUnits: number;
|
|
20
|
+
outOfOrderUnits: number;
|
|
21
|
+
overbookLimit: number | null;
|
|
22
|
+
stopSell: boolean;
|
|
23
|
+
notes: string | null;
|
|
24
|
+
}[];
|
|
25
|
+
total: number;
|
|
26
|
+
limit: number;
|
|
27
|
+
offset: number;
|
|
28
|
+
}, Error>;
|
|
29
|
+
//# sourceMappingURL=use-room-inventory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-room-inventory.d.ts","sourceRoot":"","sources":["../../src/hooks/use-room-inventory.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACrC,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,gBAAgB,CAAC,OAAO,EAAE,uBAAuB;;;;;;;;;;;;;;;;;;UAOhE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantHospitalityContext } from "../provider.js";
|
|
4
|
+
import { getRoomInventoryQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useRoomInventory(options) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
7
|
+
return useQuery({
|
|
8
|
+
...getRoomInventoryQueryOptions({ baseUrl, fetcher }, options),
|
|
9
|
+
enabled: Boolean(options.enabled ?? true) && Boolean(options.propertyId),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { insertRoomTypeSchema, updateRoomTypeSchema } from "@voyantjs/hospitality";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateRoomTypeInput = z.input<typeof insertRoomTypeSchema>;
|
|
4
|
+
export type UpdateRoomTypeInput = z.input<typeof updateRoomTypeSchema>;
|
|
5
|
+
export declare function useRoomTypeMutation(): {
|
|
6
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
propertyId: string;
|
|
8
|
+
name: string;
|
|
9
|
+
id: string;
|
|
10
|
+
code: string | null;
|
|
11
|
+
description: string | null;
|
|
12
|
+
maxAdults: number | null;
|
|
13
|
+
maxChildren: number | null;
|
|
14
|
+
maxInfants: number | null;
|
|
15
|
+
standardOccupancy: number | null;
|
|
16
|
+
maxOccupancy: number | null;
|
|
17
|
+
minOccupancy: number | null;
|
|
18
|
+
bedroomCount: number | null;
|
|
19
|
+
bathroomCount: number | null;
|
|
20
|
+
smokingAllowed: boolean;
|
|
21
|
+
active: boolean;
|
|
22
|
+
sortOrder: number;
|
|
23
|
+
inventoryMode: "virtual" | "pooled" | "serialized";
|
|
24
|
+
roomClass?: string | null | undefined;
|
|
25
|
+
areaValue?: number | null | undefined;
|
|
26
|
+
areaUnit?: string | null | undefined;
|
|
27
|
+
accessibilityNotes?: string | null | undefined;
|
|
28
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
29
|
+
}, Error, {
|
|
30
|
+
propertyId: string;
|
|
31
|
+
name: string;
|
|
32
|
+
code?: string | null | undefined;
|
|
33
|
+
description?: string | null | undefined;
|
|
34
|
+
inventoryMode?: "virtual" | "pooled" | "serialized" | undefined;
|
|
35
|
+
roomClass?: string | null | undefined;
|
|
36
|
+
maxAdults?: number | null | undefined;
|
|
37
|
+
maxChildren?: number | null | undefined;
|
|
38
|
+
maxInfants?: number | null | undefined;
|
|
39
|
+
standardOccupancy?: number | null | undefined;
|
|
40
|
+
maxOccupancy?: number | null | undefined;
|
|
41
|
+
minOccupancy?: number | null | undefined;
|
|
42
|
+
bedroomCount?: number | null | undefined;
|
|
43
|
+
bathroomCount?: number | null | undefined;
|
|
44
|
+
areaValue?: number | null | undefined;
|
|
45
|
+
areaUnit?: string | null | undefined;
|
|
46
|
+
accessibilityNotes?: string | null | undefined;
|
|
47
|
+
smokingAllowed?: boolean | undefined;
|
|
48
|
+
active?: boolean | undefined;
|
|
49
|
+
sortOrder?: number | undefined;
|
|
50
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
51
|
+
}, unknown>;
|
|
52
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
53
|
+
propertyId: string;
|
|
54
|
+
name: string;
|
|
55
|
+
id: string;
|
|
56
|
+
code: string | null;
|
|
57
|
+
description: string | null;
|
|
58
|
+
maxAdults: number | null;
|
|
59
|
+
maxChildren: number | null;
|
|
60
|
+
maxInfants: number | null;
|
|
61
|
+
standardOccupancy: number | null;
|
|
62
|
+
maxOccupancy: number | null;
|
|
63
|
+
minOccupancy: number | null;
|
|
64
|
+
bedroomCount: number | null;
|
|
65
|
+
bathroomCount: number | null;
|
|
66
|
+
smokingAllowed: boolean;
|
|
67
|
+
active: boolean;
|
|
68
|
+
sortOrder: number;
|
|
69
|
+
inventoryMode: "virtual" | "pooled" | "serialized";
|
|
70
|
+
roomClass?: string | null | undefined;
|
|
71
|
+
areaValue?: number | null | undefined;
|
|
72
|
+
areaUnit?: string | null | undefined;
|
|
73
|
+
accessibilityNotes?: string | null | undefined;
|
|
74
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
75
|
+
}, Error, {
|
|
76
|
+
id: string;
|
|
77
|
+
input: UpdateRoomTypeInput;
|
|
78
|
+
}, unknown>;
|
|
79
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
80
|
+
success: boolean;
|
|
81
|
+
}, Error, string, unknown>;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=use-room-type-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-room-type-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-room-type-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 { roomTypeSingleResponse, successEnvelope } from "../schemas.js";
|
|
7
|
+
export function useRoomTypeMutation() {
|
|
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-types", roomTypeSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (data) => {
|
|
16
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomTypes() });
|
|
17
|
+
queryClient.setQueryData(hospitalityQueryKeys.roomType(data.id), { data });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const update = useMutation({
|
|
21
|
+
mutationFn: async ({ id, input }) => {
|
|
22
|
+
const { data } = await fetchWithValidation(`/v1/hospitality/room-types/${id}`, roomTypeSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
onSuccess: (data) => {
|
|
26
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomTypes() });
|
|
27
|
+
queryClient.setQueryData(hospitalityQueryKeys.roomType(data.id), { data });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const remove = useMutation({
|
|
31
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/hospitality/room-types/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
32
|
+
onSuccess: (_data, id) => {
|
|
33
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomTypes() });
|
|
34
|
+
queryClient.removeQueries({ queryKey: hospitalityQueryKeys.roomType(id) });
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return { create, update, remove };
|
|
38
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { insertRoomTypeRateSchema, updateRoomTypeRateSchema } from "@voyantjs/hospitality";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateRoomTypeRateInput = z.input<typeof insertRoomTypeRateSchema>;
|
|
4
|
+
export type UpdateRoomTypeRateInput = z.input<typeof updateRoomTypeRateSchema>;
|
|
5
|
+
export declare function useRoomTypeRateMutation(): {
|
|
6
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
ratePlanId: string;
|
|
8
|
+
roomTypeId: string;
|
|
9
|
+
currencyCode: string;
|
|
10
|
+
id: string;
|
|
11
|
+
priceScheduleId: string | null;
|
|
12
|
+
baseAmountCents: number | null;
|
|
13
|
+
extraAdultAmountCents: number | null;
|
|
14
|
+
extraChildAmountCents: number | null;
|
|
15
|
+
extraInfantAmountCents: number | null;
|
|
16
|
+
active: boolean;
|
|
17
|
+
notes: string | null;
|
|
18
|
+
}, Error, {
|
|
19
|
+
ratePlanId: string;
|
|
20
|
+
roomTypeId: string;
|
|
21
|
+
currencyCode: string;
|
|
22
|
+
priceScheduleId?: string | null | undefined;
|
|
23
|
+
baseAmountCents?: number | null | undefined;
|
|
24
|
+
extraAdultAmountCents?: number | null | undefined;
|
|
25
|
+
extraChildAmountCents?: number | null | undefined;
|
|
26
|
+
extraInfantAmountCents?: number | null | undefined;
|
|
27
|
+
active?: boolean | undefined;
|
|
28
|
+
notes?: string | null | undefined;
|
|
29
|
+
}, unknown>;
|
|
30
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
31
|
+
ratePlanId: string;
|
|
32
|
+
roomTypeId: string;
|
|
33
|
+
currencyCode: string;
|
|
34
|
+
id: string;
|
|
35
|
+
priceScheduleId: string | null;
|
|
36
|
+
baseAmountCents: number | null;
|
|
37
|
+
extraAdultAmountCents: number | null;
|
|
38
|
+
extraChildAmountCents: number | null;
|
|
39
|
+
extraInfantAmountCents: number | null;
|
|
40
|
+
active: boolean;
|
|
41
|
+
notes: string | null;
|
|
42
|
+
}, Error, {
|
|
43
|
+
id: string;
|
|
44
|
+
input: UpdateRoomTypeRateInput;
|
|
45
|
+
}, unknown>;
|
|
46
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
47
|
+
success: boolean;
|
|
48
|
+
}, Error, string, unknown>;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=use-room-type-rate-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-room-type-rate-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-room-type-rate-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAC/F,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAC9E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAE9E,wBAAgB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBK,MAAM;eAAS,uBAAuB;;;;;EA8BjF"}
|
|
@@ -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 { roomTypeRateSingleResponse, successEnvelope } from "../schemas.js";
|
|
7
|
+
export function useRoomTypeRateMutation() {
|
|
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-type-rates", roomTypeRateSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (data) => {
|
|
16
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomTypeRates() });
|
|
17
|
+
queryClient.setQueryData(hospitalityQueryKeys.roomTypeRate(data.id), { data });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const update = useMutation({
|
|
21
|
+
mutationFn: async ({ id, input }) => {
|
|
22
|
+
const { data } = await fetchWithValidation(`/v1/hospitality/room-type-rates/${id}`, roomTypeRateSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
onSuccess: (data) => {
|
|
26
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomTypeRates() });
|
|
27
|
+
queryClient.setQueryData(hospitalityQueryKeys.roomTypeRate(data.id), { data });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const remove = useMutation({
|
|
31
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/hospitality/room-type-rates/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
32
|
+
onSuccess: (_data, id) => {
|
|
33
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomTypeRates() });
|
|
34
|
+
queryClient.removeQueries({ queryKey: hospitalityQueryKeys.roomTypeRate(id) });
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return { create, update, remove };
|
|
38
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface UseRoomTypeRatesOptions {
|
|
2
|
+
ratePlanId?: string | undefined;
|
|
3
|
+
roomTypeId?: string | undefined;
|
|
4
|
+
priceScheduleId?: string | undefined;
|
|
5
|
+
active?: boolean | undefined;
|
|
6
|
+
limit?: number | undefined;
|
|
7
|
+
offset?: number | undefined;
|
|
8
|
+
enabled?: boolean | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare function useRoomTypeRates(options: UseRoomTypeRatesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
11
|
+
data: {
|
|
12
|
+
ratePlanId: string;
|
|
13
|
+
roomTypeId: string;
|
|
14
|
+
currencyCode: string;
|
|
15
|
+
id: string;
|
|
16
|
+
priceScheduleId: string | null;
|
|
17
|
+
baseAmountCents: number | null;
|
|
18
|
+
extraAdultAmountCents: number | null;
|
|
19
|
+
extraChildAmountCents: number | null;
|
|
20
|
+
extraInfantAmountCents: number | null;
|
|
21
|
+
active: boolean;
|
|
22
|
+
notes: string | null;
|
|
23
|
+
}[];
|
|
24
|
+
total: number;
|
|
25
|
+
limit: number;
|
|
26
|
+
offset: number;
|
|
27
|
+
}, Error>;
|
|
28
|
+
//# sourceMappingURL=use-room-type-rates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-room-type-rates.d.ts","sourceRoot":"","sources":["../../src/hooks/use-room-type-rates.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,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,gBAAgB,CAAC,OAAO,EAAE,uBAAuB;;;;;;;;;;;;;;;;;UAOhE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantHospitalityContext } from "../provider.js";
|
|
4
|
+
import { getRoomTypeRatesQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useRoomTypeRates(options) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
7
|
+
return useQuery({
|
|
8
|
+
...getRoomTypeRatesQueryOptions({ baseUrl, fetcher }, options),
|
|
9
|
+
enabled: Boolean(options.enabled ?? true),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface UseRoomTypeOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useRoomType(id: string | null | undefined, options?: UseRoomTypeOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
propertyId: string;
|
|
6
|
+
name: string;
|
|
7
|
+
id: string;
|
|
8
|
+
code: string | null;
|
|
9
|
+
description: string | null;
|
|
10
|
+
maxAdults: number | null;
|
|
11
|
+
maxChildren: number | null;
|
|
12
|
+
maxInfants: number | null;
|
|
13
|
+
standardOccupancy: number | null;
|
|
14
|
+
maxOccupancy: number | null;
|
|
15
|
+
minOccupancy: number | null;
|
|
16
|
+
bedroomCount: number | null;
|
|
17
|
+
bathroomCount: number | null;
|
|
18
|
+
smokingAllowed: boolean;
|
|
19
|
+
active: boolean;
|
|
20
|
+
sortOrder: number;
|
|
21
|
+
inventoryMode: "virtual" | "pooled" | "serialized";
|
|
22
|
+
roomClass?: string | null | undefined;
|
|
23
|
+
areaValue?: number | null | undefined;
|
|
24
|
+
areaUnit?: string | null | undefined;
|
|
25
|
+
accessibilityNotes?: string | null | undefined;
|
|
26
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
27
|
+
}, Error>;
|
|
28
|
+
//# sourceMappingURL=use-room-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-room-type.d.ts","sourceRoot":"","sources":["../../src/hooks/use-room-type.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 { getRoomTypeQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useRoomType(id, options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getRoomTypeQueryOptions({ baseUrl, fetcher }, id ?? "__missing__"),
|
|
10
|
+
enabled: enabled && Boolean(id),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface UseRoomTypesOptions {
|
|
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 useRoomTypes(options: UseRoomTypesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
9
|
+
data: {
|
|
10
|
+
propertyId: string;
|
|
11
|
+
name: string;
|
|
12
|
+
id: string;
|
|
13
|
+
code: string | null;
|
|
14
|
+
description: string | null;
|
|
15
|
+
maxAdults: number | null;
|
|
16
|
+
maxChildren: number | null;
|
|
17
|
+
maxInfants: number | null;
|
|
18
|
+
standardOccupancy: number | null;
|
|
19
|
+
maxOccupancy: number | null;
|
|
20
|
+
minOccupancy: number | null;
|
|
21
|
+
bedroomCount: number | null;
|
|
22
|
+
bathroomCount: number | null;
|
|
23
|
+
smokingAllowed: boolean;
|
|
24
|
+
active: boolean;
|
|
25
|
+
sortOrder: number;
|
|
26
|
+
inventoryMode: "virtual" | "pooled" | "serialized";
|
|
27
|
+
roomClass?: string | null | undefined;
|
|
28
|
+
areaValue?: number | null | undefined;
|
|
29
|
+
areaUnit?: string | null | undefined;
|
|
30
|
+
accessibilityNotes?: string | null | undefined;
|
|
31
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
32
|
+
}[];
|
|
33
|
+
total: number;
|
|
34
|
+
limit: number;
|
|
35
|
+
offset: number;
|
|
36
|
+
}, Error>;
|
|
37
|
+
//# sourceMappingURL=use-room-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-room-types.d.ts","sourceRoot":"","sources":["../../src/hooks/use-room-types.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 { getRoomTypesQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useRoomTypes(options) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
7
|
+
return useQuery({
|
|
8
|
+
...getRoomTypesQueryOptions({ baseUrl, fetcher }, options),
|
|
9
|
+
enabled: Boolean(options.enabled ?? true) && Boolean(options.propertyId),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { insertRoomUnitSchema, updateRoomUnitSchema } from "@voyantjs/hospitality";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateRoomUnitInput = z.input<typeof insertRoomUnitSchema>;
|
|
4
|
+
export type UpdateRoomUnitInput = z.input<typeof updateRoomUnitSchema>;
|
|
5
|
+
export declare function useRoomUnitMutation(): {
|
|
6
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
propertyId: string;
|
|
8
|
+
roomTypeId: string;
|
|
9
|
+
id: string;
|
|
10
|
+
code: string | null;
|
|
11
|
+
roomNumber: string | null;
|
|
12
|
+
floor: string | null;
|
|
13
|
+
wing: string | null;
|
|
14
|
+
status: "active" | "inactive" | "archived" | "out_of_order";
|
|
15
|
+
viewCode: string | null;
|
|
16
|
+
accessibilityCode: string | null;
|
|
17
|
+
genderRestriction: string | null;
|
|
18
|
+
notes: string | null;
|
|
19
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
20
|
+
}, Error, {
|
|
21
|
+
propertyId: string;
|
|
22
|
+
roomTypeId: string;
|
|
23
|
+
code?: string | null | undefined;
|
|
24
|
+
roomNumber?: string | null | undefined;
|
|
25
|
+
floor?: string | null | undefined;
|
|
26
|
+
wing?: string | null | undefined;
|
|
27
|
+
status?: "active" | "inactive" | "archived" | "out_of_order" | undefined;
|
|
28
|
+
viewCode?: string | null | undefined;
|
|
29
|
+
accessibilityCode?: string | null | undefined;
|
|
30
|
+
genderRestriction?: string | null | undefined;
|
|
31
|
+
notes?: string | null | undefined;
|
|
32
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
33
|
+
}, unknown>;
|
|
34
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
35
|
+
propertyId: string;
|
|
36
|
+
roomTypeId: string;
|
|
37
|
+
id: string;
|
|
38
|
+
code: string | null;
|
|
39
|
+
roomNumber: string | null;
|
|
40
|
+
floor: string | null;
|
|
41
|
+
wing: string | null;
|
|
42
|
+
status: "active" | "inactive" | "archived" | "out_of_order";
|
|
43
|
+
viewCode: string | null;
|
|
44
|
+
accessibilityCode: string | null;
|
|
45
|
+
genderRestriction: string | null;
|
|
46
|
+
notes: string | null;
|
|
47
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
48
|
+
}, Error, {
|
|
49
|
+
id: string;
|
|
50
|
+
input: UpdateRoomUnitInput;
|
|
51
|
+
}, unknown>;
|
|
52
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
53
|
+
success: boolean;
|
|
54
|
+
}, Error, string, unknown>;
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=use-room-unit-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-room-unit-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-room-unit-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 { roomUnitSingleResponse, successEnvelope } from "../schemas.js";
|
|
7
|
+
export function useRoomUnitMutation() {
|
|
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-units", roomUnitSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (data) => {
|
|
16
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomUnits() });
|
|
17
|
+
queryClient.setQueryData(hospitalityQueryKeys.roomUnit(data.id), { data });
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const update = useMutation({
|
|
21
|
+
mutationFn: async ({ id, input }) => {
|
|
22
|
+
const { data } = await fetchWithValidation(`/v1/hospitality/room-units/${id}`, roomUnitSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
onSuccess: (data) => {
|
|
26
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomUnits() });
|
|
27
|
+
queryClient.setQueryData(hospitalityQueryKeys.roomUnit(data.id), { data });
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const remove = useMutation({
|
|
31
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/hospitality/room-units/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
32
|
+
onSuccess: (_data, id) => {
|
|
33
|
+
void queryClient.invalidateQueries({ queryKey: hospitalityQueryKeys.roomUnits() });
|
|
34
|
+
queryClient.removeQueries({ queryKey: hospitalityQueryKeys.roomUnit(id) });
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return { create, update, remove };
|
|
38
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface UseRoomUnitOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useRoomUnit(id: string | null | undefined, options?: UseRoomUnitOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
propertyId: string;
|
|
6
|
+
roomTypeId: string;
|
|
7
|
+
id: string;
|
|
8
|
+
code: string | null;
|
|
9
|
+
roomNumber: string | null;
|
|
10
|
+
floor: string | null;
|
|
11
|
+
wing: string | null;
|
|
12
|
+
status: "active" | "inactive" | "archived" | "out_of_order";
|
|
13
|
+
viewCode: string | null;
|
|
14
|
+
accessibilityCode: string | null;
|
|
15
|
+
genderRestriction: string | null;
|
|
16
|
+
notes: string | null;
|
|
17
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
18
|
+
}, Error>;
|
|
19
|
+
//# sourceMappingURL=use-room-unit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-room-unit.d.ts","sourceRoot":"","sources":["../../src/hooks/use-room-unit.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 { getRoomUnitQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useRoomUnit(id, options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantHospitalityContext();
|
|
7
|
+
const { enabled = true } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getRoomUnitQueryOptions({ baseUrl, fetcher }, id ?? "__missing__"),
|
|
10
|
+
enabled: enabled && Boolean(id),
|
|
11
|
+
});
|
|
12
|
+
}
|