@voyantjs/availability-react 0.105.2 → 0.107.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +161 -1
- package/dist/admin/availability-index-host.d.ts +12 -0
- package/dist/admin/availability-index-host.d.ts.map +1 -0
- package/dist/admin/availability-index-host.js +125 -0
- package/dist/admin/availability-page-data.d.ts +9 -0
- package/dist/admin/availability-page-data.d.ts.map +1 -0
- package/dist/admin/availability-page-data.js +25 -0
- package/dist/admin/index.d.ts +69 -0
- package/dist/admin/index.d.ts.map +1 -0
- package/dist/admin/index.js +73 -0
- package/dist/admin/option-resource-templates-panel.d.ts +22 -0
- package/dist/admin/option-resource-templates-panel.d.ts.map +1 -0
- package/dist/admin/option-resource-templates-panel.js +251 -0
- package/dist/admin/rule-detail-host.d.ts +14 -0
- package/dist/admin/rule-detail-host.d.ts.map +1 -0
- package/dist/admin/rule-detail-host.js +27 -0
- package/dist/admin/slot-detail-host.d.ts +29 -0
- package/dist/admin/slot-detail-host.d.ts.map +1 -0
- package/dist/admin/slot-detail-host.js +110 -0
- package/dist/admin/start-time-detail-host.d.ts +15 -0
- package/dist/admin/start-time-detail-host.d.ts.map +1 -0
- package/dist/admin/start-time-detail-host.js +37 -0
- package/dist/components/availability-columns.d.ts +42 -0
- package/dist/components/availability-columns.d.ts.map +1 -0
- package/dist/components/availability-columns.js +182 -0
- package/dist/components/availability-dialogs.d.ts +236 -0
- package/dist/components/availability-dialogs.d.ts.map +1 -0
- package/dist/components/availability-dialogs.js +369 -0
- package/dist/components/availability-overview.d.ts +54 -0
- package/dist/components/availability-overview.d.ts.map +1 -0
- package/dist/components/availability-overview.js +50 -0
- package/dist/components/availability-page.d.ts +32 -0
- package/dist/components/availability-page.d.ts.map +1 -0
- package/dist/components/availability-page.js +128 -0
- package/dist/components/availability-rule-detail-page.d.ts +251 -0
- package/dist/components/availability-rule-detail-page.d.ts.map +1 -0
- package/dist/components/availability-rule-detail-page.js +74 -0
- package/dist/components/availability-section-header.d.ts +8 -0
- package/dist/components/availability-section-header.d.ts.map +1 -0
- package/dist/components/availability-section-header.js +7 -0
- package/dist/components/availability-skeletons.d.ts +6 -0
- package/dist/components/availability-skeletons.d.ts.map +1 -0
- package/dist/components/availability-skeletons.js +34 -0
- package/dist/components/availability-slot-detail-page.d.ts +974 -0
- package/dist/components/availability-slot-detail-page.d.ts.map +1 -0
- package/dist/components/availability-slot-detail-page.js +383 -0
- package/dist/components/availability-start-time-detail-page.d.ts +246 -0
- package/dist/components/availability-start-time-detail-page.d.ts.map +1 -0
- package/dist/components/availability-start-time-detail-page.js +83 -0
- package/dist/components/availability-tabs.d.ts +152 -0
- package/dist/components/availability-tabs.d.ts.map +1 -0
- package/dist/components/availability-tabs.js +192 -0
- package/dist/components/slot-status-tone.d.ts +15 -0
- package/dist/components/slot-status-tone.d.ts.map +1 -0
- package/dist/components/slot-status-tone.js +18 -0
- package/dist/form-resolver.d.ts +4 -0
- package/dist/form-resolver.d.ts.map +1 -0
- package/dist/form-resolver.js +40 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +3 -0
- package/dist/hooks/use-availability-batch-mutations.d.ts +193 -0
- package/dist/hooks/use-availability-batch-mutations.d.ts.map +1 -0
- package/dist/hooks/use-availability-batch-mutations.js +53 -0
- package/dist/hooks/use-availability-closeout-mutation.d.ts +34 -0
- package/dist/hooks/use-availability-closeout-mutation.d.ts.map +1 -0
- package/dist/hooks/use-availability-closeout-mutation.js +38 -0
- package/dist/hooks/use-availability-pickup-point-mutation.d.ts +35 -0
- package/dist/hooks/use-availability-pickup-point-mutation.d.ts.map +1 -0
- package/dist/hooks/use-availability-pickup-point-mutation.js +38 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/provider.d.ts +2003 -0
- package/dist/i18n/provider.d.ts.map +1 -0
- package/dist/i18n/provider.js +102 -0
- package/dist/schemas.d.ts +63 -2
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +22 -2
- package/dist/ui.d.ts +13 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +12 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +3 -0
- package/package.json +92 -9
- package/src/styles.css +11 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { type BatchUpdateResponse } from "../schemas.js";
|
|
2
|
+
export interface BatchUpdateVariables<TPatch> {
|
|
3
|
+
ids: string[];
|
|
4
|
+
patch: TPatch;
|
|
5
|
+
}
|
|
6
|
+
export interface BatchDeleteVariables {
|
|
7
|
+
ids: string[];
|
|
8
|
+
}
|
|
9
|
+
/** Batch mutations for `POST /v1/availability/rules/batch-update|batch-delete`. */
|
|
10
|
+
export declare function useAvailabilityRuleBatchMutation(): {
|
|
11
|
+
batchUpdate: import("@tanstack/react-query").UseMutationResult<BatchUpdateResponse<{
|
|
12
|
+
id: string;
|
|
13
|
+
productId: string;
|
|
14
|
+
optionId: string | null;
|
|
15
|
+
facilityId: string | null;
|
|
16
|
+
timezone: string;
|
|
17
|
+
recurrenceRule: string;
|
|
18
|
+
maxCapacity: number;
|
|
19
|
+
maxPickupCapacity: number | null;
|
|
20
|
+
minTotalPax: number | null;
|
|
21
|
+
cutoffMinutes: number | null;
|
|
22
|
+
earlyBookingLimitMinutes: number | null;
|
|
23
|
+
active: boolean;
|
|
24
|
+
productName?: string | null | undefined;
|
|
25
|
+
}>, Error, BatchUpdateVariables<{
|
|
26
|
+
productId?: string | undefined;
|
|
27
|
+
optionId?: string | null | undefined;
|
|
28
|
+
facilityId?: string | null | undefined;
|
|
29
|
+
timezone?: string | undefined;
|
|
30
|
+
recurrenceRule?: string | undefined;
|
|
31
|
+
maxCapacity?: number | undefined;
|
|
32
|
+
maxPickupCapacity?: number | null | undefined;
|
|
33
|
+
minTotalPax?: number | null | undefined;
|
|
34
|
+
cutoffMinutes?: number | null | undefined;
|
|
35
|
+
earlyBookingLimitMinutes?: number | null | undefined;
|
|
36
|
+
active?: boolean | undefined;
|
|
37
|
+
}>, unknown>;
|
|
38
|
+
batchDelete: import("@tanstack/react-query").UseMutationResult<{
|
|
39
|
+
deletedIds: string[];
|
|
40
|
+
total: number;
|
|
41
|
+
succeeded: number;
|
|
42
|
+
failed: {
|
|
43
|
+
id: string;
|
|
44
|
+
error: string;
|
|
45
|
+
}[];
|
|
46
|
+
}, Error, BatchDeleteVariables, unknown>;
|
|
47
|
+
};
|
|
48
|
+
/** Batch mutations for `POST /v1/availability/start-times/batch-update|batch-delete`. */
|
|
49
|
+
export declare function useAvailabilityStartTimeBatchMutation(): {
|
|
50
|
+
batchUpdate: import("@tanstack/react-query").UseMutationResult<BatchUpdateResponse<{
|
|
51
|
+
id: string;
|
|
52
|
+
productId: string;
|
|
53
|
+
optionId: string | null;
|
|
54
|
+
facilityId: string | null;
|
|
55
|
+
label: string | null;
|
|
56
|
+
startTimeLocal: string;
|
|
57
|
+
durationMinutes: number | null;
|
|
58
|
+
sortOrder: number;
|
|
59
|
+
active: boolean;
|
|
60
|
+
productName?: string | null | undefined;
|
|
61
|
+
}>, Error, BatchUpdateVariables<{
|
|
62
|
+
productId?: string | undefined;
|
|
63
|
+
optionId?: string | null | undefined;
|
|
64
|
+
facilityId?: string | null | undefined;
|
|
65
|
+
label?: string | null | undefined;
|
|
66
|
+
startTimeLocal?: string | undefined;
|
|
67
|
+
durationMinutes?: number | null | undefined;
|
|
68
|
+
sortOrder?: number | undefined;
|
|
69
|
+
active?: boolean | undefined;
|
|
70
|
+
}>, unknown>;
|
|
71
|
+
batchDelete: import("@tanstack/react-query").UseMutationResult<{
|
|
72
|
+
deletedIds: string[];
|
|
73
|
+
total: number;
|
|
74
|
+
succeeded: number;
|
|
75
|
+
failed: {
|
|
76
|
+
id: string;
|
|
77
|
+
error: string;
|
|
78
|
+
}[];
|
|
79
|
+
}, Error, BatchDeleteVariables, unknown>;
|
|
80
|
+
};
|
|
81
|
+
/** Batch mutations for `POST /v1/availability/slots/batch-update|batch-delete`. */
|
|
82
|
+
export declare function useAvailabilitySlotBatchMutation(): {
|
|
83
|
+
batchUpdate: import("@tanstack/react-query").UseMutationResult<BatchUpdateResponse<{
|
|
84
|
+
id: string;
|
|
85
|
+
productId: string;
|
|
86
|
+
itineraryId: string | null;
|
|
87
|
+
optionId: string | null;
|
|
88
|
+
facilityId: string | null;
|
|
89
|
+
availabilityRuleId: string | null;
|
|
90
|
+
startTimeId: string | null;
|
|
91
|
+
dateLocal: string;
|
|
92
|
+
startsAt: string;
|
|
93
|
+
endsAt: string | null;
|
|
94
|
+
timezone: string;
|
|
95
|
+
status: "cancelled" | "open" | "closed" | "sold_out";
|
|
96
|
+
unlimited: boolean;
|
|
97
|
+
initialPax: number | null;
|
|
98
|
+
remainingPax: number | null;
|
|
99
|
+
nights: number | null;
|
|
100
|
+
days: number | null;
|
|
101
|
+
notes: string | null;
|
|
102
|
+
productName?: string | null | undefined;
|
|
103
|
+
endDateLocal?: string | null | undefined;
|
|
104
|
+
}>, Error, BatchUpdateVariables<{
|
|
105
|
+
productId?: string | undefined;
|
|
106
|
+
itineraryId?: string | null | undefined;
|
|
107
|
+
optionId?: string | null | undefined;
|
|
108
|
+
facilityId?: string | null | undefined;
|
|
109
|
+
availabilityRuleId?: string | null | undefined;
|
|
110
|
+
startTimeId?: string | null | undefined;
|
|
111
|
+
dateLocal?: string | undefined;
|
|
112
|
+
startsAt?: string | undefined;
|
|
113
|
+
endsAt?: string | null | undefined;
|
|
114
|
+
timezone?: string | undefined;
|
|
115
|
+
status?: "cancelled" | "open" | "closed" | "sold_out" | undefined;
|
|
116
|
+
unlimited?: boolean | undefined;
|
|
117
|
+
initialPax?: number | null | undefined;
|
|
118
|
+
remainingPax?: number | null | undefined;
|
|
119
|
+
initialPickups?: number | null | undefined;
|
|
120
|
+
remainingPickups?: number | null | undefined;
|
|
121
|
+
remainingResources?: number | null | undefined;
|
|
122
|
+
pastCutoff?: boolean | undefined;
|
|
123
|
+
tooEarly?: boolean | undefined;
|
|
124
|
+
nights?: number | null | undefined;
|
|
125
|
+
days?: number | null | undefined;
|
|
126
|
+
notes?: string | null | undefined;
|
|
127
|
+
}>, unknown>;
|
|
128
|
+
batchDelete: import("@tanstack/react-query").UseMutationResult<{
|
|
129
|
+
deletedIds: string[];
|
|
130
|
+
total: number;
|
|
131
|
+
succeeded: number;
|
|
132
|
+
failed: {
|
|
133
|
+
id: string;
|
|
134
|
+
error: string;
|
|
135
|
+
}[];
|
|
136
|
+
}, Error, BatchDeleteVariables, unknown>;
|
|
137
|
+
};
|
|
138
|
+
/** Batch mutations for `POST /v1/availability/closeouts/batch-update|batch-delete`. */
|
|
139
|
+
export declare function useAvailabilityCloseoutBatchMutation(): {
|
|
140
|
+
batchUpdate: import("@tanstack/react-query").UseMutationResult<BatchUpdateResponse<{
|
|
141
|
+
id: string;
|
|
142
|
+
productId: string;
|
|
143
|
+
slotId: string | null;
|
|
144
|
+
dateLocal: string;
|
|
145
|
+
reason: string | null;
|
|
146
|
+
createdBy: string | null;
|
|
147
|
+
productName?: string | null | undefined;
|
|
148
|
+
}>, Error, BatchUpdateVariables<{
|
|
149
|
+
productId?: string | undefined;
|
|
150
|
+
slotId?: string | null | undefined;
|
|
151
|
+
dateLocal?: string | undefined;
|
|
152
|
+
reason?: string | null | undefined;
|
|
153
|
+
createdBy?: string | null | undefined;
|
|
154
|
+
}>, unknown>;
|
|
155
|
+
batchDelete: import("@tanstack/react-query").UseMutationResult<{
|
|
156
|
+
deletedIds: string[];
|
|
157
|
+
total: number;
|
|
158
|
+
succeeded: number;
|
|
159
|
+
failed: {
|
|
160
|
+
id: string;
|
|
161
|
+
error: string;
|
|
162
|
+
}[];
|
|
163
|
+
}, Error, BatchDeleteVariables, unknown>;
|
|
164
|
+
};
|
|
165
|
+
/** Batch mutations for `POST /v1/availability/pickup-points/batch-update|batch-delete`. */
|
|
166
|
+
export declare function useAvailabilityPickupPointBatchMutation(): {
|
|
167
|
+
batchUpdate: import("@tanstack/react-query").UseMutationResult<BatchUpdateResponse<{
|
|
168
|
+
id: string;
|
|
169
|
+
productId: string;
|
|
170
|
+
name: string;
|
|
171
|
+
description: string | null;
|
|
172
|
+
locationText: string | null;
|
|
173
|
+
active: boolean;
|
|
174
|
+
productName?: string | null | undefined;
|
|
175
|
+
}>, Error, BatchUpdateVariables<{
|
|
176
|
+
productId?: string | undefined;
|
|
177
|
+
facilityId?: string | null | undefined;
|
|
178
|
+
name?: string | undefined;
|
|
179
|
+
description?: string | null | undefined;
|
|
180
|
+
locationText?: string | null | undefined;
|
|
181
|
+
active?: boolean | undefined;
|
|
182
|
+
}>, unknown>;
|
|
183
|
+
batchDelete: import("@tanstack/react-query").UseMutationResult<{
|
|
184
|
+
deletedIds: string[];
|
|
185
|
+
total: number;
|
|
186
|
+
succeeded: number;
|
|
187
|
+
failed: {
|
|
188
|
+
id: string;
|
|
189
|
+
error: string;
|
|
190
|
+
}[];
|
|
191
|
+
}, Error, BatchDeleteVariables, unknown>;
|
|
192
|
+
};
|
|
193
|
+
//# sourceMappingURL=use-availability-batch-mutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-availability-batch-mutations.d.ts","sourceRoot":"","sources":["../../src/hooks/use-availability-batch-mutations.ts"],"names":[],"mappings":"AAQA,OAAO,EAOL,KAAK,mBAAmB,EAQzB,MAAM,eAAe,CAAA;AAEtB,MAAM,WAAW,oBAAoB,CAAC,MAAM;IAC1C,GAAG,EAAE,MAAM,EAAE,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,EAAE,CAAA;CACd;AAoDD,mFAAmF;AACnF,wBAAgB,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK/C;AAED,yFAAyF;AACzF,wBAAgB,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EASpD;AAED,mFAAmF;AACnF,wBAAgB,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK/C;AAED,uFAAuF;AACvF,wBAAgB,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;EAKnD;AAED,2FAA2F;AAC3F,wBAAgB,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;EAStD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantAvailabilityContext } from "../provider.js";
|
|
5
|
+
import { availabilityQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { availabilityCloseoutRecordSchema, availabilityPickupPointRecordSchema, availabilityRuleRecordSchema, availabilitySlotRecordSchema, availabilityStartTimeRecordSchema, batchDeleteEnvelope, batchUpdateEnvelope, } from "../schemas.js";
|
|
7
|
+
/**
|
|
8
|
+
* Shared plumbing for the `POST <entity>/batch-update` + `/batch-delete`
|
|
9
|
+
* endpoint pairs the availability module exposes for every list entity.
|
|
10
|
+
* Each mutation sends the whole id selection in one request and resolves
|
|
11
|
+
* the server's success/partial-failure envelope (`{ total, succeeded,
|
|
12
|
+
* failed }` plus the updated rows on update / `deletedIds` on delete) —
|
|
13
|
+
* callers branch their toasts on `failed.length`. Invalidation is scoped
|
|
14
|
+
* to the entity's query-key root, mirroring the single-record mutation
|
|
15
|
+
* hooks.
|
|
16
|
+
*/
|
|
17
|
+
function useAvailabilityBatchMutationPair(basePath, recordSchema, queryKey) {
|
|
18
|
+
const { baseUrl, fetcher } = useVoyantAvailabilityContext();
|
|
19
|
+
const queryClient = useQueryClient();
|
|
20
|
+
const batchUpdate = useMutation({
|
|
21
|
+
mutationFn: async ({ ids, patch, }) => fetchWithValidation(`${basePath}/batch-update`, batchUpdateEnvelope(recordSchema), { baseUrl, fetcher }, { method: "POST", body: JSON.stringify({ ids, patch }) }),
|
|
22
|
+
onSuccess: async () => {
|
|
23
|
+
await queryClient.invalidateQueries({ queryKey: queryKey() });
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const batchDelete = useMutation({
|
|
27
|
+
mutationFn: async ({ ids }) => fetchWithValidation(`${basePath}/batch-delete`, batchDeleteEnvelope, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify({ ids }) }),
|
|
28
|
+
onSuccess: async () => {
|
|
29
|
+
await queryClient.invalidateQueries({ queryKey: queryKey() });
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
return { batchUpdate, batchDelete };
|
|
33
|
+
}
|
|
34
|
+
/** Batch mutations for `POST /v1/availability/rules/batch-update|batch-delete`. */
|
|
35
|
+
export function useAvailabilityRuleBatchMutation() {
|
|
36
|
+
return useAvailabilityBatchMutationPair("/v1/availability/rules", availabilityRuleRecordSchema, availabilityQueryKeys.rules);
|
|
37
|
+
}
|
|
38
|
+
/** Batch mutations for `POST /v1/availability/start-times/batch-update|batch-delete`. */
|
|
39
|
+
export function useAvailabilityStartTimeBatchMutation() {
|
|
40
|
+
return useAvailabilityBatchMutationPair("/v1/availability/start-times", availabilityStartTimeRecordSchema, availabilityQueryKeys.startTimes);
|
|
41
|
+
}
|
|
42
|
+
/** Batch mutations for `POST /v1/availability/slots/batch-update|batch-delete`. */
|
|
43
|
+
export function useAvailabilitySlotBatchMutation() {
|
|
44
|
+
return useAvailabilityBatchMutationPair("/v1/availability/slots", availabilitySlotRecordSchema, availabilityQueryKeys.slots);
|
|
45
|
+
}
|
|
46
|
+
/** Batch mutations for `POST /v1/availability/closeouts/batch-update|batch-delete`. */
|
|
47
|
+
export function useAvailabilityCloseoutBatchMutation() {
|
|
48
|
+
return useAvailabilityBatchMutationPair("/v1/availability/closeouts", availabilityCloseoutRecordSchema, availabilityQueryKeys.closeouts);
|
|
49
|
+
}
|
|
50
|
+
/** Batch mutations for `POST /v1/availability/pickup-points/batch-update|batch-delete`. */
|
|
51
|
+
export function useAvailabilityPickupPointBatchMutation() {
|
|
52
|
+
return useAvailabilityBatchMutationPair("/v1/availability/pickup-points", availabilityPickupPointRecordSchema, availabilityQueryKeys.pickupPoints);
|
|
53
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type UpdateAvailabilityCloseoutInput } from "../schemas.js";
|
|
2
|
+
export declare function useAvailabilityCloseoutMutation(): {
|
|
3
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
4
|
+
id: string;
|
|
5
|
+
productId: string;
|
|
6
|
+
slotId: string | null;
|
|
7
|
+
dateLocal: string;
|
|
8
|
+
reason: string | null;
|
|
9
|
+
createdBy: string | null;
|
|
10
|
+
productName?: string | null | undefined;
|
|
11
|
+
}, Error, {
|
|
12
|
+
productId: string;
|
|
13
|
+
dateLocal: string;
|
|
14
|
+
slotId?: string | null | undefined;
|
|
15
|
+
reason?: string | null | undefined;
|
|
16
|
+
createdBy?: string | null | undefined;
|
|
17
|
+
}, unknown>;
|
|
18
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
19
|
+
id: string;
|
|
20
|
+
productId: string;
|
|
21
|
+
slotId: string | null;
|
|
22
|
+
dateLocal: string;
|
|
23
|
+
reason: string | null;
|
|
24
|
+
createdBy: string | null;
|
|
25
|
+
productName?: string | null | undefined;
|
|
26
|
+
}, Error, {
|
|
27
|
+
id: string;
|
|
28
|
+
input: UpdateAvailabilityCloseoutInput;
|
|
29
|
+
}, unknown>;
|
|
30
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
31
|
+
success: boolean;
|
|
32
|
+
}, Error, string, unknown>;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=use-availability-closeout-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-availability-closeout-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-availability-closeout-mutation.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,+BAA+B,EACrC,MAAM,eAAe,CAAA;AAEtB,wBAAgB,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;YAuBH,MAAM;eAAS,+BAA+B;;;;;EA4BzF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantAvailabilityContext } from "../provider.js";
|
|
5
|
+
import { availabilityQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { availabilityCloseoutSingleResponse, successEnvelope, } from "../schemas.js";
|
|
7
|
+
export function useAvailabilityCloseoutMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantAvailabilityContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async (input) => {
|
|
12
|
+
const { data } = await fetchWithValidation("/v1/availability/closeouts", availabilityCloseoutSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: async (data) => {
|
|
16
|
+
await queryClient.invalidateQueries({ queryKey: availabilityQueryKeys.closeouts() });
|
|
17
|
+
await queryClient.invalidateQueries({
|
|
18
|
+
queryKey: availabilityQueryKeys.closeoutsList({ productId: data.productId }),
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
const update = useMutation({
|
|
23
|
+
mutationFn: async ({ id, input }) => {
|
|
24
|
+
const { data } = await fetchWithValidation(`/v1/availability/closeouts/${id}`, availabilityCloseoutSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
25
|
+
return data;
|
|
26
|
+
},
|
|
27
|
+
onSuccess: async () => {
|
|
28
|
+
await queryClient.invalidateQueries({ queryKey: availabilityQueryKeys.closeouts() });
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const remove = useMutation({
|
|
32
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/availability/closeouts/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
33
|
+
onSuccess: async () => {
|
|
34
|
+
await queryClient.invalidateQueries({ queryKey: availabilityQueryKeys.closeouts() });
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return { create, update, remove };
|
|
38
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type UpdateAvailabilityPickupPointInput } from "../schemas.js";
|
|
2
|
+
export declare function useAvailabilityPickupPointMutation(): {
|
|
3
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
4
|
+
id: string;
|
|
5
|
+
productId: string;
|
|
6
|
+
name: string;
|
|
7
|
+
description: string | null;
|
|
8
|
+
locationText: string | null;
|
|
9
|
+
active: boolean;
|
|
10
|
+
productName?: string | null | undefined;
|
|
11
|
+
}, Error, {
|
|
12
|
+
productId: string;
|
|
13
|
+
name: string;
|
|
14
|
+
facilityId?: string | null | undefined;
|
|
15
|
+
description?: string | null | undefined;
|
|
16
|
+
locationText?: string | null | undefined;
|
|
17
|
+
active?: boolean | undefined;
|
|
18
|
+
}, unknown>;
|
|
19
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
20
|
+
id: string;
|
|
21
|
+
productId: string;
|
|
22
|
+
name: string;
|
|
23
|
+
description: string | null;
|
|
24
|
+
locationText: string | null;
|
|
25
|
+
active: boolean;
|
|
26
|
+
productName?: string | null | undefined;
|
|
27
|
+
}, Error, {
|
|
28
|
+
id: string;
|
|
29
|
+
input: UpdateAvailabilityPickupPointInput;
|
|
30
|
+
}, unknown>;
|
|
31
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
32
|
+
success: boolean;
|
|
33
|
+
}, Error, string, unknown>;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=use-availability-pickup-point-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-availability-pickup-point-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-availability-pickup-point-mutation.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,KAAK,kCAAkC,EACxC,MAAM,eAAe,CAAA;AAEtB,wBAAgB,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;YA2BxC,MAAM;eACH,kCAAkC;;;;;EA6B9C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantAvailabilityContext } from "../provider.js";
|
|
5
|
+
import { availabilityQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { availabilityPickupPointSingleResponse, successEnvelope, } from "../schemas.js";
|
|
7
|
+
export function useAvailabilityPickupPointMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantAvailabilityContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async (input) => {
|
|
12
|
+
const { data } = await fetchWithValidation("/v1/availability/pickup-points", availabilityPickupPointSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: async (data) => {
|
|
16
|
+
await queryClient.invalidateQueries({ queryKey: availabilityQueryKeys.pickupPoints() });
|
|
17
|
+
await queryClient.invalidateQueries({
|
|
18
|
+
queryKey: availabilityQueryKeys.pickupPointsList({ productId: data.productId }),
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
const update = useMutation({
|
|
23
|
+
mutationFn: async ({ id, input, }) => {
|
|
24
|
+
const { data } = await fetchWithValidation(`/v1/availability/pickup-points/${id}`, availabilityPickupPointSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
25
|
+
return data;
|
|
26
|
+
},
|
|
27
|
+
onSuccess: async () => {
|
|
28
|
+
await queryClient.invalidateQueries({ queryKey: availabilityQueryKeys.pickupPoints() });
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
const remove = useMutation({
|
|
32
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/availability/pickup-points/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
|
|
33
|
+
onSuccess: async () => {
|
|
34
|
+
await queryClient.invalidateQueries({ queryKey: availabilityQueryKeys.pickupPoints() });
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return { create, update, remove };
|
|
38
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { type AvailabilityUiMessageOverrides, type AvailabilityUiMessages, AvailabilityUiMessagesProvider, availabilityUiEn, availabilityUiMessageDefinitions, availabilityUiRo, getAvailabilityUiI18n, resolveAvailabilityUiMessages, useAvailabilityUiI18n, useAvailabilityUiI18nOrDefault, useAvailabilityUiMessages, useAvailabilityUiMessagesOrDefault, } from "./provider.js";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,8BAA8B,EAC9B,gBAAgB,EAChB,gCAAgC,EAChC,gBAAgB,EAChB,qBAAqB,EACrB,6BAA6B,EAC7B,qBAAqB,EACrB,8BAA8B,EAC9B,yBAAyB,EACzB,kCAAkC,GACnC,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AvailabilityUiMessagesProvider, availabilityUiEn, availabilityUiMessageDefinitions, availabilityUiRo, getAvailabilityUiI18n, resolveAvailabilityUiMessages, useAvailabilityUiI18n, useAvailabilityUiI18nOrDefault, useAvailabilityUiMessages, useAvailabilityUiMessagesOrDefault, } from "./provider.js";
|