@timardex/cluemart-shared 1.0.14 → 1.0.16

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.
Files changed (54) hide show
  1. package/dist/auth-CdcH8nqw.d.mts +84 -0
  2. package/dist/auth-TM_XttY3.d.ts +84 -0
  3. package/dist/chat-NGx5Emrr.d.mts +27 -0
  4. package/dist/chat-NGx5Emrr.d.ts +27 -0
  5. package/dist/chunk-K5NK2CK5.mjs +133 -0
  6. package/dist/chunk-K5NK2CK5.mjs.map +1 -0
  7. package/dist/chunk-L2H5WFGC.mjs +100 -0
  8. package/dist/chunk-L2H5WFGC.mjs.map +1 -0
  9. package/dist/enums/index.cjs +134 -0
  10. package/dist/enums/index.cjs.map +1 -0
  11. package/dist/enums/index.d.mts +75 -0
  12. package/dist/enums/index.d.ts +75 -0
  13. package/dist/enums/index.mjs +27 -0
  14. package/dist/enums/index.mjs.map +1 -0
  15. package/dist/formFields/index.cjs +888 -0
  16. package/dist/formFields/index.cjs.map +1 -0
  17. package/dist/formFields/index.d.mts +60 -0
  18. package/dist/formFields/index.d.ts +60 -0
  19. package/dist/formFields/index.mjs +754 -0
  20. package/dist/formFields/index.mjs.map +1 -0
  21. package/dist/global-B7gB8cvC.d.ts +338 -0
  22. package/dist/global-B8kYikwQ.d.mts +338 -0
  23. package/dist/graphql/index.cjs +1634 -0
  24. package/dist/graphql/index.cjs.map +1 -0
  25. package/dist/graphql/index.d.mts +299 -0
  26. package/dist/graphql/index.d.ts +299 -0
  27. package/dist/graphql/index.mjs +1558 -0
  28. package/dist/graphql/index.mjs.map +1 -0
  29. package/dist/hooks/index.cjs +1090 -0
  30. package/dist/hooks/index.cjs.map +1 -0
  31. package/dist/hooks/index.d.mts +78 -0
  32. package/dist/hooks/index.d.ts +78 -0
  33. package/dist/hooks/index.mjs +970 -0
  34. package/dist/hooks/index.mjs.map +1 -0
  35. package/dist/index.cjs +89 -83
  36. package/dist/index.cjs.map +1 -0
  37. package/dist/index.d.mts +16 -299
  38. package/dist/index.d.ts +16 -299
  39. package/dist/index.mjs +87 -60
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/types/index.cjs +19 -0
  42. package/dist/types/index.cjs.map +1 -0
  43. package/dist/types/index.d.mts +12 -0
  44. package/dist/types/index.d.ts +12 -0
  45. package/dist/types/index.mjs +1 -0
  46. package/dist/types/index.mjs.map +1 -0
  47. package/dist/utils/index.cjs +215 -0
  48. package/dist/utils/index.cjs.map +1 -0
  49. package/dist/utils/index.d.mts +66 -0
  50. package/dist/utils/index.d.ts +66 -0
  51. package/dist/utils/index.mjs +38 -0
  52. package/dist/utils/index.mjs.map +1 -0
  53. package/package.json +37 -4
  54. package/dist/index.js.map +0 -1
