@timardex/cluemart-shared 1.4.26 → 1.4.28
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-S6G7DNEV.mjs → chunk-XUYZ2LYW.mjs} +6 -10
- package/dist/chunk-XUYZ2LYW.mjs.map +1 -0
- package/dist/formFields/index.cjs +32 -0
- package/dist/formFields/index.cjs.map +1 -1
- package/dist/formFields/index.d.mts +3 -1
- package/dist/formFields/index.d.ts +3 -1
- package/dist/formFields/index.mjs +31 -1
- 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/index.cjs +38 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.mjs +34 -8
- package/dist/index.mjs.map +1 -1
- package/dist/utils/index.cjs +6 -9
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.mts +4 -3
- package/dist/utils/index.d.ts +4 -3
- package/dist/utils/index.mjs +5 -3
- package/package.json +1 -1
- package/dist/chunk-S6G7DNEV.mjs.map +0 -1
|
@@ -59,13 +59,6 @@ var formatTimestamp = (timestamp) => {
|
|
|
59
59
|
const formattedTime = dayjs(timestamp).tz("Pacific/Auckland").format(timeFormat);
|
|
60
60
|
return formatDate(formattedDate, "date");
|
|
61
61
|
};
|
|
62
|
-
var defaultRegion = {
|
|
63
|
-
latitude: -36.8624942,
|
|
64
|
-
// Default: New Zealand
|
|
65
|
-
latitudeDelta: 5,
|
|
66
|
-
longitude: 174.7450494,
|
|
67
|
-
longitudeDelta: 5
|
|
68
|
-
};
|
|
69
62
|
var isIsoDateString = (value) => {
|
|
70
63
|
return typeof value === "string" && !isNaN(Date.parse(value));
|
|
71
64
|
};
|
|
@@ -157,6 +150,8 @@ var cluemartSocialMedia = [
|
|
|
157
150
|
name: "youtube" /* YOUTUBE */
|
|
158
151
|
}
|
|
159
152
|
];
|
|
153
|
+
var IOS_URL = "https://apps.apple.com/nz/app/cluemart/id6747251008";
|
|
154
|
+
var ANDROID_URL = "https://play.google.com/store/apps/details?id=com.timardex.cluemart";
|
|
160
155
|
|
|
161
156
|
export {
|
|
162
157
|
dateFormat,
|
|
@@ -166,7 +161,6 @@ export {
|
|
|
166
161
|
getCurrentAndFutureDates,
|
|
167
162
|
isFutureDatesBeforeThreshold,
|
|
168
163
|
formatTimestamp,
|
|
169
|
-
defaultRegion,
|
|
170
164
|
removeTypename,
|
|
171
165
|
truncateText,
|
|
172
166
|
mapArrayToOptions,
|
|
@@ -178,6 +172,8 @@ export {
|
|
|
178
172
|
paymentMethodOptions,
|
|
179
173
|
normalizeUrl,
|
|
180
174
|
licenseNiceNames,
|
|
181
|
-
cluemartSocialMedia
|
|
175
|
+
cluemartSocialMedia,
|
|
176
|
+
IOS_URL,
|
|
177
|
+
ANDROID_URL
|
|
182
178
|
};
|
|
183
|
-
//# sourceMappingURL=chunk-
|
|
179
|
+
//# sourceMappingURL=chunk-XUYZ2LYW.mjs.map
|
|
@@ -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, 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,OAAO,cAAc;AACrB,OAAO,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F;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,6 +37,7 @@ __export(formFields_exports, {
|
|
|
37
37
|
contactUsFields: () => contactUsFields,
|
|
38
38
|
emailField: () => emailField,
|
|
39
39
|
eventBasicInfoFields: () => eventBasicInfoFields,
|
|
40
|
+
eventCancellationOptions: () => eventCancellationOptions,
|
|
40
41
|
eventEndDateFields: () => eventEndDateFields,
|
|
41
42
|
eventInfo: () => eventInfo,
|
|
42
43
|
eventInfoPaymentInfo: () => eventInfoPaymentInfo,
|
|
@@ -54,6 +55,7 @@ __export(formFields_exports, {
|
|
|
54
55
|
resetPasswordFields: () => resetPasswordFields,
|
|
55
56
|
socialMediaFields: () => socialMediaFields,
|
|
56
57
|
stallTypeOptions: () => stallTypeOptions,
|
|
58
|
+
stallholderCancellationOptions: () => stallholderCancellationOptions,
|
|
57
59
|
tagOptions: () => tagOptions,
|
|
58
60
|
testersFields: () => testersFields,
|
|
59
61
|
validateVerificationTokenFields: () => validateVerificationTokenFields,
|
|
@@ -779,6 +781,34 @@ var stallTypeOptions = stallTypes.map((type) => ({
|
|
|
779
781
|
price: 0,
|
|
780
782
|
stallCapacity: 0
|
|
781
783
|
}));
|
|
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
|
+
];
|
|
782
812
|
|
|
783
813
|
// src/formFields/global.ts
|
|
784
814
|
var emailField = {
|
|
@@ -2037,6 +2067,7 @@ var partnerBasicInfoFields = [
|
|
|
2037
2067
|
contactUsFields,
|
|
2038
2068
|
emailField,
|
|
2039
2069
|
eventBasicInfoFields,
|
|
2070
|
+
eventCancellationOptions,
|
|
2040
2071
|
eventEndDateFields,
|
|
2041
2072
|
eventInfo,
|
|
2042
2073
|
eventInfoPaymentInfo,
|
|
@@ -2054,6 +2085,7 @@ var partnerBasicInfoFields = [
|
|
|
2054
2085
|
resetPasswordFields,
|
|
2055
2086
|
socialMediaFields,
|
|
2056
2087
|
stallTypeOptions,
|
|
2088
|
+
stallholderCancellationOptions,
|
|
2057
2089
|
tagOptions,
|
|
2058
2090
|
testersFields,
|
|
2059
2091
|
validateVerificationTokenFields,
|