@timardex/cluemart-shared 1.4.29 → 1.4.30
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/{chunk-XUYZ2LYW.mjs → chunk-Z4W6CSYI.mjs} +1 -1
- package/dist/chunk-Z4W6CSYI.mjs.map +1 -0
- package/dist/formFields/index.cjs +0 -32
- package/dist/formFields/index.cjs.map +1 -1
- package/dist/formFields/index.d.mts +1 -3
- package/dist/formFields/index.d.ts +1 -3
- package/dist/formFields/index.mjs +1 -31
- package/dist/formFields/index.mjs.map +1 -1
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.cjs +0 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.mjs +0 -30
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-XUYZ2LYW.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/index.ts"],"sourcesContent":["import dayjs from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat.js\";\nimport isSameOrAfter from \"dayjs/plugin/isSameOrAfter.js\";\nimport timezone from \"dayjs/plugin/timezone.js\";\nimport utc from \"dayjs/plugin/utc.js\";\n\nimport {\n EnumInviteStatus,\n EnumPaymentMethod,\n EnumRegions,\n EnumSocialMedia,\n EnumUserLicence,\n} from \"../enums\";\nimport { OptionItem, Region, SocialMediaType } from \"../types/global\";\n\nexport const dateFormat = \"DD-MM-YYYY\";\nexport const timeFormat = \"HH:mm\";\n\n// Enable custom format parsing\ndayjs.extend(customParseFormat);\ndayjs.extend(utc);\ndayjs.extend(timezone);\ndayjs.extend(isSameOrAfter);\n\nconst NZ_TZ = \"Pacific/Auckland\";\n\nexport function toNZTime(date: Date | string) {\n return dayjs(date).tz(NZ_TZ).format();\n}\n\ntype DateFormat = \"date\" | \"time\" | \"datetime\";\n\n/**\n * Format a date string to a more readable format.\n * @param dateStr - the date string\n * @param timeStr - optional time string\n * @param display - 'date' | 'time' | 'datetime'\n * @returns formatted string based on display option\n */\nexport const formatDate = (\n dateStr: string,\n display: DateFormat = \"datetime\",\n timeStr?: string,\n) => {\n // Combine date and time into a single string if time is provided\n const dateTimeStr = timeStr ? `${dateStr} ${timeStr}` : dateStr;\n\n // Parse with formats\n const dateTime = timeStr\n ? dayjs(dateTimeStr, `${dateFormat} ${timeFormat}`)\n : dayjs(dateStr, dateFormat);\n\n // Format parts\n const formattedDate = dateTime.format(\"dddd, D MMMM, YYYY\");\n const formattedTime = dateTime.format(\"h:mm a\");\n\n // Return based on display option\n switch (display) {\n case \"date\":\n return formattedDate;\n case \"time\":\n return formattedTime;\n case \"datetime\":\n return `${formattedDate} at ${formattedTime}`;\n default:\n return formattedDate;\n }\n};\n\nexport const getCurrentAndFutureDates = <\n T extends { startDate: string; startTime: string },\n>(\n dates: T[],\n): T[] => {\n const now = dayjs(); // current date and time\n\n return dates.filter((dateObj) => {\n const dateTime = dayjs(\n `${dateObj.startDate} ${dateObj.startTime}`,\n `${dateFormat} ${timeFormat}`,\n );\n return dateTime.isSameOrAfter(now);\n });\n};\n\nexport const isFutureDatesBeforeThreshold = (\n date: {\n startDate: string;\n startTime: string;\n },\n minHoursFromNow: number,\n): boolean => {\n const threshold = minHoursFromNow\n ? dayjs().add(minHoursFromNow, \"hour\")\n : dayjs().startOf(\"day\");\n\n const dateTime = dayjs(\n `${date.startDate} ${date.startTime}`,\n `${dateFormat} ${timeFormat}`,\n );\n\n return dateTime.isSameOrAfter(threshold);\n};\n\nexport const formatTimestamp = (timestamp: string) => {\n const formattedDate = dayjs(timestamp)\n .tz(\"Pacific/Auckland\")\n .format(dateFormat);\n\n const formattedTime = dayjs(timestamp)\n .tz(\"Pacific/Auckland\")\n .format(timeFormat);\n\n return formatDate(formattedDate, \"date\");\n};\n\nconst isIsoDateString = (value: unknown): value is string => {\n return typeof value === \"string\" && !isNaN(Date.parse(value));\n};\n\nexport const removeTypename = (obj: any): any => {\n // Preserve Date objects\n if (obj instanceof Date) {\n return obj;\n }\n\n // Preserve File objects (for apollo-upload-client)\n if (obj instanceof File) {\n return obj;\n }\n\n // Preserve ISO date strings\n if (isIsoDateString(obj)) {\n return obj;\n }\n\n // Handle arrays\n if (Array.isArray(obj)) {\n return obj.map(removeTypename);\n }\n\n // Handle plain objects only\n if (obj !== null && typeof obj === \"object\") {\n const { __typename, ...cleanedObj } = obj;\n\n return Object.keys(cleanedObj).reduce((acc: any, key) => {\n acc[key] = removeTypename(cleanedObj[key]);\n return acc;\n }, {});\n }\n\n // Primitives\n return obj;\n};\n\n/**\n * Truncate text to a specified length and append ellipsis if necessary.\n * @param text\n * @param maxLength\n * @returns\n */\nexport const truncateText = (text: string, maxLength: number = 30): string => {\n return text.length > maxLength ? text.substring(0, maxLength) + \"...\" : text;\n};\n\n/**\n * Convert an array of strings to an array of objects with label and value properties.\n * @param items - The array of strings to convert.\n * @returns - The converted array of objects.\n */\nexport const mapArrayToOptions = (items: string[]): OptionItem[] =>\n items.map((item) => ({\n label: item,\n value: item,\n }));\n\nexport const capitalizeFirstLetter = (str: string): string => {\n return str\n .split(\" \")\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\" \");\n};\n\nexport const statusOptions = [\n ...Object.values(EnumInviteStatus)\n .map((status) => ({\n label: status,\n value: status,\n }))\n .sort((a, b) => a.label.localeCompare(b.label)), // Sort the options alphabetically\n];\n\n/**\n * Sort an array of date strings by their proximity to the current date.\n * @param dates - The array of date strings to sort.\n * @returns - The sorted array of date strings.\n */\nexport function sortDatesChronologically<\n T extends { startDate: string; startTime: string },\n>(dates: T[]): T[] {\n if (!dates || !dates.length) {\n return [];\n }\n\n return [...dates].sort((a, b) => {\n const dateTimeFormat = `${dateFormat} ${timeFormat}`;\n const dateA = dayjs(`${a.startDate} ${a.startTime}`, dateTimeFormat);\n const dateB = dayjs(`${b.startDate} ${b.startTime}`, dateTimeFormat);\n return dateA.valueOf() - dateB.valueOf(); // chronological order\n });\n}\n\nexport const availableRegionTypes = Object.values(EnumRegions);\nexport const availableRegionOptions: OptionItem[] =\n mapArrayToOptions(availableRegionTypes);\n\nexport const paymentMethodOptions: OptionItem[] = mapArrayToOptions(\n Object.values(EnumPaymentMethod),\n);\n\nexport function normalizeUrl(url: string): string {\n if (!url.startsWith(\"http://\") && !url.startsWith(\"https://\")) {\n return `https://${url}`;\n }\n return url;\n}\n\nexport const licenseNiceNames: Record<EnumUserLicence, string> = {\n [EnumUserLicence.PRO_EVENT]: \"Pro Event\",\n [EnumUserLicence.PRO_VENDOR]: \"Pro Stallholder\",\n [EnumUserLicence.STANDARD_EVENT]: \"Standard Event\",\n [EnumUserLicence.STANDARD_VENDOR]: \"Standard Stallholder\",\n [EnumUserLicence.PRO_PLUS_EVENT]: \"Pro+ Event\",\n [EnumUserLicence.PRO_PLUS_VENDOR]: \"Pro+ Stallholder\",\n [EnumUserLicence.STANDARD_PARTNER]: \"Partner\",\n};\n\nexport const cluemartSocialMedia: SocialMediaType[] = [\n {\n link: \"https://www.facebook.com/ClueMartApp\",\n name: EnumSocialMedia.FACEBOOK,\n },\n {\n link: \"https://www.instagram.com/cluemart_app\",\n name: EnumSocialMedia.INSTAGRAM,\n },\n {\n link: \"https://www.tiktok.com/@cluemart\",\n name: EnumSocialMedia.TIKTOK,\n },\n {\n link: \"https://www.youtube.com/@ClueMart-App-NZ\",\n name: EnumSocialMedia.YOUTUBE,\n },\n];\n\nexport const IOS_URL = \"https://apps.apple.com/nz/app/cluemart/id6747251008\";\nexport const ANDROID_URL =\n \"https://play.google.com/store/apps/details?id=com.timardex.cluemart\";\n"],"mappings":";;;;;;;AAAA,OAAO,WAAW;AAClB,OAAO,uBAAuB;AAC9B,OAAO,mBAAmB;AAC1B,OAA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;AAAA,IACN;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN;AAAA,EACF;AACF;AAEO,IAAM,UAAU;AAChB,IAAM,cACX;","names":[]}
|
|
@@ -37,7 +37,6 @@ __export(formFields_exports, {
|
|
|
37
37
|
contactUsFields: () => contactUsFields,
|
|
38
38
|
emailField: () => emailField,
|
|
39
39
|
eventBasicInfoFields: () => eventBasicInfoFields,
|
|
40
|
-
eventCancellationOptions: () => eventCancellationOptions,
|
|
41
40
|
eventEndDateFields: () => eventEndDateFields,
|
|
42
41
|
eventInfo: () => eventInfo,
|
|
43
42
|
eventInfoPaymentInfo: () => eventInfoPaymentInfo,
|
|
@@ -55,7 +54,6 @@ __export(formFields_exports, {
|
|
|
55
54
|
resetPasswordFields: () => resetPasswordFields,
|
|
56
55
|
socialMediaFields: () => socialMediaFields,
|
|
57
56
|
stallTypeOptions: () => stallTypeOptions,
|
|
58
|
-
stallholderCancellationOptions: () => stallholderCancellationOptions,
|
|
59
57
|
tagOptions: () => tagOptions,
|
|
60
58
|
testersFields: () => testersFields,
|
|
61
59
|
validateVerificationTokenFields: () => validateVerificationTokenFields,
|
|
@@ -781,34 +779,6 @@ var stallTypeOptions = stallTypes.map((type) => ({
|
|
|
781
779
|
price: 0,
|
|
782
780
|
stallCapacity: 0
|
|
783
781
|
}));
|
|
784
|
-
var stallholderCancellationOptions = [
|
|
785
|
-
{
|
|
786
|
-
label: "Full refund if cancelled 30+ days before the event.",
|
|
787
|
-
value: "full_refund_30_days"
|
|
788
|
-
},
|
|
789
|
-
{
|
|
790
|
-
label: "50% refund if cancelled 14\u201329 days before the event.",
|
|
791
|
-
value: "half_refund_14_29_days"
|
|
792
|
-
},
|
|
793
|
-
{
|
|
794
|
-
label: "No refund if cancelled less than 14 days before the event.",
|
|
795
|
-
value: "no_refund_less_than_14_days"
|
|
796
|
-
}
|
|
797
|
-
];
|
|
798
|
-
var eventCancellationOptions = [
|
|
799
|
-
{
|
|
800
|
-
label: "Full refund if the event is cancelled by the organiser.",
|
|
801
|
-
value: "event_full_refund"
|
|
802
|
-
},
|
|
803
|
-
{
|
|
804
|
-
label: "Credit towards a future event if cancelled by the organiser.",
|
|
805
|
-
value: "event_credit_only"
|
|
806
|
-
},
|
|
807
|
-
{
|
|
808
|
-
label: "Refund only in cases of force majeure (e.g., natural disasters, government restrictions).",
|
|
809
|
-
value: "event_force_majeure_only"
|
|
810
|
-
}
|
|
811
|
-
];
|
|
812
782
|
|
|
813
783
|
// src/formFields/global.ts
|
|
814
784
|
var emailField = {
|
|
@@ -2067,7 +2037,6 @@ var partnerBasicInfoFields = [
|
|
|
2067
2037
|
contactUsFields,
|
|
2068
2038
|
emailField,
|
|
2069
2039
|
eventBasicInfoFields,
|
|
2070
|
-
eventCancellationOptions,
|
|
2071
2040
|
eventEndDateFields,
|
|
2072
2041
|
eventInfo,
|
|
2073
2042
|
eventInfoPaymentInfo,
|
|
@@ -2085,7 +2054,6 @@ var partnerBasicInfoFields = [
|
|
|
2085
2054
|
resetPasswordFields,
|
|
2086
2055
|
socialMediaFields,
|
|
2087
2056
|
stallTypeOptions,
|
|
2088
|
-
stallholderCancellationOptions,
|
|
2089
2057
|
tagOptions,
|
|
2090
2058
|
testersFields,
|
|
2091
2059
|
validateVerificationTokenFields,
|