@@ -0,0 +1,970 @@
1
+ import {
2
+ dateFormat,
3
+ timeFormat
4
+ } from "../chunk-K5NK2CK5.mjs";
5
+ import {
6
+ EnumPaymentMethod,
7
+ EnumRejectionPolicy,
8
+ EnumUserRole
9
+ } from "../chunk-L2H5WFGC.mjs";
10
+
11
+ // src/hooks/useLocationSearch.ts
12
+ var handleApiError = (error, message) => {
13
+ console.error(message, error);
14
+ };
15
+ var useLocationSearch = (googleApi) => {
16
+ const getPredictions = async (text) => {
17
+ try {
18
+ const response = await fetch(
19
+ `https://maps.googleapis.com/maps/api/place/autocomplete/json?input=${text}&components=country:nz&key=${googleApi}`
20
+ );
21
+ if (!response.ok) {
22
+ throw new Error(`HTTP error! Status: ${response.status}`);
23
+ }
24
+ const data = await response.json();
25
+ return data.predictions;
26
+ } catch (error) {
27
+ console.error("Error fetching predictions:", error);
28
+ handleApiError(error, "Failed to fetch address predictions.");
29
+ }
30
+ };
31
+ const getPlaceDetails = async (placeId) => {
32
+ try {
33
+ const response = await fetch(
34
+ `https://maps.googleapis.com/maps/api/place/details/json?place_id=${placeId}&key=${googleApi}`
35
+ );
36
+ if (!response.ok) {
37
+ throw new Error(`HTTP error! Status: ${response.status}`);
38
+ }
39
+ const data = await response.json();
40
+ const { result } = data;
41
+ const { lat, lng } = result.geometry.location;
42
+ const { address_components, formatted_address } = result;
43
+ const address = address_components.reduce((acc, item) => {
44
+ if (item.types.includes("street_number")) {
45
+ return { ...acc, streetNumber: item.long_name };
46
+ }
47
+ if (item.types.includes("route")) {
48
+ return { ...acc, streetName: item.long_name };
49
+ }
50
+ if (item.types.includes("locality")) {
51
+ return { ...acc, city: item.long_name };
52
+ }
53
+ if (item.types.includes("administrative_area_level_1")) {
54
+ return { ...acc, region: item.long_name };
55
+ }
56
+ if (item.types.includes("country")) {
57
+ return { ...acc, country: item.long_name };
58
+ }
59
+ return acc;
60
+ }, {});
61
+ const newLocation = {
62
+ city: address.city.toLowerCase(),
63
+ coordinates: [lng, lat],
64
+ // [longitude, latitude]
65
+ country: address.country,
66
+ fullAddress: formatted_address,
67
+ latitude: lat,
68
+ longitude: lng,
69
+ region: address.region.replace(/ Region$/, ""),
70
+ // Remove " Region" suffix
71
+ type: "Point"
72
+ // Mongoose GeoJSON type
73
+ };
74
+ return newLocation;
75
+ } catch (error) {
76
+ handleApiError(error, "Failed to fetch place details.");
77
+ }
78
+ };
79
+ return {
80
+ getPlaceDetails,
81
+ getPredictions
82
+ };
83
+ };
84
+
85
+ // src/hooks/stallholder/useStallholderForm.ts
86
+ import { yupResolver } from "@hookform/resolvers/yup";
87
+ import * as React from "react";
88
+ import { useForm } from "react-hook-form";
89
+
90
+ // src/yupSchema/global.ts
91
+ import dayjs, { extend } from "dayjs";
92
+ import customParseFormat from "dayjs/plugin/customParseFormat";
93
+ import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
94
+ import * as yup from "yup";
95
+ var noLeadingZeros = (fieldName, options = {}) => {
96
+ return function(value, context) {
97
+ const original = context.originalValue?.toString() ?? "";
98
+ const regex = options.allowDecimal ? /^0\d+(\.\d+)?$/ : /^0\d+$/;
99
+ if (regex.test(original)) {
100
+ return context.createError({
101
+ message: `${fieldName} must not have leading zeros`
102
+ });
103
+ }
104
+ return true;
105
+ };
106
+ };
107
+ extend(isSameOrAfter);
108
+ extend(customParseFormat);
109
+ var now = dayjs();
110
+ var endDateNotInPastTest = yup.string().test("not-in-past", "End date cannot be in the past", (value) => {
111
+ return value ? dayjs(value, dateFormat, true).isSameOrAfter(now, "day") : false;
112
+ });
113
+ var startDateNotInPastTest = yup.string().test("not-in-past", "Start date cannot be in the past", (value) => {
114
+ return value ? dayjs(value, dateFormat, true).isSameOrAfter(now, "day") : false;
115
+ });
116
+ var endDateAfterStartDateTest = yup.string().test(
117
+ "end-after-start",
118
+ "End date cannot be before start date",
119
+ function(value) {
120
+ const { startDate } = this.parent;
121
+ if (!startDate || !value) return false;
122
+ return dayjs(value, dateFormat, true).isSameOrAfter(
123
+ dayjs(startDate, dateFormat, true),
124
+ "day"
125
+ );
126
+ }
127
+ );
128
+ var endTimeMustBeAfterStartTimeTest = yup.string().test(
129
+ "valid-end-time",
130
+ "End time must be after start time",
131
+ function(value) {
132
+ const { startDate, endDate, startTime } = this.parent;
133
+ if (!startDate || !endDate || !startTime || !value) return false;
134
+ const startDateTime = dayjs(
135
+ `${startDate} ${startTime}`,
136
+ `${dateFormat} ${timeFormat}`,
137
+ true
138
+ );
139
+ const endDateTime = dayjs(
140
+ `${endDate} ${value}`,
141
+ `${dateFormat} ${timeFormat}`,
142
+ true
143
+ );
144
+ return endDateTime.isAfter(startDateTime);
145
+ }
146
+ );
147
+ var startTimeCannotBeInPastTest = yup.string().test(
148
+ "valid-start-time",
149
+ "Start time cannot be in the past",
150
+ function(value) {
151
+ const { startDate } = this.parent;
152
+ if (!startDate || !value) return false;
153
+ const startDateTime = dayjs(
154
+ `${startDate} ${value}`,
155
+ `${dateFormat} ${timeFormat}`,
156
+ true
157
+ );
158
+ return startDateTime.isSameOrAfter(now);
159
+ }
160
+ );
161
+ var dateTimeSchema = yup.object().shape({
162
+ endDate: yup.string().concat(endDateNotInPastTest).concat(endDateAfterStartDateTest).required("End date is required"),
163
+ endTime: yup.string().concat(endTimeMustBeAfterStartTimeTest).required("End time is required"),
164
+ 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(
165
+ "no-leading-zeros",
166
+ "",
167
+ noLeadingZeros("Market price", { allowDecimal: true })
168
+ ),
169
+ startDate: yup.string().concat(startDateNotInPastTest).required("Start date is required"),
170
+ startTime: yup.string().concat(startTimeCannotBeInPastTest).required("Start time is required")
171
+ });
172
+ var locationSchema = yup.object().shape({
173
+ city: yup.string().required("City is required"),
174
+ coordinates: yup.array().of(yup.number().required("Coordinates must be numbers")).length(
175
+ 2,
176
+ "Coordinates must contain exactly two numbers (longitude, latitude)"
177
+ ).required("Coordinates are required"),
178
+ country: yup.string().required("Country is required"),
179
+ fullAddress: yup.string().required("Address is required"),
180
+ latitude: yup.number().required("Latitude is required"),
181
+ longitude: yup.number().required("Longitude is required"),
182
+ region: yup.string().required("Region is required"),
183
+ type: yup.string().oneOf(["Point"], "Type must be 'Point'").default("Point").required("Type is required")
184
+ });
185
+ var emailSchema = yup.string().email("Invalid email address").required("Email is required").transform(
186
+ (value) => typeof value === "string" ? value.toLowerCase() : value
187
+ );
188
+ var passwordSchema = yup.string().trim().min(8, "Password must be at least 8 characters long").required("Password is required");
189
+ var globalResourceSchema = yup.object().shape({
190
+ active: yup.boolean().required("Active is required"),
191
+ cover: yup.object({
192
+ source: yup.string().required("Cover is required"),
193
+ title: yup.string().required("Cover is required")
194
+ }),
195
+ description: yup.string().trim().min(3).required("Description is required"),
196
+ name: yup.string().trim().min(3).required("Name is required"),
197
+ region: yup.string().required("Region is required")
198
+ });
199
+
200
+ // src/yupSchema/market.ts
201
+ import * as yup2 from "yup";
202
+ var nzBankAccountRegex = /^\d{2}-\d{4}-\d{7}-\d{2}$/;
203
+ var marketSchema = globalResourceSchema.shape({
204
+ dateTime: yup2.array().of(dateTimeSchema).required("DateTime is required"),
205
+ location: locationSchema,
206
+ provider: yup2.string().trim().min(3).required("Provider is required"),
207
+ stallApplicationInfo: yup2.object().shape({
208
+ 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(
209
+ "no-leading-zeros",
210
+ "",
211
+ noLeadingZeros("Application deadline hours")
212
+ ),
213
+ 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")),
214
+ paymentMethod: yup2.mixed().oneOf(Object.values(EnumPaymentMethod)).required("Please select a Payment method"),
215
+ paymentTarget: yup2.object().when("paymentMethod", (paymentMethod, schema) => {
216
+ const isBankTransfer = paymentMethod.includes(
217
+ "bank_transfer" /* BANK_TRANSFER */
218
+ );
219
+ if (!isBankTransfer) {
220
+ return schema.shape({
221
+ accountHolderName: yup2.string().notRequired(),
222
+ accountNumber: yup2.string().notRequired(),
223
+ link: yup2.string().trim().required("Link is required for PayPal/Stripe")
224
+ });
225
+ } else if (isBankTransfer) {
226
+ return schema.shape({
227
+ accountHolderName: yup2.string().trim().required("Account holder name is required for bank transfer"),
228
+ accountNumber: yup2.string().trim().required("Account number is required for bank transfer").matches(
229
+ nzBankAccountRegex,
230
+ "Account number must be in format: XX-XXXX-XXXXXXX-XX"
231
+ ),
232
+ link: yup2.string().notRequired()
233
+ });
234
+ } else {
235
+ return schema.shape({
236
+ accountHolderName: yup2.string().notRequired(),
237
+ accountNumber: yup2.string().notRequired(),
238
+ link: yup2.string().notRequired()
239
+ });
240
+ }
241
+ }),
242
+ rejectionPolicy: yup2.mixed().oneOf(Object.values(EnumRejectionPolicy)).required("Rejection policy is required"),
243
+ 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"))
244
+ }),
245
+ tags: yup2.array().of(yup2.string().defined()).nullable()
246
+ });
247
+
248
+ // src/yupSchema/stallholder.ts
249
+ import * as yup3 from "yup";
250
+ var stallHolderSchema = globalResourceSchema.shape({
251
+ categories: yup3.array().of(
252
+ yup3.object().shape({
253
+ id: yup3.string().required("Category id is required"),
254
+ name: yup3.string().required("Category name is required"),
255
+ subcategories: yup3.array().of(
256
+ yup3.object().shape({
257
+ id: yup3.string().defined(),
258
+ items: yup3.array().of(yup3.string().defined()).nullable(),
259
+ name: yup3.string().defined()
260
+ })
261
+ ).nullable()
262
+ })
263
+ ).min(1, "Category list must contain at least one item").required("Categories are required"),
264
+ multiLocation: yup3.boolean().required("Multi location is required"),
265
+ products: yup3.array().of(yup3.string().defined()).min(1, "Product list must contain at least one item").required("Products are required")
266
+ });
267
+ var stallholderApplyFormSchema = yup3.object().shape({
268
+ active: yup3.boolean().required("Active is required"),
269
+ electricity: yup3.object().shape({
270
+ details: yup3.string().trim().test("details-required", "Please add details", function(value) {
271
+ return !this.parent?.isRequired || (value?.trim().length ?? 0) > 0;
272
+ }).nullable(),
273
+ isRequired: yup3.boolean().required("Electricity requirement is required")
274
+ }),
275
+ foodSafetyGradeFiles: yup3.array().of(yup3.string().defined()).nullable(),
276
+ foodSafetyGradeFilesUpload: yup3.array().of(yup3.string().defined()).nullable(),
277
+ gazebo: yup3.object().shape({
278
+ details: yup3.string().trim().test("details-required", "Please add details", function(value) {
279
+ return !this.parent?.isRequired || (value?.trim().length ?? 0) > 0;
280
+ }).nullable(),
281
+ isRequired: yup3.boolean().required("Gazebo requirement is required")
282
+ }),
283
+ packaging: yup3.array().of(yup3.string().defined()).min(1, "Packaging list must contain at least one item").required("Packaging is required"),
284
+ paymentMethod: yup3.mixed().oneOf(Object.values(EnumPaymentMethod)).required("Please select a Payment method"),
285
+ priceRange: yup3.object().shape({
286
+ max: yup3.number().min(1).required("Max price is required").test(
287
+ "is-greater",
288
+ "Max price must be greater than or equal to Min price",
289
+ function(max) {
290
+ const { min } = this.parent;
291
+ return max >= min;
292
+ }
293
+ ),
294
+ min: yup3.number().min(1).required("Min price is required")
295
+ }),
296
+ producedIn: yup3.array().of(yup3.string().defined()).min(1, "Produced in list must contain at least one item").required("Produced in is required"),
297
+ stallSize: yup3.object().shape({
298
+ depth: yup3.number().min(1).required("Depth is required"),
299
+ width: yup3.number().min(1).required("Width is required")
300
+ }),
301
+ table: yup3.object().shape({
302
+ details: yup3.string().trim().test("details-required", "Please add details", function(value) {
303
+ return !this.parent?.isRequired || (value?.trim().length ?? 0) > 0;
304
+ }).nullable(),
305
+ isRequired: yup3.boolean().required("Table requirement is required")
306
+ })
307
+ });
308
+
309
+ // src/yupSchema/user.ts
310
+ import * as yup4 from "yup";
311
+ var userSchema = yup4.object().shape({
312
+ active: yup4.boolean().required("Active is required"),
313
+ email: emailSchema,
314
+ firstName: yup4.string().required("First name is required"),
315
+ lastName: yup4.string().required("Last name is required"),
316
+ password: passwordSchema,
317
+ preferredRegion: yup4.string().required("Preferred region is required"),
318
+ // eslint-disable-next-line sort-keys
319
+ confirmPassword: yup4.string().oneOf([yup4.ref("password")], "Passwords must match").required("Confirm Password is required"),
320
+ role: yup4.mixed().oneOf(Object.values(EnumUserRole)).required("Role is required")
321
+ });
322
+
323
+ // src/yupSchema/auth.ts
324
+ import * as yup5 from "yup";
325
+ var loginSchema = yup5.object().shape({
326
+ email: emailSchema,
327
+ password: passwordSchema
328
+ });
329
+ var registerSchema = yup5.object().shape({
330
+ email: emailSchema,
331
+ firstName: yup5.string().required("First Name is required"),
332
+ lastName: yup5.string().required("Last Name is required"),
333
+ password: passwordSchema,
334
+ preferredRegion: yup5.string().required("Preferred Region is required"),
335
+ role: yup5.mixed().oneOf(Object.values(EnumUserRole)).required("Role is required")
336
+ });
337
+ var requestPasswordResetSchema = yup5.object().shape({
338
+ email: emailSchema
339
+ });
340
+ var resetPasswordSchema = yup5.object().shape({
341
+ email: emailSchema,
342
+ password: passwordSchema,
343
+ // eslint-disable-next-line sort-keys
344
+ confirmPassword: yup5.string().oneOf([yup5.ref("password")], "Passwords must match").required("Confirm Password is required")
345
+ });
346
+ var validateTokenSchema = yup5.object().shape({
347
+ email: emailSchema,
348
+ token: yup5.string().required("Verification code is required").matches(/^\d{5}$/, "Verification code must be exactly 5 digits")
349
+ });
350
+
351
+ // src/hooks/utils.ts
352
+ var globalDefaultValues = {
353
+ active: false,
354
+ cover: {
355
+ source: "",
356
+ title: ""
357
+ },
358
+ coverUpload: {
359
+ source: "",
360
+ title: ""
361
+ },
362
+ 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.",
363
+ images: null,
364
+ imagesUpload: null,
365
+ logo: null,
366
+ logoUpload: null,
367
+ name: "Resource name",
368
+ promoCode: "",
369
+ region: ""
370
+ };
371
+ var defaultMarketFormValues = {
372
+ ...globalDefaultValues,
373
+ dateTime: [
374
+ {
375
+ endDate: "04-05-2025",
376
+ endTime: "15:00",
377
+ marketPrice: 0,
378
+ startDate: "04-05-2025",
379
+ startTime: "09:00"
380
+ },
381
+ {
382
+ endDate: "05-05-2025",
383
+ endTime: "15:00",
384
+ marketPrice: 0,
385
+ startDate: "05-05-2025",
386
+ startTime: "09:00"
387
+ }
388
+ ],
389
+ location: {
390
+ city: "",
391
+ coordinates: [0, 0],
392
+ // [longitude, latitude]
393
+ country: "",
394
+ fullAddress: "",
395
+ latitude: 0,
396
+ longitude: 0,
397
+ region: "",
398
+ type: "Point"
399
+ // Default type for GeoJSON
400
+ },
401
+ provider: "Provider name",
402
+ stallApplicationInfo: {
403
+ applicationDeadlineHours: 0,
404
+ paymentDueHours: 0,
405
+ paymentMethod: "",
406
+ paymentTarget: {
407
+ accountHolderName: "",
408
+ accountNumber: "",
409
+ link: ""
410
+ },
411
+ rejectionPolicy: "multi_date_allowed" /* MULTI_DATE_ALLOWED */,
412
+ stallCapacity: 0
413
+ },
414
+ tags: null
415
+ };
416
+ var defaultStallholderFormValues = {
417
+ ...globalDefaultValues,
418
+ categories: [],
419
+ locations: null,
420
+ multiLocation: false,
421
+ products: ["Prod uct 1", "Product 2"],
422
+ specialities: null
423
+ };
424
+ var defaultStallholderApplyFormValues = {
425
+ active: false,
426
+ electricity: { details: null, isRequired: false },
427
+ foodSafetyGradeFiles: null,
428
+ foodSafetyGradeFilesUpload: null,
429
+ gazebo: { details: null, isRequired: false },
430
+ packaging: [],
431
+ paymentMethod: "",
432
+ priceRange: { max: 0, min: 0 },
433
+ producedIn: [],
434
+ stallSize: { depth: 0, width: 0 },
435
+ table: { details: null, isRequired: false }
436
+ };
437
+
438
+ // src/hooks/stallholder/useStallholderForm.ts
439
+ function useStallholderForm(data) {
440
+ const {
441
+ control,
442
+ formState: { errors },
443
+ getValues,
444
+ handleSubmit,
445
+ reset,
446
+ setValue,
447
+ watch
448
+ } = useForm({
449
+ defaultValues: defaultStallholderFormValues,
450
+ resolver: yupResolver(stallHolderSchema)
451
+ });
452
+ React.useEffect(() => {
453
+ if (data) {
454
+ reset({
455
+ _id: data._id,
456
+ active: data.active,
457
+ categories: data.categories,
458
+ cover: data.cover,
459
+ coverUpload: data.coverUpload,
460
+ description: data.description,
461
+ images: data.images,
462
+ imagesUpload: data.imagesUpload,
463
+ locations: data.locations,
464
+ logo: data.logo,
465
+ logoUpload: data.logoUpload,
466
+ multiLocation: data.multiLocation,
467
+ name: data.name,
468
+ products: data.products,
469
+ promoCode: data.promoCode,
470
+ region: data.region,
471
+ specialities: data.specialities
472
+ });
473
+ } else {
474
+ reset(defaultStallholderFormValues);
475
+ }
476
+ }, [data]);
477
+ const {
478
+ _id,
479
+ active,
480
+ categories,
481
+ cover,
482
+ coverUpload,
483
+ description,
484
+ images,
485
+ imagesUpload,
486
+ locations,
487
+ logo,
488
+ logoUpload,
489
+ multiLocation,
490
+ name,
491
+ products,
492
+ promoCode,
493
+ region,
494
+ specialities
495
+ } = getValues();
496
+ return {
497
+ control,
498
+ fields: {
499
+ _id,
500
+ active,
501
+ categories,
502
+ cover,
503
+ coverUpload,
504
+ description,
505
+ images,
506
+ imagesUpload,
507
+ locations,
508
+ logo,
509
+ logoUpload,
510
+ multiLocation,
511
+ name,
512
+ products,
513
+ promoCode,
514
+ region,
515
+ specialities
516
+ },
517
+ formState: { errors },
518
+ handleSubmit,
519
+ reset,
520
+ setValue,
521
+ watch
522
+ };
523
+ }
524
+
525
+ // src/hooks/stallholder/useStallholderApplyForm.ts
526
+ import { yupResolver as yupResolver2 } from "@hookform/resolvers/yup";
527
+ import * as React2 from "react";
528
+ import { useForm as useForm2 } from "react-hook-form";
529
+ function useStallholderApplyForm(data) {
530
+ const {
531
+ control,
532
+ formState: { errors },
533
+ getValues,
534
+ handleSubmit,
535
+ reset,
536
+ setValue,
537
+ watch
538
+ } = useForm2({
539
+ defaultValues: defaultStallholderApplyFormValues,
540
+ resolver: yupResolver2(stallholderApplyFormSchema)
541
+ });
542
+ React2.useEffect(() => {
543
+ if (data) {
544
+ reset({
545
+ _id: data._id,
546
+ active: data.active,
547
+ electricity: data.electricity,
548
+ foodSafetyGradeFiles: data.foodSafetyGradeFiles,
549
+ foodSafetyGradeFilesUpload: data.foodSafetyGradeFilesUpload,
550
+ gazebo: data.gazebo,
551
+ packaging: data.packaging,
552
+ paymentMethod: data.paymentMethod,
553
+ priceRange: data.priceRange,
554
+ producedIn: data.producedIn,
555
+ stallSize: data.stallSize,
556
+ table: data.table
557
+ });
558
+ } else {
559
+ reset(defaultStallholderApplyFormValues);
560
+ }
561
+ }, [data]);
562
+ const {
563
+ _id,
564
+ active,
565
+ electricity,
566
+ foodSafetyGradeFiles,
567
+ foodSafetyGradeFilesUpload,
568
+ gazebo,
569
+ packaging,
570
+ paymentMethod,
571
+ priceRange,
572
+ producedIn,
573
+ stallSize,
574
+ table
575
+ } = getValues();
576
+ return {
577
+ control,
578
+ fields: {
579
+ _id,
580
+ active,
581
+ electricity,
582
+ foodSafetyGradeFiles,
583
+ foodSafetyGradeFilesUpload,
584
+ gazebo,
585
+ packaging,
586
+ paymentMethod,
587
+ priceRange,
588
+ producedIn,
589
+ stallSize,
590
+ table
591
+ },
592
+ formState: { errors },
593
+ handleSubmit,
594
+ reset,
595
+ setValue,
596
+ watch
597
+ };
598
+ }
599
+
600
+ // src/hooks/useMarketForm.ts
601
+ import { yupResolver as yupResolver3 } from "@hookform/resolvers/yup";
602
+ import * as React3 from "react";
603
+ import { useForm as useForm3 } from "react-hook-form";
604
+ function useMarketForm(data) {
605
+ const {
606
+ control,
607
+ formState: { errors },
608
+ getValues,
609
+ handleSubmit,
610
+ reset,
611
+ setValue,
612
+ watch
613
+ } = useForm3({
614
+ defaultValues: defaultMarketFormValues,
615
+ resolver: yupResolver3(marketSchema)
616
+ });
617
+ React3.useEffect(() => {
618
+ if (data) {
619
+ reset({
620
+ _id: data._id,
621
+ active: data.active,
622
+ cover: data.cover,
623
+ coverUpload: data.coverUpload,
624
+ dateTime: data.dateTime,
625
+ description: data.description,
626
+ images: data.images,
627
+ imagesUpload: data.imagesUpload,
628
+ location: data.location,
629
+ logo: data.logo,
630
+ logoUpload: data.logoUpload,
631
+ name: data.name,
632
+ promoCode: data.promoCode,
633
+ provider: data.provider,
634
+ region: data.region,
635
+ stallApplicationInfo: data.stallApplicationInfo,
636
+ tags: data.tags
637
+ });
638
+ } else {
639
+ reset(defaultMarketFormValues);
640
+ }
641
+ }, [data]);
642
+ const {
643
+ _id,
644
+ active,
645
+ cover,
646
+ coverUpload,
647
+ dateTime,
648
+ description,
649
+ images,
650
+ imagesUpload,
651
+ location,
652
+ logo,
653
+ logoUpload,
654
+ name,
655
+ provider,
656
+ region,
657
+ stallApplicationInfo,
658
+ tags
659
+ } = getValues();
660
+ return {
661
+ control,
662
+ fields: {
663
+ _id,
664
+ active,
665
+ cover,
666
+ coverUpload,
667
+ dateTime,
668
+ description,
669
+ images,
670
+ imagesUpload,
671
+ location,
672
+ logo,
673
+ logoUpload,
674
+ name,
675
+ provider,
676
+ region,
677
+ stallApplicationInfo,
678
+ tags
679
+ },
680
+ formState: { errors },
681
+ handleSubmit,
682
+ reset,
683
+ setValue,
684
+ watch
685
+ };
686
+ }
687
+
688
+ // src/hooks/useUserForm.ts
689
+ import { yupResolver as yupResolver4 } from "@hookform/resolvers/yup";
690
+ import * as React4 from "react";
691
+ import { useForm as useForm4 } from "react-hook-form";
692
+ var defaultValues = {
693
+ active: false,
694
+ avatar: null,
695
+ avatarUpload: null,
696
+ confirmPassword: "",
697
+ email: "",
698
+ firstName: "",
699
+ lastName: "",
700
+ password: "",
701
+ preferredRegion: "",
702
+ role: "customer" /* CUSTOMER */
703
+ };
704
+ function useUserForm(data) {
705
+ const {
706
+ control,
707
+ formState: { errors },
708
+ getValues,
709
+ handleSubmit,
710
+ reset,
711
+ setValue,
712
+ watch
713
+ } = useForm4({
714
+ defaultValues,
715
+ resolver: yupResolver4(userSchema)
716
+ });
717
+ React4.useEffect(() => {
718
+ if (data) {
719
+ reset({
720
+ _id: data._id,
721
+ active: data.active,
722
+ avatar: data.avatar,
723
+ avatarUpload: data.avatarUpload,
724
+ confirmPassword: data.confirmPassword,
725
+ email: data.email,
726
+ firstName: data.firstName,
727
+ lastName: data.lastName,
728
+ password: data.password,
729
+ preferredRegion: data.preferredRegion,
730
+ role: data.role
731
+ });
732
+ } else {
733
+ reset(defaultValues);
734
+ }
735
+ }, [data]);
736
+ const {
737
+ _id,
738
+ active,
739
+ avatar,
740
+ avatarUpload,
741
+ confirmPassword,
742
+ email,
743
+ firstName,
744
+ lastName,
745
+ password,
746
+ preferredRegion,
747
+ role
748
+ } = getValues();
749
+ return {
750
+ control,
751
+ fields: {
752
+ _id,
753
+ active,
754
+ avatar,
755
+ avatarUpload,
756
+ confirmPassword,
757
+ email,
758
+ firstName,
759
+ lastName,
760
+ password,
761
+ preferredRegion,
762
+ role
763
+ },
764
+ formState: { errors },
765
+ handleSubmit,
766
+ reset,
767
+ setValue,
768
+ watch
769
+ };
770
+ }
771
+
772
+ // src/hooks/auth/useLoginForm.ts
773
+ import { yupResolver as yupResolver5 } from "@hookform/resolvers/yup";
774
+ import { useForm as useForm5 } from "react-hook-form";
775
+ var defaultValues2 = {
776
+ email: "",
777
+ password: ""
778
+ };
779
+ function useLoginForm() {
780
+ const {
781
+ control,
782
+ formState: { errors },
783
+ getValues,
784
+ handleSubmit,
785
+ reset,
786
+ setValue,
787
+ watch
788
+ } = useForm5({
789
+ defaultValues: defaultValues2,
790
+ resolver: yupResolver5(loginSchema)
791
+ });
792
+ const { email, password } = getValues();
793
+ return {
794
+ control,
795
+ fields: {
796
+ email,
797
+ password
798
+ },
799
+ formState: { errors },
800
+ handleSubmit,
801
+ reset,
802
+ setValue,
803
+ watch
804
+ };
805
+ }
806
+
807
+ // src/hooks/auth/useRegisterForm.ts
808
+ import { yupResolver as yupResolver6 } from "@hookform/resolvers/yup";
809
+ import { useForm as useForm6 } from "react-hook-form";
810
+ var defaultValues3 = {
811
+ email: "",
812
+ firstName: "",
813
+ lastName: "",
814
+ password: "",
815
+ preferredRegion: "",
816
+ role: "customer" /* CUSTOMER */
817
+ };
818
+ function useRegisterForm() {
819
+ const {
820
+ control,
821
+ formState: { errors },
822
+ getValues,
823
+ handleSubmit,
824
+ reset,
825
+ setValue,
826
+ watch
827
+ } = useForm6({
828
+ defaultValues: defaultValues3,
829
+ resolver: yupResolver6(registerSchema)
830
+ });
831
+ const { email, firstName, lastName, password, preferredRegion, role } = getValues();
832
+ return {
833
+ control,
834
+ fields: {
835
+ email,
836
+ firstName,
837
+ lastName,
838
+ password,
839
+ preferredRegion,
840
+ role
841
+ },
842
+ formState: { errors },
843
+ handleSubmit,
844
+ reset,
845
+ setValue,
846
+ watch
847
+ };
848
+ }
849
+
850
+ // src/hooks/auth/useRequestPasswordResetForm.ts
851
+ import { yupResolver as yupResolver7 } from "@hookform/resolvers/yup";
852
+ import { useForm as useForm7 } from "react-hook-form";
853
+ var defaultValues4 = {
854
+ email: ""
855
+ };
856
+ function useRequestPasswordResetForm() {
857
+ const {
858
+ control,
859
+ formState: { errors },
860
+ getValues,
861
+ handleSubmit,
862
+ reset,
863
+ setValue,
864
+ watch
865
+ } = useForm7({
866
+ defaultValues: defaultValues4,
867
+ resolver: yupResolver7(requestPasswordResetSchema)
868
+ });
869
+ const { email } = getValues();
870
+ return {
871
+ control,
872
+ fields: {
873
+ email
874
+ },
875
+ formState: { errors },
876
+ handleSubmit,
877
+ reset,
878
+ setValue,
879
+ watch
880
+ };
881
+ }
882
+
883
+ // src/hooks/auth/useValidateTokenForm.ts
884
+ import { yupResolver as yupResolver8 } from "@hookform/resolvers/yup";
885
+ import { useForm as useForm8 } from "react-hook-form";
886
+ var defaultValues5 = {
887
+ email: "",
888
+ token: ""
889
+ };
890
+ function useValidateTokenForm() {
891
+ const {
892
+ control,
893
+ formState: { errors },
894
+ getValues,
895
+ handleSubmit,
896
+ reset,
897
+ setValue,
898
+ watch
899
+ } = useForm8({
900
+ defaultValues: defaultValues5,
901
+ resolver: yupResolver8(validateTokenSchema)
902
+ });
903
+ const { email, token } = getValues();
904
+ return {
905
+ control,
906
+ fields: {
907
+ email,
908
+ token
909
+ },
910
+ formState: { errors },
911
+ handleSubmit,
912
+ reset,
913
+ setValue,
914
+ watch
915
+ };
916
+ }
917
+
918
+ // src/hooks/auth/useResetPasswordForm.ts
919
+ import { yupResolver as yupResolver9 } from "@hookform/resolvers/yup";
920
+ import { useForm as useForm9 } from "react-hook-form";
921
+ var defaultValues6 = {
922
+ confirmPassword: "",
923
+ email: "",
924
+ password: ""
925
+ };
926
+ function useResetPasswordForm() {
927
+ const {
928
+ control,
929
+ formState: { errors },
930
+ getValues,
931
+ handleSubmit,
932
+ reset,
933
+ setValue,
934
+ watch
935
+ } = useForm9({
936
+ defaultValues: defaultValues6,
937
+ resolver: yupResolver9(resetPasswordSchema)
938
+ });
939
+ const { confirmPassword, email, password } = getValues();
940
+ return {
941
+ control,
942
+ fields: {
943
+ confirmPassword,
944
+ email,
945
+ password
946
+ },
947
+ formState: { errors },
948
+ handleSubmit,
949
+ reset,
950
+ setValue,
951
+ watch
952
+ };
953
+ }
954
+ export {
955
+ defaultMarketFormValues,
956
+ defaultStallholderApplyFormValues,
957
+ defaultStallholderFormValues,
958
+ globalDefaultValues,
959
+ useLocationSearch,
960
+ useLoginForm,
961
+ useMarketForm,
962
+ useRegisterForm,
963
+ useRequestPasswordResetForm,
964
+ useResetPasswordForm,
965
+ useStallholderApplyForm,
966
+ useStallholderForm,
967
+ useUserForm,
968
+ useValidateTokenForm
969
+ };
970
+ //# sourceMappingURL=index.mjs.map