@timardex/cluemart-shared 1.0.15 → 1.0.17
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/auth-CAeHx-BM.d.mts +84 -0
- package/dist/auth-gmfsaSPo.d.ts +84 -0
- package/dist/chat-BUVCf9Tu.d.mts +27 -0
- package/dist/chat-BUVCf9Tu.d.ts +27 -0
- package/dist/chunk-K5NK2CK5.mjs +133 -0
- package/dist/chunk-K5NK2CK5.mjs.map +1 -0
- package/dist/chunk-L2H5WFGC.mjs +100 -0
- package/dist/chunk-L2H5WFGC.mjs.map +1 -0
- package/dist/enums/index.cjs +134 -0
- package/dist/enums/index.cjs.map +1 -0
- package/dist/enums/index.d.mts +75 -0
- package/dist/enums/index.d.ts +75 -0
- package/dist/enums/index.mjs +27 -0
- package/dist/enums/index.mjs.map +1 -0
- package/dist/formFields/index.cjs +890 -0
- package/dist/formFields/index.cjs.map +1 -0
- package/dist/formFields/index.d.mts +61 -0
- package/dist/formFields/index.d.ts +61 -0
- package/dist/formFields/index.mjs +756 -0
- package/dist/formFields/index.mjs.map +1 -0
- package/dist/global-B6OE9jjE.d.mts +349 -0
- package/dist/global-Diphaotm.d.ts +349 -0
- package/dist/graphql/index.cjs +1712 -0
- package/dist/graphql/index.cjs.map +1 -0
- package/dist/graphql/index.d.mts +315 -0
- package/dist/graphql/index.d.ts +315 -0
- package/dist/graphql/index.mjs +1633 -0
- package/dist/graphql/index.mjs.map +1 -0
- package/dist/hooks/index.cjs +1167 -0
- package/dist/hooks/index.cjs.map +1 -0
- package/dist/hooks/index.d.mts +87 -0
- package/dist/hooks/index.d.ts +87 -0
- package/dist/hooks/index.mjs +1045 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.cjs +312 -193
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +48 -297
- package/dist/index.d.ts +48 -297
- package/dist/index.mjs +305 -171
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.cjs +19 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.mts +12 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/index.mjs.map +1 -0
- package/dist/utils/index.cjs +215 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.mts +66 -0
- package/dist/utils/index.d.ts +66 -0
- package/dist/utils/index.mjs +38 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +37 -4
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,1167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/hooks/index.ts
|
|
31
|
+
var hooks_exports = {};
|
|
32
|
+
__export(hooks_exports, {
|
|
33
|
+
defaultMarketFormValues: () => defaultMarketFormValues,
|
|
34
|
+
defaultMarketInfoFormValues: () => defaultMarketInfoFormValues,
|
|
35
|
+
defaultStallholderApplyFormValues: () => defaultStallholderApplyFormValues,
|
|
36
|
+
defaultStallholderFormValues: () => defaultStallholderFormValues,
|
|
37
|
+
globalDefaultValues: () => globalDefaultValues,
|
|
38
|
+
useLocationSearch: () => useLocationSearch,
|
|
39
|
+
useLoginForm: () => useLoginForm,
|
|
40
|
+
useMarketForm: () => useMarketForm,
|
|
41
|
+
useMarketInfoForm: () => useMarketInfoForm,
|
|
42
|
+
useRegisterForm: () => useRegisterForm,
|
|
43
|
+
useRequestPasswordResetForm: () => useRequestPasswordResetForm,
|
|
44
|
+
useResetPasswordForm: () => useResetPasswordForm,
|
|
45
|
+
useStallholderApplyForm: () => useStallholderApplyForm,
|
|
46
|
+
useStallholderForm: () => useStallholderForm,
|
|
47
|
+
useUserForm: () => useUserForm,
|
|
48
|
+
useValidateTokenForm: () => useValidateTokenForm
|
|
49
|
+
});
|
|
50
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
51
|
+
|
|
52
|
+
// src/hooks/useLocationSearch.ts
|
|
53
|
+
var handleApiError = (error, message) => {
|
|
54
|
+
console.error(message, error);
|
|
55
|
+
};
|
|
56
|
+
var useLocationSearch = (googleApi) => {
|
|
57
|
+
const getPredictions = async (text) => {
|
|
58
|
+
try {
|
|
59
|
+
const response = await fetch(
|
|
60
|
+
`https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${text}&components=country:nz&key=${googleApi}`
|
|
61
|
+
);
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
64
|
+
}
|
|
65
|
+
const data = await response.json();
|
|
66
|
+
return data.predictions;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error("Error fetching predictions:", error);
|
|
69
|
+
handleApiError(error, "Failed to fetch address predictions.");
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const getPlaceDetails = async (placeId) => {
|
|
73
|
+
try {
|
|
74
|
+
const response = await fetch(
|
|
75
|
+
`https://maps.googleapis.com/maps/api/place/details/json?place_id=${placeId}&key=${googleApi}`
|
|
76
|
+
);
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
79
|
+
}
|
|
80
|
+
const data = await response.json();
|
|
81
|
+
const { result } = data;
|
|
82
|
+
const { lat, lng } = result.geometry.location;
|
|
83
|
+
const { address_components, formatted_address } = result;
|
|
84
|
+
const address = address_components.reduce((acc, item) => {
|
|
85
|
+
if (item.types.includes("street_number")) {
|
|
86
|
+
return { ...acc, streetNumber: item.long_name };
|
|
87
|
+
}
|
|
88
|
+
if (item.types.includes("route")) {
|
|
89
|
+
return { ...acc, streetName: item.long_name };
|
|
90
|
+
}
|
|
91
|
+
if (item.types.includes("locality")) {
|
|
92
|
+
return { ...acc, city: item.long_name };
|
|
93
|
+
}
|
|
94
|
+
if (item.types.includes("administrative_area_level_1")) {
|
|
95
|
+
return { ...acc, region: item.long_name };
|
|
96
|
+
}
|
|
97
|
+
if (item.types.includes("country")) {
|
|
98
|
+
return { ...acc, country: item.long_name };
|
|
99
|
+
}
|
|
100
|
+
return acc;
|
|
101
|
+
}, {});
|
|
102
|
+
const newLocation = {
|
|
103
|
+
city: address.city.toLowerCase(),
|
|
104
|
+
coordinates: [lng, lat],
|
|
105
|
+
// [longitude, latitude]
|
|
106
|
+
country: address.country,
|
|
107
|
+
fullAddress: formatted_address,
|
|
108
|
+
latitude: lat,
|
|
109
|
+
longitude: lng,
|
|
110
|
+
region: address.region.replace(/ Region$/, ""),
|
|
111
|
+
// Remove " Region" suffix
|
|
112
|
+
type: "Point"
|
|
113
|
+
// Mongoose GeoJSON type
|
|
114
|
+
};
|
|
115
|
+
return newLocation;
|
|
116
|
+
} catch (error) {
|
|
117
|
+
handleApiError(error, "Failed to fetch place details.");
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
return {
|
|
121
|
+
getPlaceDetails,
|
|
122
|
+
getPredictions
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// src/hooks/stallholder/useStallholderForm.ts
|
|
127
|
+
var import_yup = require("@hookform/resolvers/yup");
|
|
128
|
+
var React = __toESM(require("react"));
|
|
129
|
+
var import_react_hook_form = require("react-hook-form");
|
|
130
|
+
|
|
131
|
+
// src/yupSchema/global.ts
|
|
132
|
+
var import_dayjs2 = __toESM(require("dayjs"));
|
|
133
|
+
var import_customParseFormat2 = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
134
|
+
var import_isSameOrAfter2 = __toESM(require("dayjs/plugin/isSameOrAfter"));
|
|
135
|
+
var yup = __toESM(require("yup"));
|
|
136
|
+
|
|
137
|
+
// src/utils/index.ts
|
|
138
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
139
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
140
|
+
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
|
|
141
|
+
var import_timezone = __toESM(require("dayjs/plugin/timezone"));
|
|
142
|
+
var import_utc = __toESM(require("dayjs/plugin/utc"));
|
|
143
|
+
|
|
144
|
+
// src/enums/index.ts
|
|
145
|
+
var EnumInviteStatus = /* @__PURE__ */ ((EnumInviteStatus2) => {
|
|
146
|
+
EnumInviteStatus2["ACCEPTED"] = "Accepted";
|
|
147
|
+
EnumInviteStatus2["COMPLETED"] = "Completed";
|
|
148
|
+
EnumInviteStatus2["EXPIRED"] = "Expired";
|
|
149
|
+
EnumInviteStatus2["NO_STATUS"] = "No_Status";
|
|
150
|
+
EnumInviteStatus2["PENDING"] = "Pending";
|
|
151
|
+
EnumInviteStatus2["REJECTED"] = "Rejected";
|
|
152
|
+
EnumInviteStatus2["WAITING"] = "Waiting";
|
|
153
|
+
return EnumInviteStatus2;
|
|
154
|
+
})(EnumInviteStatus || {});
|
|
155
|
+
var EnumRejectionPolicy = /* @__PURE__ */ ((EnumRejectionPolicy2) => {
|
|
156
|
+
EnumRejectionPolicy2["SINGLE_DATE_ALLOWED"] = "single_date_allowed";
|
|
157
|
+
EnumRejectionPolicy2["MULTI_DATE_ALLOWED"] = "multi_date_allowed";
|
|
158
|
+
return EnumRejectionPolicy2;
|
|
159
|
+
})(EnumRejectionPolicy || {});
|
|
160
|
+
var EnumPaymentMethod = /* @__PURE__ */ ((EnumPaymentMethod3) => {
|
|
161
|
+
EnumPaymentMethod3["CASH"] = "cash";
|
|
162
|
+
EnumPaymentMethod3["EFTPOS"] = "eftpos";
|
|
163
|
+
EnumPaymentMethod3["BANK_TRANSFER"] = "bank_transfer";
|
|
164
|
+
EnumPaymentMethod3["PAYPAL"] = "paypal";
|
|
165
|
+
EnumPaymentMethod3["STRIPE"] = "stripe";
|
|
166
|
+
return EnumPaymentMethod3;
|
|
167
|
+
})(EnumPaymentMethod || {});
|
|
168
|
+
var EnumRegions = /* @__PURE__ */ ((EnumRegions3) => {
|
|
169
|
+
EnumRegions3["Auckland"] = "Auckland";
|
|
170
|
+
EnumRegions3["BayOfPlenty"] = "Bay of Plenty";
|
|
171
|
+
EnumRegions3["Canterbury"] = "Canterbury";
|
|
172
|
+
EnumRegions3["Gisborne"] = "Gisborne";
|
|
173
|
+
EnumRegions3["HawkesBay"] = "Hawke's Bay";
|
|
174
|
+
EnumRegions3["ManawatuWanganui"] = "Manawatu-Wanganui";
|
|
175
|
+
EnumRegions3["Marlborough"] = "Marlborough";
|
|
176
|
+
EnumRegions3["Nelson"] = "Nelson";
|
|
177
|
+
EnumRegions3["Northland"] = "Northland";
|
|
178
|
+
EnumRegions3["Otago"] = "Otago";
|
|
179
|
+
EnumRegions3["Southland"] = "Southland";
|
|
180
|
+
EnumRegions3["Taranaki"] = "Taranaki";
|
|
181
|
+
EnumRegions3["Waikato"] = "Waikato";
|
|
182
|
+
EnumRegions3["Wellington"] = "Wellington";
|
|
183
|
+
return EnumRegions3;
|
|
184
|
+
})(EnumRegions || {});
|
|
185
|
+
var EnumUserRole = /* @__PURE__ */ ((EnumUserRole2) => {
|
|
186
|
+
EnumUserRole2["ADMIN"] = "admin";
|
|
187
|
+
EnumUserRole2["CUSTOMER"] = "customer";
|
|
188
|
+
return EnumUserRole2;
|
|
189
|
+
})(EnumUserRole || {});
|
|
190
|
+
|
|
191
|
+
// src/utils/index.ts
|
|
192
|
+
var dateFormat = "DD-MM-YYYY";
|
|
193
|
+
var timeFormat = "HH:mm";
|
|
194
|
+
(0, import_dayjs.extend)(import_customParseFormat.default);
|
|
195
|
+
(0, import_dayjs.extend)(import_utc.default);
|
|
196
|
+
(0, import_dayjs.extend)(import_timezone.default);
|
|
197
|
+
(0, import_dayjs.extend)(import_isSameOrAfter.default);
|
|
198
|
+
var mapArrayToOptions = (items) => items.map((item) => ({
|
|
199
|
+
label: item.replace(/_/g, " "),
|
|
200
|
+
value: item.replace(/\s+/g, "_").toLowerCase()
|
|
201
|
+
}));
|
|
202
|
+
var statusOptions = [
|
|
203
|
+
...Object.values(EnumInviteStatus).map((status) => ({
|
|
204
|
+
label: status,
|
|
205
|
+
value: status
|
|
206
|
+
})).sort((a, b) => a.label.localeCompare(b.label))
|
|
207
|
+
// Sort the options alphabetically
|
|
208
|
+
];
|
|
209
|
+
var availableRegionTypes = Object.values(EnumRegions);
|
|
210
|
+
var availableRegionOptions = mapArrayToOptions(availableRegionTypes);
|
|
211
|
+
var paymentMethodOptions = mapArrayToOptions(
|
|
212
|
+
Object.values(EnumPaymentMethod)
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
// src/yupSchema/global.ts
|
|
216
|
+
var noLeadingZeros = (fieldName, options = {}) => {
|
|
217
|
+
return function(value, context) {
|
|
218
|
+
const original = context.originalValue?.toString() ?? "";
|
|
219
|
+
const regex = options.allowDecimal ? /^0\d+(\.\d+)?$/ : /^0\d+$/;
|
|
220
|
+
if (regex.test(original)) {
|
|
221
|
+
return context.createError({
|
|
222
|
+
message: `${fieldName} must not have leading zeros`
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
return true;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
(0, import_dayjs2.extend)(import_isSameOrAfter2.default);
|
|
229
|
+
(0, import_dayjs2.extend)(import_customParseFormat2.default);
|
|
230
|
+
var now = (0, import_dayjs2.default)();
|
|
231
|
+
var endDateNotInPastTest = yup.string().test("not-in-past", "End date cannot be in the past", (value) => {
|
|
232
|
+
return value ? (0, import_dayjs2.default)(value, dateFormat, true).isSameOrAfter(now, "day") : false;
|
|
233
|
+
});
|
|
234
|
+
var startDateNotInPastTest = yup.string().test("not-in-past", "Start date cannot be in the past", (value) => {
|
|
235
|
+
return value ? (0, import_dayjs2.default)(value, dateFormat, true).isSameOrAfter(now, "day") : false;
|
|
236
|
+
});
|
|
237
|
+
var endDateAfterStartDateTest = yup.string().test(
|
|
238
|
+
"end-after-start",
|
|
239
|
+
"End date cannot be before start date",
|
|
240
|
+
function(value) {
|
|
241
|
+
const { startDate } = this.parent;
|
|
242
|
+
if (!startDate || !value) return false;
|
|
243
|
+
return (0, import_dayjs2.default)(value, dateFormat, true).isSameOrAfter(
|
|
244
|
+
(0, import_dayjs2.default)(startDate, dateFormat, true),
|
|
245
|
+
"day"
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
);
|
|
249
|
+
var endTimeMustBeAfterStartTimeTest = yup.string().test(
|
|
250
|
+
"valid-end-time",
|
|
251
|
+
"End time must be after start time",
|
|
252
|
+
function(value) {
|
|
253
|
+
const { startDate, endDate, startTime } = this.parent;
|
|
254
|
+
if (!startDate || !endDate || !startTime || !value) return false;
|
|
255
|
+
const startDateTime = (0, import_dayjs2.default)(
|
|
256
|
+
`${startDate} ${startTime}`,
|
|
257
|
+
`${dateFormat} ${timeFormat}`,
|
|
258
|
+
true
|
|
259
|
+
);
|
|
260
|
+
const endDateTime = (0, import_dayjs2.default)(
|
|
261
|
+
`${endDate} ${value}`,
|
|
262
|
+
`${dateFormat} ${timeFormat}`,
|
|
263
|
+
true
|
|
264
|
+
);
|
|
265
|
+
return endDateTime.isAfter(startDateTime);
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
var startTimeCannotBeInPastTest = yup.string().test(
|
|
269
|
+
"valid-start-time",
|
|
270
|
+
"Start time cannot be in the past",
|
|
271
|
+
function(value) {
|
|
272
|
+
const { startDate } = this.parent;
|
|
273
|
+
if (!startDate || !value) return false;
|
|
274
|
+
const startDateTime = (0, import_dayjs2.default)(
|
|
275
|
+
`${startDate} ${value}`,
|
|
276
|
+
`${dateFormat} ${timeFormat}`,
|
|
277
|
+
true
|
|
278
|
+
);
|
|
279
|
+
return startDateTime.isSameOrAfter(now);
|
|
280
|
+
}
|
|
281
|
+
);
|
|
282
|
+
var dateTimeSchema = yup.object().shape({
|
|
283
|
+
endDate: yup.string().concat(endDateNotInPastTest).concat(endDateAfterStartDateTest).required("End date is required"),
|
|
284
|
+
endTime: yup.string().concat(endTimeMustBeAfterStartTimeTest).required("End time is required"),
|
|
285
|
+
startDate: yup.string().concat(startDateNotInPastTest).required("Start date is required"),
|
|
286
|
+
startTime: yup.string().concat(startTimeCannotBeInPastTest).required("Start time is required")
|
|
287
|
+
});
|
|
288
|
+
var dateTimeWithPriceSchema = dateTimeSchema.shape({
|
|
289
|
+
marketPrice: yup.number().typeError("Market price must be a number").min(0.1, "Market price must be at least 0.1").required("Market price is required").test(
|
|
290
|
+
"no-leading-zeros",
|
|
291
|
+
"",
|
|
292
|
+
noLeadingZeros("Market price", { allowDecimal: true })
|
|
293
|
+
)
|
|
294
|
+
});
|
|
295
|
+
var locationSchema = yup.object().shape({
|
|
296
|
+
city: yup.string().required("City is required"),
|
|
297
|
+
coordinates: yup.array().of(yup.number().required("Coordinates must be numbers")).length(
|
|
298
|
+
2,
|
|
299
|
+
"Coordinates must contain exactly two numbers (longitude, latitude)"
|
|
300
|
+
).required("Coordinates are required"),
|
|
301
|
+
country: yup.string().required("Country is required"),
|
|
302
|
+
fullAddress: yup.string().required("Address is required"),
|
|
303
|
+
latitude: yup.number().required("Latitude is required"),
|
|
304
|
+
longitude: yup.number().required("Longitude is required"),
|
|
305
|
+
region: yup.string().required("Region is required"),
|
|
306
|
+
type: yup.string().oneOf(["Point"], "Type must be 'Point'").default("Point").required("Type is required")
|
|
307
|
+
});
|
|
308
|
+
var emailSchema = yup.string().email("Invalid email address").required("Email is required").transform(
|
|
309
|
+
(value) => typeof value === "string" ? value.toLowerCase() : value
|
|
310
|
+
);
|
|
311
|
+
var passwordSchema = yup.string().trim().min(8, "Password must be at least 8 characters long").required("Password is required");
|
|
312
|
+
var globalResourceSchema = yup.object().shape({
|
|
313
|
+
active: yup.boolean().required("Active is required"),
|
|
314
|
+
cover: yup.object({
|
|
315
|
+
source: yup.string().required("Cover is required"),
|
|
316
|
+
title: yup.string().required("Cover is required")
|
|
317
|
+
}),
|
|
318
|
+
description: yup.string().trim().min(3).required("Description is required"),
|
|
319
|
+
name: yup.string().trim().min(3).required("Name is required"),
|
|
320
|
+
region: yup.string().required("Region is required")
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
// src/yupSchema/market.ts
|
|
324
|
+
var yup2 = __toESM(require("yup"));
|
|
325
|
+
var nzBankAccountRegex = /^\d{2}-\d{4}-\d{7}-\d{2}$/;
|
|
326
|
+
var marketSchema = globalResourceSchema.shape({
|
|
327
|
+
dateTime: yup2.array().of(dateTimeSchema).required("DateTime is required"),
|
|
328
|
+
location: locationSchema,
|
|
329
|
+
provider: yup2.string().trim().min(3).required("Provider is required"),
|
|
330
|
+
tags: yup2.array().of(yup2.string().defined()).nullable()
|
|
331
|
+
});
|
|
332
|
+
var marketInfoSchema = yup2.object().shape({
|
|
333
|
+
applicationDeadlineHours: yup2.number().typeError("Application deadline hours must be a number").min(1, "Application deadline hours must be at least 1").required("Application deadline hours is required").test("no-leading-zeros", "", noLeadingZeros("Application deadline hours")),
|
|
334
|
+
dateTime: yup2.array().of(dateTimeWithPriceSchema).required("DateTime is required"),
|
|
335
|
+
paymentDueHours: yup2.number().typeError("Payment due hours must be a number").min(1, "Payment due hours must be at least 1").required("Payment due hours is required").test("no-leading-zeros", "", noLeadingZeros("Payment due hours")),
|
|
336
|
+
paymentMethod: yup2.mixed().oneOf(Object.values(EnumPaymentMethod)).required("Please select a Payment method"),
|
|
337
|
+
paymentTarget: yup2.object().when("paymentMethod", (paymentMethod, schema) => {
|
|
338
|
+
const isBankTransfer = paymentMethod.includes(
|
|
339
|
+
"bank_transfer" /* BANK_TRANSFER */
|
|
340
|
+
);
|
|
341
|
+
if (!isBankTransfer) {
|
|
342
|
+
return schema.shape({
|
|
343
|
+
accountHolderName: yup2.string().notRequired(),
|
|
344
|
+
accountNumber: yup2.string().notRequired(),
|
|
345
|
+
link: yup2.string().trim().required("Link is required for PayPal/Stripe")
|
|
346
|
+
});
|
|
347
|
+
} else if (isBankTransfer) {
|
|
348
|
+
return schema.shape({
|
|
349
|
+
accountHolderName: yup2.string().trim().required("Account holder name is required for bank transfer"),
|
|
350
|
+
accountNumber: yup2.string().trim().required("Account number is required for bank transfer").matches(
|
|
351
|
+
nzBankAccountRegex,
|
|
352
|
+
"Account number must be in format: XX-XXXX-XXXXXXX-XX"
|
|
353
|
+
),
|
|
354
|
+
link: yup2.string().notRequired()
|
|
355
|
+
});
|
|
356
|
+
} else {
|
|
357
|
+
return schema.shape({
|
|
358
|
+
accountHolderName: yup2.string().notRequired(),
|
|
359
|
+
accountNumber: yup2.string().notRequired(),
|
|
360
|
+
link: yup2.string().notRequired()
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
}),
|
|
364
|
+
rejectionPolicy: yup2.mixed().oneOf(Object.values(EnumRejectionPolicy)).required("Rejection policy is required"),
|
|
365
|
+
stallCapacity: yup2.number().typeError("Stall capacity must be a number").min(1, "Stall capacity must be at least 1").integer("Stall capacity must be a whole number").required("Stall capacity is required").test("no-leading-zeros", "", noLeadingZeros("Stall capacity"))
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
// src/yupSchema/stallholder.ts
|
|
369
|
+
var yup3 = __toESM(require("yup"));
|
|
370
|
+
var stallHolderSchema = globalResourceSchema.shape({
|
|
371
|
+
categories: yup3.array().of(
|
|
372
|
+
yup3.object().shape({
|
|
373
|
+
id: yup3.string().required("Category id is required"),
|
|
374
|
+
name: yup3.string().required("Category name is required"),
|
|
375
|
+
subcategories: yup3.array().of(
|
|
376
|
+
yup3.object().shape({
|
|
377
|
+
id: yup3.string().defined(),
|
|
378
|
+
items: yup3.array().of(yup3.string().defined()).nullable(),
|
|
379
|
+
name: yup3.string().defined()
|
|
380
|
+
})
|
|
381
|
+
).nullable()
|
|
382
|
+
})
|
|
383
|
+
).min(1, "Category list must contain at least one item").required("Categories are required"),
|
|
384
|
+
multiLocation: yup3.boolean().required("Multi location is required"),
|
|
385
|
+
products: yup3.array().of(yup3.string().defined()).min(1, "Product list must contain at least one item").required("Products are required")
|
|
386
|
+
});
|
|
387
|
+
var stallholderApplyFormSchema = yup3.object().shape({
|
|
388
|
+
active: yup3.boolean().required("Active is required"),
|
|
389
|
+
electricity: yup3.object().shape({
|
|
390
|
+
details: yup3.string().trim().test("details-required", "Please add details", function(value) {
|
|
391
|
+
return !this.parent?.isRequired || (value?.trim().length ?? 0) > 0;
|
|
392
|
+
}).nullable(),
|
|
393
|
+
isRequired: yup3.boolean().required("Electricity requirement is required")
|
|
394
|
+
}),
|
|
395
|
+
foodSafetyGradeFiles: yup3.array().of(yup3.string().defined()).nullable(),
|
|
396
|
+
foodSafetyGradeFilesUpload: yup3.array().of(yup3.string().defined()).nullable(),
|
|
397
|
+
gazebo: yup3.object().shape({
|
|
398
|
+
details: yup3.string().trim().test("details-required", "Please add details", function(value) {
|
|
399
|
+
return !this.parent?.isRequired || (value?.trim().length ?? 0) > 0;
|
|
400
|
+
}).nullable(),
|
|
401
|
+
isRequired: yup3.boolean().required("Gazebo requirement is required")
|
|
402
|
+
}),
|
|
403
|
+
packaging: yup3.array().of(yup3.string().defined()).min(1, "Packaging list must contain at least one item").required("Packaging is required"),
|
|
404
|
+
paymentMethod: yup3.mixed().oneOf(Object.values(EnumPaymentMethod)).required("Please select a Payment method"),
|
|
405
|
+
priceRange: yup3.object().shape({
|
|
406
|
+
max: yup3.number().min(1).required("Max price is required").test(
|
|
407
|
+
"is-greater",
|
|
408
|
+
"Max price must be greater than or equal to Min price",
|
|
409
|
+
function(max) {
|
|
410
|
+
const { min } = this.parent;
|
|
411
|
+
return max >= min;
|
|
412
|
+
}
|
|
413
|
+
),
|
|
414
|
+
min: yup3.number().min(1).required("Min price is required")
|
|
415
|
+
}),
|
|
416
|
+
producedIn: yup3.array().of(yup3.string().defined()).min(1, "Produced in list must contain at least one item").required("Produced in is required"),
|
|
417
|
+
stallSize: yup3.object().shape({
|
|
418
|
+
depth: yup3.number().min(1).required("Depth is required"),
|
|
419
|
+
width: yup3.number().min(1).required("Width is required")
|
|
420
|
+
}),
|
|
421
|
+
table: yup3.object().shape({
|
|
422
|
+
details: yup3.string().trim().test("details-required", "Please add details", function(value) {
|
|
423
|
+
return !this.parent?.isRequired || (value?.trim().length ?? 0) > 0;
|
|
424
|
+
}).nullable(),
|
|
425
|
+
isRequired: yup3.boolean().required("Table requirement is required")
|
|
426
|
+
})
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
// src/yupSchema/user.ts
|
|
430
|
+
var yup4 = __toESM(require("yup"));
|
|
431
|
+
var userSchema = yup4.object().shape({
|
|
432
|
+
active: yup4.boolean().required("Active is required"),
|
|
433
|
+
email: emailSchema,
|
|
434
|
+
firstName: yup4.string().required("First name is required"),
|
|
435
|
+
lastName: yup4.string().required("Last name is required"),
|
|
436
|
+
password: passwordSchema,
|
|
437
|
+
preferredRegion: yup4.string().required("Preferred region is required"),
|
|
438
|
+
// eslint-disable-next-line sort-keys
|
|
439
|
+
confirmPassword: yup4.string().oneOf([yup4.ref("password")], "Passwords must match").required("Confirm Password is required"),
|
|
440
|
+
role: yup4.mixed().oneOf(Object.values(EnumUserRole)).required("Role is required")
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
// src/yupSchema/auth.ts
|
|
444
|
+
var yup5 = __toESM(require("yup"));
|
|
445
|
+
var loginSchema = yup5.object().shape({
|
|
446
|
+
email: emailSchema,
|
|
447
|
+
password: passwordSchema
|
|
448
|
+
});
|
|
449
|
+
var registerSchema = yup5.object().shape({
|
|
450
|
+
email: emailSchema,
|
|
451
|
+
firstName: yup5.string().required("First Name is required"),
|
|
452
|
+
lastName: yup5.string().required("Last Name is required"),
|
|
453
|
+
password: passwordSchema,
|
|
454
|
+
preferredRegion: yup5.string().required("Preferred Region is required"),
|
|
455
|
+
role: yup5.mixed().oneOf(Object.values(EnumUserRole)).required("Role is required")
|
|
456
|
+
});
|
|
457
|
+
var requestPasswordResetSchema = yup5.object().shape({
|
|
458
|
+
email: emailSchema
|
|
459
|
+
});
|
|
460
|
+
var resetPasswordSchema = yup5.object().shape({
|
|
461
|
+
email: emailSchema,
|
|
462
|
+
password: passwordSchema,
|
|
463
|
+
// eslint-disable-next-line sort-keys
|
|
464
|
+
confirmPassword: yup5.string().oneOf([yup5.ref("password")], "Passwords must match").required("Confirm Password is required")
|
|
465
|
+
});
|
|
466
|
+
var validateTokenSchema = yup5.object().shape({
|
|
467
|
+
email: emailSchema,
|
|
468
|
+
token: yup5.string().required("Verification code is required").matches(/^\d{5}$/, "Verification code must be exactly 5 digits")
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
// src/hooks/utils.ts
|
|
472
|
+
var globalDefaultValues = {
|
|
473
|
+
active: false,
|
|
474
|
+
cover: {
|
|
475
|
+
source: "",
|
|
476
|
+
title: ""
|
|
477
|
+
},
|
|
478
|
+
coverUpload: {
|
|
479
|
+
source: "",
|
|
480
|
+
title: ""
|
|
481
|
+
},
|
|
482
|
+
description: "Lorem Ipsum is a placeholder text commonly used in design and publishing to represent the visual form of a document without relying on meaningful content. It's a jumbled Latin text, not intended to be read or understood, and is used to show the layout and typography before actual content is added.",
|
|
483
|
+
images: null,
|
|
484
|
+
imagesUpload: null,
|
|
485
|
+
logo: null,
|
|
486
|
+
logoUpload: null,
|
|
487
|
+
name: "Resource name",
|
|
488
|
+
promoCode: "",
|
|
489
|
+
region: ""
|
|
490
|
+
};
|
|
491
|
+
var defaultMarketFormValues = {
|
|
492
|
+
...globalDefaultValues,
|
|
493
|
+
dateTime: [
|
|
494
|
+
{
|
|
495
|
+
endDate: "04-05-2025",
|
|
496
|
+
endTime: "15:00",
|
|
497
|
+
startDate: "04-05-2025",
|
|
498
|
+
startTime: "09:00"
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
endDate: "05-05-2025",
|
|
502
|
+
endTime: "15:00",
|
|
503
|
+
startDate: "05-05-2025",
|
|
504
|
+
startTime: "09:00"
|
|
505
|
+
}
|
|
506
|
+
],
|
|
507
|
+
location: {
|
|
508
|
+
city: "",
|
|
509
|
+
coordinates: [0, 0],
|
|
510
|
+
// [longitude, latitude]
|
|
511
|
+
country: "",
|
|
512
|
+
fullAddress: "",
|
|
513
|
+
latitude: 0,
|
|
514
|
+
longitude: 0,
|
|
515
|
+
region: "",
|
|
516
|
+
type: "Point"
|
|
517
|
+
// Default type for GeoJSON
|
|
518
|
+
},
|
|
519
|
+
provider: "Provider name",
|
|
520
|
+
tags: null
|
|
521
|
+
};
|
|
522
|
+
var defaultMarketInfoFormValues = {
|
|
523
|
+
applicationDeadlineHours: 0,
|
|
524
|
+
dateTime: [
|
|
525
|
+
{
|
|
526
|
+
endDate: "04-05-2025",
|
|
527
|
+
endTime: "15:00",
|
|
528
|
+
marketPrice: 0,
|
|
529
|
+
startDate: "04-05-2025",
|
|
530
|
+
startTime: "09:00"
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
endDate: "05-05-2025",
|
|
534
|
+
endTime: "15:00",
|
|
535
|
+
marketPrice: 0,
|
|
536
|
+
startDate: "05-05-2025",
|
|
537
|
+
startTime: "09:00"
|
|
538
|
+
}
|
|
539
|
+
],
|
|
540
|
+
paymentDueHours: 0,
|
|
541
|
+
paymentMethod: "",
|
|
542
|
+
paymentTarget: {
|
|
543
|
+
accountHolderName: "",
|
|
544
|
+
accountNumber: "",
|
|
545
|
+
link: ""
|
|
546
|
+
},
|
|
547
|
+
rejectionPolicy: "multi_date_allowed" /* MULTI_DATE_ALLOWED */,
|
|
548
|
+
stallCapacity: 0
|
|
549
|
+
};
|
|
550
|
+
var defaultStallholderFormValues = {
|
|
551
|
+
...globalDefaultValues,
|
|
552
|
+
categories: [],
|
|
553
|
+
locations: null,
|
|
554
|
+
multiLocation: false,
|
|
555
|
+
products: ["Prod uct 1", "Product 2"],
|
|
556
|
+
specialities: null
|
|
557
|
+
};
|
|
558
|
+
var defaultStallholderApplyFormValues = {
|
|
559
|
+
active: false,
|
|
560
|
+
electricity: { details: null, isRequired: false },
|
|
561
|
+
foodSafetyGradeFiles: null,
|
|
562
|
+
foodSafetyGradeFilesUpload: null,
|
|
563
|
+
gazebo: { details: null, isRequired: false },
|
|
564
|
+
packaging: [],
|
|
565
|
+
paymentMethod: "",
|
|
566
|
+
priceRange: { max: 0, min: 0 },
|
|
567
|
+
producedIn: [],
|
|
568
|
+
stallSize: { depth: 0, width: 0 },
|
|
569
|
+
table: { details: null, isRequired: false }
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
// src/hooks/stallholder/useStallholderForm.ts
|
|
573
|
+
function useStallholderForm(data) {
|
|
574
|
+
const {
|
|
575
|
+
control,
|
|
576
|
+
formState: { errors },
|
|
577
|
+
getValues,
|
|
578
|
+
handleSubmit,
|
|
579
|
+
reset,
|
|
580
|
+
setValue,
|
|
581
|
+
watch
|
|
582
|
+
} = (0, import_react_hook_form.useForm)({
|
|
583
|
+
defaultValues: defaultStallholderFormValues,
|
|
584
|
+
resolver: (0, import_yup.yupResolver)(stallHolderSchema)
|
|
585
|
+
});
|
|
586
|
+
React.useEffect(() => {
|
|
587
|
+
if (data) {
|
|
588
|
+
reset({
|
|
589
|
+
_id: data._id,
|
|
590
|
+
active: data.active,
|
|
591
|
+
categories: data.categories,
|
|
592
|
+
cover: data.cover,
|
|
593
|
+
coverUpload: data.coverUpload,
|
|
594
|
+
description: data.description,
|
|
595
|
+
images: data.images,
|
|
596
|
+
imagesUpload: data.imagesUpload,
|
|
597
|
+
locations: data.locations,
|
|
598
|
+
logo: data.logo,
|
|
599
|
+
logoUpload: data.logoUpload,
|
|
600
|
+
multiLocation: data.multiLocation,
|
|
601
|
+
name: data.name,
|
|
602
|
+
products: data.products,
|
|
603
|
+
promoCode: data.promoCode,
|
|
604
|
+
region: data.region,
|
|
605
|
+
specialities: data.specialities
|
|
606
|
+
});
|
|
607
|
+
} else {
|
|
608
|
+
reset(defaultStallholderFormValues);
|
|
609
|
+
}
|
|
610
|
+
}, [data]);
|
|
611
|
+
const {
|
|
612
|
+
_id,
|
|
613
|
+
active,
|
|
614
|
+
categories,
|
|
615
|
+
cover,
|
|
616
|
+
coverUpload,
|
|
617
|
+
description,
|
|
618
|
+
images,
|
|
619
|
+
imagesUpload,
|
|
620
|
+
locations,
|
|
621
|
+
logo,
|
|
622
|
+
logoUpload,
|
|
623
|
+
multiLocation,
|
|
624
|
+
name,
|
|
625
|
+
products,
|
|
626
|
+
promoCode,
|
|
627
|
+
region,
|
|
628
|
+
specialities
|
|
629
|
+
} = getValues();
|
|
630
|
+
return {
|
|
631
|
+
control,
|
|
632
|
+
fields: {
|
|
633
|
+
_id,
|
|
634
|
+
active,
|
|
635
|
+
categories,
|
|
636
|
+
cover,
|
|
637
|
+
coverUpload,
|
|
638
|
+
description,
|
|
639
|
+
images,
|
|
640
|
+
imagesUpload,
|
|
641
|
+
locations,
|
|
642
|
+
logo,
|
|
643
|
+
logoUpload,
|
|
644
|
+
multiLocation,
|
|
645
|
+
name,
|
|
646
|
+
products,
|
|
647
|
+
promoCode,
|
|
648
|
+
region,
|
|
649
|
+
specialities
|
|
650
|
+
},
|
|
651
|
+
formState: { errors },
|
|
652
|
+
handleSubmit,
|
|
653
|
+
reset,
|
|
654
|
+
setValue,
|
|
655
|
+
watch
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// src/hooks/stallholder/useStallholderApplyForm.ts
|
|
660
|
+
var import_yup2 = require("@hookform/resolvers/yup");
|
|
661
|
+
var React2 = __toESM(require("react"));
|
|
662
|
+
var import_react_hook_form2 = require("react-hook-form");
|
|
663
|
+
function useStallholderApplyForm(data) {
|
|
664
|
+
const {
|
|
665
|
+
control,
|
|
666
|
+
formState: { errors },
|
|
667
|
+
getValues,
|
|
668
|
+
handleSubmit,
|
|
669
|
+
reset,
|
|
670
|
+
setValue,
|
|
671
|
+
watch
|
|
672
|
+
} = (0, import_react_hook_form2.useForm)({
|
|
673
|
+
defaultValues: defaultStallholderApplyFormValues,
|
|
674
|
+
resolver: (0, import_yup2.yupResolver)(stallholderApplyFormSchema)
|
|
675
|
+
});
|
|
676
|
+
React2.useEffect(() => {
|
|
677
|
+
if (data) {
|
|
678
|
+
reset({
|
|
679
|
+
_id: data._id,
|
|
680
|
+
active: data.active,
|
|
681
|
+
electricity: data.electricity,
|
|
682
|
+
foodSafetyGradeFiles: data.foodSafetyGradeFiles,
|
|
683
|
+
foodSafetyGradeFilesUpload: data.foodSafetyGradeFilesUpload,
|
|
684
|
+
gazebo: data.gazebo,
|
|
685
|
+
packaging: data.packaging,
|
|
686
|
+
paymentMethod: data.paymentMethod,
|
|
687
|
+
priceRange: data.priceRange,
|
|
688
|
+
producedIn: data.producedIn,
|
|
689
|
+
stallSize: data.stallSize,
|
|
690
|
+
table: data.table
|
|
691
|
+
});
|
|
692
|
+
} else {
|
|
693
|
+
reset(defaultStallholderApplyFormValues);
|
|
694
|
+
}
|
|
695
|
+
}, [data]);
|
|
696
|
+
const {
|
|
697
|
+
_id,
|
|
698
|
+
active,
|
|
699
|
+
electricity,
|
|
700
|
+
foodSafetyGradeFiles,
|
|
701
|
+
foodSafetyGradeFilesUpload,
|
|
702
|
+
gazebo,
|
|
703
|
+
packaging,
|
|
704
|
+
paymentMethod,
|
|
705
|
+
priceRange,
|
|
706
|
+
producedIn,
|
|
707
|
+
stallSize,
|
|
708
|
+
table
|
|
709
|
+
} = getValues();
|
|
710
|
+
return {
|
|
711
|
+
control,
|
|
712
|
+
fields: {
|
|
713
|
+
_id,
|
|
714
|
+
active,
|
|
715
|
+
electricity,
|
|
716
|
+
foodSafetyGradeFiles,
|
|
717
|
+
foodSafetyGradeFilesUpload,
|
|
718
|
+
gazebo,
|
|
719
|
+
packaging,
|
|
720
|
+
paymentMethod,
|
|
721
|
+
priceRange,
|
|
722
|
+
producedIn,
|
|
723
|
+
stallSize,
|
|
724
|
+
table
|
|
725
|
+
},
|
|
726
|
+
formState: { errors },
|
|
727
|
+
handleSubmit,
|
|
728
|
+
reset,
|
|
729
|
+
setValue,
|
|
730
|
+
watch
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
// src/hooks/market/useMarketForm.ts
|
|
735
|
+
var import_yup3 = require("@hookform/resolvers/yup");
|
|
736
|
+
var React3 = __toESM(require("react"));
|
|
737
|
+
var import_react_hook_form3 = require("react-hook-form");
|
|
738
|
+
function useMarketForm(data) {
|
|
739
|
+
const {
|
|
740
|
+
control,
|
|
741
|
+
formState: { errors },
|
|
742
|
+
getValues,
|
|
743
|
+
handleSubmit,
|
|
744
|
+
reset,
|
|
745
|
+
setValue,
|
|
746
|
+
watch
|
|
747
|
+
} = (0, import_react_hook_form3.useForm)({
|
|
748
|
+
defaultValues: defaultMarketFormValues,
|
|
749
|
+
resolver: (0, import_yup3.yupResolver)(marketSchema)
|
|
750
|
+
});
|
|
751
|
+
React3.useEffect(() => {
|
|
752
|
+
if (data) {
|
|
753
|
+
reset({
|
|
754
|
+
_id: data._id,
|
|
755
|
+
active: data.active,
|
|
756
|
+
cover: data.cover,
|
|
757
|
+
coverUpload: data.coverUpload,
|
|
758
|
+
dateTime: data.dateTime,
|
|
759
|
+
description: data.description,
|
|
760
|
+
images: data.images,
|
|
761
|
+
imagesUpload: data.imagesUpload,
|
|
762
|
+
location: data.location,
|
|
763
|
+
logo: data.logo,
|
|
764
|
+
logoUpload: data.logoUpload,
|
|
765
|
+
name: data.name,
|
|
766
|
+
promoCode: data.promoCode,
|
|
767
|
+
provider: data.provider,
|
|
768
|
+
region: data.region,
|
|
769
|
+
tags: data.tags
|
|
770
|
+
});
|
|
771
|
+
} else {
|
|
772
|
+
reset(defaultMarketFormValues);
|
|
773
|
+
}
|
|
774
|
+
}, [data]);
|
|
775
|
+
const {
|
|
776
|
+
_id,
|
|
777
|
+
active,
|
|
778
|
+
cover,
|
|
779
|
+
coverUpload,
|
|
780
|
+
dateTime,
|
|
781
|
+
description,
|
|
782
|
+
images,
|
|
783
|
+
imagesUpload,
|
|
784
|
+
location,
|
|
785
|
+
logo,
|
|
786
|
+
logoUpload,
|
|
787
|
+
name,
|
|
788
|
+
provider,
|
|
789
|
+
region,
|
|
790
|
+
tags
|
|
791
|
+
} = getValues();
|
|
792
|
+
return {
|
|
793
|
+
control,
|
|
794
|
+
fields: {
|
|
795
|
+
_id,
|
|
796
|
+
active,
|
|
797
|
+
cover,
|
|
798
|
+
coverUpload,
|
|
799
|
+
dateTime,
|
|
800
|
+
description,
|
|
801
|
+
images,
|
|
802
|
+
imagesUpload,
|
|
803
|
+
location,
|
|
804
|
+
logo,
|
|
805
|
+
logoUpload,
|
|
806
|
+
name,
|
|
807
|
+
provider,
|
|
808
|
+
region,
|
|
809
|
+
tags
|
|
810
|
+
},
|
|
811
|
+
formState: { errors },
|
|
812
|
+
handleSubmit,
|
|
813
|
+
reset,
|
|
814
|
+
setValue,
|
|
815
|
+
watch
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
// src/hooks/market/useMarketInfoForm.ts
|
|
820
|
+
var import_yup4 = require("@hookform/resolvers/yup");
|
|
821
|
+
var React4 = __toESM(require("react"));
|
|
822
|
+
var import_react_hook_form4 = require("react-hook-form");
|
|
823
|
+
function useMarketInfoForm(data) {
|
|
824
|
+
const {
|
|
825
|
+
control,
|
|
826
|
+
formState: { errors },
|
|
827
|
+
getValues,
|
|
828
|
+
handleSubmit,
|
|
829
|
+
reset,
|
|
830
|
+
setValue,
|
|
831
|
+
watch
|
|
832
|
+
} = (0, import_react_hook_form4.useForm)({
|
|
833
|
+
defaultValues: defaultMarketInfoFormValues,
|
|
834
|
+
resolver: (0, import_yup4.yupResolver)(marketInfoSchema)
|
|
835
|
+
});
|
|
836
|
+
React4.useEffect(() => {
|
|
837
|
+
if (data) {
|
|
838
|
+
reset({
|
|
839
|
+
_id: data._id,
|
|
840
|
+
applicationDeadlineHours: data.applicationDeadlineHours,
|
|
841
|
+
dateTime: data.dateTime,
|
|
842
|
+
paymentDueHours: data.paymentDueHours,
|
|
843
|
+
paymentMethod: data.paymentMethod,
|
|
844
|
+
paymentTarget: data.paymentTarget,
|
|
845
|
+
rejectionPolicy: data.rejectionPolicy,
|
|
846
|
+
stallCapacity: data.stallCapacity
|
|
847
|
+
});
|
|
848
|
+
} else {
|
|
849
|
+
reset(defaultMarketInfoFormValues);
|
|
850
|
+
}
|
|
851
|
+
}, [data]);
|
|
852
|
+
const {
|
|
853
|
+
_id,
|
|
854
|
+
applicationDeadlineHours,
|
|
855
|
+
dateTime,
|
|
856
|
+
paymentDueHours,
|
|
857
|
+
paymentMethod,
|
|
858
|
+
paymentTarget,
|
|
859
|
+
rejectionPolicy,
|
|
860
|
+
stallCapacity
|
|
861
|
+
} = getValues();
|
|
862
|
+
return {
|
|
863
|
+
control,
|
|
864
|
+
fields: {
|
|
865
|
+
_id,
|
|
866
|
+
applicationDeadlineHours,
|
|
867
|
+
dateTime,
|
|
868
|
+
paymentDueHours,
|
|
869
|
+
paymentMethod,
|
|
870
|
+
paymentTarget,
|
|
871
|
+
rejectionPolicy,
|
|
872
|
+
stallCapacity
|
|
873
|
+
},
|
|
874
|
+
formState: { errors },
|
|
875
|
+
handleSubmit,
|
|
876
|
+
reset,
|
|
877
|
+
setValue,
|
|
878
|
+
watch
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
// src/hooks/useUserForm.ts
|
|
883
|
+
var import_yup5 = require("@hookform/resolvers/yup");
|
|
884
|
+
var React5 = __toESM(require("react"));
|
|
885
|
+
var import_react_hook_form5 = require("react-hook-form");
|
|
886
|
+
var defaultValues = {
|
|
887
|
+
active: false,
|
|
888
|
+
avatar: null,
|
|
889
|
+
avatarUpload: null,
|
|
890
|
+
confirmPassword: "",
|
|
891
|
+
email: "",
|
|
892
|
+
firstName: "",
|
|
893
|
+
lastName: "",
|
|
894
|
+
password: "",
|
|
895
|
+
preferredRegion: "",
|
|
896
|
+
role: "customer" /* CUSTOMER */
|
|
897
|
+
};
|
|
898
|
+
function useUserForm(data) {
|
|
899
|
+
const {
|
|
900
|
+
control,
|
|
901
|
+
formState: { errors },
|
|
902
|
+
getValues,
|
|
903
|
+
handleSubmit,
|
|
904
|
+
reset,
|
|
905
|
+
setValue,
|
|
906
|
+
watch
|
|
907
|
+
} = (0, import_react_hook_form5.useForm)({
|
|
908
|
+
defaultValues,
|
|
909
|
+
resolver: (0, import_yup5.yupResolver)(userSchema)
|
|
910
|
+
});
|
|
911
|
+
React5.useEffect(() => {
|
|
912
|
+
if (data) {
|
|
913
|
+
reset({
|
|
914
|
+
_id: data._id,
|
|
915
|
+
active: data.active,
|
|
916
|
+
avatar: data.avatar,
|
|
917
|
+
avatarUpload: data.avatarUpload,
|
|
918
|
+
confirmPassword: data.confirmPassword,
|
|
919
|
+
email: data.email,
|
|
920
|
+
firstName: data.firstName,
|
|
921
|
+
lastName: data.lastName,
|
|
922
|
+
password: data.password,
|
|
923
|
+
preferredRegion: data.preferredRegion,
|
|
924
|
+
role: data.role
|
|
925
|
+
});
|
|
926
|
+
} else {
|
|
927
|
+
reset(defaultValues);
|
|
928
|
+
}
|
|
929
|
+
}, [data]);
|
|
930
|
+
const {
|
|
931
|
+
_id,
|
|
932
|
+
active,
|
|
933
|
+
avatar,
|
|
934
|
+
avatarUpload,
|
|
935
|
+
confirmPassword,
|
|
936
|
+
email,
|
|
937
|
+
firstName,
|
|
938
|
+
lastName,
|
|
939
|
+
password,
|
|
940
|
+
preferredRegion,
|
|
941
|
+
role
|
|
942
|
+
} = getValues();
|
|
943
|
+
return {
|
|
944
|
+
control,
|
|
945
|
+
fields: {
|
|
946
|
+
_id,
|
|
947
|
+
active,
|
|
948
|
+
avatar,
|
|
949
|
+
avatarUpload,
|
|
950
|
+
confirmPassword,
|
|
951
|
+
email,
|
|
952
|
+
firstName,
|
|
953
|
+
lastName,
|
|
954
|
+
password,
|
|
955
|
+
preferredRegion,
|
|
956
|
+
role
|
|
957
|
+
},
|
|
958
|
+
formState: { errors },
|
|
959
|
+
handleSubmit,
|
|
960
|
+
reset,
|
|
961
|
+
setValue,
|
|
962
|
+
watch
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
// src/hooks/auth/useLoginForm.ts
|
|
967
|
+
var import_yup6 = require("@hookform/resolvers/yup");
|
|
968
|
+
var import_react_hook_form6 = require("react-hook-form");
|
|
969
|
+
var defaultValues2 = {
|
|
970
|
+
email: "",
|
|
971
|
+
password: ""
|
|
972
|
+
};
|
|
973
|
+
function useLoginForm() {
|
|
974
|
+
const {
|
|
975
|
+
control,
|
|
976
|
+
formState: { errors },
|
|
977
|
+
getValues,
|
|
978
|
+
handleSubmit,
|
|
979
|
+
reset,
|
|
980
|
+
setValue,
|
|
981
|
+
watch
|
|
982
|
+
} = (0, import_react_hook_form6.useForm)({
|
|
983
|
+
defaultValues: defaultValues2,
|
|
984
|
+
resolver: (0, import_yup6.yupResolver)(loginSchema)
|
|
985
|
+
});
|
|
986
|
+
const { email, password } = getValues();
|
|
987
|
+
return {
|
|
988
|
+
control,
|
|
989
|
+
fields: {
|
|
990
|
+
email,
|
|
991
|
+
password
|
|
992
|
+
},
|
|
993
|
+
formState: { errors },
|
|
994
|
+
handleSubmit,
|
|
995
|
+
reset,
|
|
996
|
+
setValue,
|
|
997
|
+
watch
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
// src/hooks/auth/useRegisterForm.ts
|
|
1002
|
+
var import_yup7 = require("@hookform/resolvers/yup");
|
|
1003
|
+
var import_react_hook_form7 = require("react-hook-form");
|
|
1004
|
+
var defaultValues3 = {
|
|
1005
|
+
email: "",
|
|
1006
|
+
firstName: "",
|
|
1007
|
+
lastName: "",
|
|
1008
|
+
password: "",
|
|
1009
|
+
preferredRegion: "",
|
|
1010
|
+
role: "customer" /* CUSTOMER */
|
|
1011
|
+
};
|
|
1012
|
+
function useRegisterForm() {
|
|
1013
|
+
const {
|
|
1014
|
+
control,
|
|
1015
|
+
formState: { errors },
|
|
1016
|
+
getValues,
|
|
1017
|
+
handleSubmit,
|
|
1018
|
+
reset,
|
|
1019
|
+
setValue,
|
|
1020
|
+
watch
|
|
1021
|
+
} = (0, import_react_hook_form7.useForm)({
|
|
1022
|
+
defaultValues: defaultValues3,
|
|
1023
|
+
resolver: (0, import_yup7.yupResolver)(registerSchema)
|
|
1024
|
+
});
|
|
1025
|
+
const { email, firstName, lastName, password, preferredRegion, role } = getValues();
|
|
1026
|
+
return {
|
|
1027
|
+
control,
|
|
1028
|
+
fields: {
|
|
1029
|
+
email,
|
|
1030
|
+
firstName,
|
|
1031
|
+
lastName,
|
|
1032
|
+
password,
|
|
1033
|
+
preferredRegion,
|
|
1034
|
+
role
|
|
1035
|
+
},
|
|
1036
|
+
formState: { errors },
|
|
1037
|
+
handleSubmit,
|
|
1038
|
+
reset,
|
|
1039
|
+
setValue,
|
|
1040
|
+
watch
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
// src/hooks/auth/useRequestPasswordResetForm.ts
|
|
1045
|
+
var import_yup8 = require("@hookform/resolvers/yup");
|
|
1046
|
+
var import_react_hook_form8 = require("react-hook-form");
|
|
1047
|
+
var defaultValues4 = {
|
|
1048
|
+
email: ""
|
|
1049
|
+
};
|
|
1050
|
+
function useRequestPasswordResetForm() {
|
|
1051
|
+
const {
|
|
1052
|
+
control,
|
|
1053
|
+
formState: { errors },
|
|
1054
|
+
getValues,
|
|
1055
|
+
handleSubmit,
|
|
1056
|
+
reset,
|
|
1057
|
+
setValue,
|
|
1058
|
+
watch
|
|
1059
|
+
} = (0, import_react_hook_form8.useForm)({
|
|
1060
|
+
defaultValues: defaultValues4,
|
|
1061
|
+
resolver: (0, import_yup8.yupResolver)(requestPasswordResetSchema)
|
|
1062
|
+
});
|
|
1063
|
+
const { email } = getValues();
|
|
1064
|
+
return {
|
|
1065
|
+
control,
|
|
1066
|
+
fields: {
|
|
1067
|
+
email
|
|
1068
|
+
},
|
|
1069
|
+
formState: { errors },
|
|
1070
|
+
handleSubmit,
|
|
1071
|
+
reset,
|
|
1072
|
+
setValue,
|
|
1073
|
+
watch
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
// src/hooks/auth/useValidateTokenForm.ts
|
|
1078
|
+
var import_yup9 = require("@hookform/resolvers/yup");
|
|
1079
|
+
var import_react_hook_form9 = require("react-hook-form");
|
|
1080
|
+
var defaultValues5 = {
|
|
1081
|
+
email: "",
|
|
1082
|
+
token: ""
|
|
1083
|
+
};
|
|
1084
|
+
function useValidateTokenForm() {
|
|
1085
|
+
const {
|
|
1086
|
+
control,
|
|
1087
|
+
formState: { errors },
|
|
1088
|
+
getValues,
|
|
1089
|
+
handleSubmit,
|
|
1090
|
+
reset,
|
|
1091
|
+
setValue,
|
|
1092
|
+
watch
|
|
1093
|
+
} = (0, import_react_hook_form9.useForm)({
|
|
1094
|
+
defaultValues: defaultValues5,
|
|
1095
|
+
resolver: (0, import_yup9.yupResolver)(validateTokenSchema)
|
|
1096
|
+
});
|
|
1097
|
+
const { email, token } = getValues();
|
|
1098
|
+
return {
|
|
1099
|
+
control,
|
|
1100
|
+
fields: {
|
|
1101
|
+
email,
|
|
1102
|
+
token
|
|
1103
|
+
},
|
|
1104
|
+
formState: { errors },
|
|
1105
|
+
handleSubmit,
|
|
1106
|
+
reset,
|
|
1107
|
+
setValue,
|
|
1108
|
+
watch
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
// src/hooks/auth/useResetPasswordForm.ts
|
|
1113
|
+
var import_yup10 = require("@hookform/resolvers/yup");
|
|
1114
|
+
var import_react_hook_form10 = require("react-hook-form");
|
|
1115
|
+
var defaultValues6 = {
|
|
1116
|
+
confirmPassword: "",
|
|
1117
|
+
email: "",
|
|
1118
|
+
password: ""
|
|
1119
|
+
};
|
|
1120
|
+
function useResetPasswordForm() {
|
|
1121
|
+
const {
|
|
1122
|
+
control,
|
|
1123
|
+
formState: { errors },
|
|
1124
|
+
getValues,
|
|
1125
|
+
handleSubmit,
|
|
1126
|
+
reset,
|
|
1127
|
+
setValue,
|
|
1128
|
+
watch
|
|
1129
|
+
} = (0, import_react_hook_form10.useForm)({
|
|
1130
|
+
defaultValues: defaultValues6,
|
|
1131
|
+
resolver: (0, import_yup10.yupResolver)(resetPasswordSchema)
|
|
1132
|
+
});
|
|
1133
|
+
const { confirmPassword, email, password } = getValues();
|
|
1134
|
+
return {
|
|
1135
|
+
control,
|
|
1136
|
+
fields: {
|
|
1137
|
+
confirmPassword,
|
|
1138
|
+
email,
|
|
1139
|
+
password
|
|
1140
|
+
},
|
|
1141
|
+
formState: { errors },
|
|
1142
|
+
handleSubmit,
|
|
1143
|
+
reset,
|
|
1144
|
+
setValue,
|
|
1145
|
+
watch
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1149
|
+
0 && (module.exports = {
|
|
1150
|
+
defaultMarketFormValues,
|
|
1151
|
+
defaultMarketInfoFormValues,
|
|
1152
|
+
defaultStallholderApplyFormValues,
|
|
1153
|
+
defaultStallholderFormValues,
|
|
1154
|
+
globalDefaultValues,
|
|
1155
|
+
useLocationSearch,
|
|
1156
|
+
useLoginForm,
|
|
1157
|
+
useMarketForm,
|
|
1158
|
+
useMarketInfoForm,
|
|
1159
|
+
useRegisterForm,
|
|
1160
|
+
useRequestPasswordResetForm,
|
|
1161
|
+
useResetPasswordForm,
|
|
1162
|
+
useStallholderApplyForm,
|
|
1163
|
+
useStallholderForm,
|
|
1164
|
+
useUserForm,
|
|
1165
|
+
useValidateTokenForm
|
|
1166
|
+
});
|
|
1167
|
+
//# sourceMappingURL=index.cjs.map
|