@getmicdrop/svelte-components 5.18.2 → 5.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.css +18 -0
- package/dist/calendar/Calendar/MiniMonthCalendar.svelte +10 -8
- package/dist/calendar/Calendar/MiniMonthCalendar.svelte.d.ts.map +1 -1
- package/dist/components/Heading.svelte +8 -2
- package/dist/components/Heading.svelte.d.ts +1 -0
- package/dist/components/Heading.svelte.d.ts.map +1 -1
- package/dist/components/Text.svelte +13 -2
- package/dist/components/Text.svelte.d.ts +2 -1
- package/dist/components/Text.svelte.d.ts.map +1 -1
- package/dist/constants/formOptions.d.ts +2 -5
- package/dist/constants/formOptions.d.ts.map +1 -1
- package/dist/constants/formOptions.js +6 -6
- package/dist/constants/formOptions.spec.js +2 -7
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -2
- package/dist/patterns/forms/FormSection.svelte +2 -1
- package/dist/patterns/forms/FormSection.svelte.d.ts +2 -0
- package/dist/patterns/forms/FormSection.svelte.d.ts.map +1 -1
- package/dist/patterns/layout/SidebarTestWrapper.svelte.d.ts +1 -1
- package/dist/patterns/navigation/Header.svelte +3 -3
- package/dist/primitives/Input/Select.svelte +1 -1
- package/dist/primitives/Pagination/DotIndicator.svelte +66 -0
- package/dist/primitives/Pagination/DotIndicator.svelte.d.ts +18 -0
- package/dist/primitives/Pagination/DotIndicator.svelte.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +1 -0
- package/dist/primitives/index.js +1 -0
- package/dist/recipes/inputs/phoneInput/CountrySelector.svelte +1 -1
- package/dist/recipes/modals/FeedbackModal.svelte +205 -0
- package/dist/recipes/modals/FeedbackModal.svelte.d.ts +24 -0
- package/dist/recipes/modals/FeedbackModal.svelte.d.ts.map +1 -0
- package/dist/recipes/modals/index.d.ts +1 -0
- package/dist/recipes/modals/index.js +1 -0
- package/dist/schemas/event.d.ts +4 -4
- package/dist/schemas/order.d.ts +2 -2
- package/dist/schemas/promo.d.ts +4 -4
- package/dist/services/event.service.d.ts +11 -0
- package/dist/services/event.service.d.ts.map +1 -0
- package/dist/services/event.service.js +64 -0
- package/dist/services/event.service.spec.d.ts +2 -0
- package/dist/services/event.service.spec.d.ts.map +1 -0
- package/dist/services/event.service.spec.js +168 -0
- package/dist/services/{ShowService.d.ts → show.service.d.ts} +1 -1
- package/dist/services/show.service.d.ts.map +1 -0
- package/dist/services/show.service.js +115 -0
- package/dist/services/show.service.spec.d.ts +2 -0
- package/dist/services/show.service.spec.d.ts.map +1 -0
- package/dist/services/show.service.spec.js +242 -0
- package/dist/tailwind/preset.cjs +5 -0
- package/dist/tailwind/preset.d.cts +2 -0
- package/dist/tailwind/preset.d.cts.map +1 -1
- package/dist/tokens/__tests__/spacing.test.js +2 -2
- package/dist/tokens/base-resets.css +124 -0
- package/dist/tokens/spacing.d.ts +2 -0
- package/dist/tokens/spacing.d.ts.map +1 -1
- package/dist/tokens/spacing.js +1 -0
- package/dist/tokens/tokens.css +1 -1
- package/dist/tokens/utilities.css +79 -2
- package/dist/utils/apiConfig.js +1 -1
- package/dist/utils/apiConfig.spec.js +34 -27
- package/dist/utils/assets.d.ts +3 -0
- package/dist/utils/assets.d.ts.map +1 -0
- package/dist/utils/assets.js +3 -0
- package/dist/utils/classNames.d.ts +10 -0
- package/dist/utils/classNames.d.ts.map +1 -0
- package/dist/utils/classNames.js +15 -0
- package/dist/utils/clickOutside.d.ts +4 -0
- package/dist/utils/clickOutside.d.ts.map +1 -0
- package/dist/utils/clickOutside.js +13 -0
- package/dist/utils/cookieHelpers.d.ts +40 -0
- package/dist/utils/cookieHelpers.d.ts.map +1 -0
- package/dist/utils/cookieHelpers.js +102 -0
- package/dist/utils/dateHelpers.d.ts +71 -0
- package/dist/utils/dateHelpers.d.ts.map +1 -0
- package/dist/utils/dateHelpers.js +253 -0
- package/dist/utils/eventFormatters.d.ts +9 -0
- package/dist/utils/eventFormatters.d.ts.map +1 -0
- package/dist/utils/eventFormatters.js +96 -0
- package/dist/utils/feedbackContext.d.ts +24 -0
- package/dist/utils/feedbackContext.d.ts.map +1 -0
- package/dist/utils/feedbackContext.js +19 -0
- package/dist/utils/fetchHelpers.d.ts +17 -0
- package/dist/utils/fetchHelpers.d.ts.map +1 -0
- package/dist/utils/fetchHelpers.js +45 -0
- package/dist/utils/focusTrap.d.ts +20 -0
- package/dist/utils/focusTrap.d.ts.map +1 -0
- package/dist/utils/focusTrap.js +130 -0
- package/dist/utils/formatters.d.ts +56 -0
- package/dist/utils/formatters.d.ts.map +1 -1
- package/dist/utils/formatters.js +121 -1
- package/dist/utils/formatters.spec.js +128 -1
- package/dist/utils/logger.d.ts +25 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +59 -1
- package/dist/utils/logger.spec.js +99 -1
- package/dist/utils/permissions.d.ts +9 -0
- package/dist/utils/permissions.d.ts.map +1 -0
- package/dist/utils/permissions.js +93 -0
- package/dist/utils/stringHelpers.d.ts +17 -0
- package/dist/utils/stringHelpers.d.ts.map +1 -0
- package/dist/utils/stringHelpers.js +38 -0
- package/dist/utils/transitions.d.ts +99 -1
- package/dist/utils/transitions.d.ts.map +1 -1
- package/dist/utils/transitions.js +144 -2
- package/dist/utils/utils/utils.d.ts +2 -73
- package/dist/utils/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils/utils.js +2 -2
- package/dist/utils/utils.d.ts +41 -98
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +58 -701
- package/package.json +16 -3
- package/dist/services/EventService.d.ts +0 -5
- package/dist/services/EventService.d.ts.map +0 -1
- package/dist/services/EventService.js +0 -79
- package/dist/services/EventService.spec.d.ts +0 -2
- package/dist/services/EventService.spec.d.ts.map +0 -1
- package/dist/services/EventService.spec.js +0 -217
- package/dist/services/ShowService.d.ts.map +0 -1
- package/dist/services/ShowService.js +0 -144
- package/dist/services/ShowService.spec.d.ts +0 -2
- package/dist/services/ShowService.spec.d.ts.map +0 -1
- package/dist/services/ShowService.spec.js +0 -345
package/dist/utils/utils.js
CHANGED
|
@@ -1,702 +1,59 @@
|
|
|
1
|
-
import { twMerge } from "tailwind-merge";
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import EventIcon from "../assets/svg/role/event.svg";
|
|
4
|
-
import BookingIcon from "../assets/svg/role/booking.svg";
|
|
5
|
-
import EmailIcon from "../assets/svg/role/emails.svg";
|
|
6
|
-
import VenueIcon from "../assets/svg/role/venue.svg";
|
|
7
|
-
import PayoutIcon from "../assets/svg/role/payout.svg";
|
|
8
|
-
import MarketingIcon from "../assets/svg/role/marketing.svg";
|
|
9
|
-
import OrdersIcon from "../assets/svg/role/orders.svg";
|
|
10
|
-
import OrganisationIcon from "../assets/svg/role/organisation.svg";
|
|
11
|
-
import ReportingIcon from "../assets/svg/role/reporting.svg";
|
|
12
|
-
import microphonePlaceholder from "../assets/images/microphone.png";
|
|
13
|
-
|
|
14
|
-
export function classNames(...classes) {
|
|
15
|
-
return classes.filter(Boolean).join(" ");
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function truncateTitle(title, maxLength) {
|
|
19
|
-
if (title.length > maxLength) {
|
|
20
|
-
return title.slice(0, maxLength) + "...";
|
|
21
|
-
}
|
|
22
|
-
return title;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function convertToCustomDateFormat(isoString) {
|
|
26
|
-
const date = new Date(isoString);
|
|
27
|
-
|
|
28
|
-
const year = date.getUTCFullYear();
|
|
29
|
-
const month = date.getUTCMonth();
|
|
30
|
-
const day = date.getUTCDate();
|
|
31
|
-
|
|
32
|
-
const customDate = new Date(year, month, day);
|
|
33
|
-
|
|
34
|
-
return customDate;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function cn(...inputs) {
|
|
38
|
-
return twMerge(clsx(inputs));
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function getDays(params) {
|
|
42
|
-
if (params === "weeks") {
|
|
43
|
-
return [
|
|
44
|
-
{ value: "monday", label: "Monday" },
|
|
45
|
-
{ value: "tuesday", label: "Tuesday" },
|
|
46
|
-
{ value: "wednesday", label: "Wednesday" },
|
|
47
|
-
{ value: "thursday", label: "Thursday" },
|
|
48
|
-
{ value: "friday", label: "Friday" },
|
|
49
|
-
];
|
|
50
|
-
} else {
|
|
51
|
-
return Array.from({ length: 31 }, (_, i) => {
|
|
52
|
-
const day = i + 1;
|
|
53
|
-
const suffix =
|
|
54
|
-
day % 10 === 1 && day !== 11
|
|
55
|
-
? "st"
|
|
56
|
-
: day % 10 === 2 && day !== 12
|
|
57
|
-
? "nd"
|
|
58
|
-
: day % 10 === 3 && day !== 13
|
|
59
|
-
? "rd"
|
|
60
|
-
: "th";
|
|
61
|
-
return {
|
|
62
|
-
value: day.toString(),
|
|
63
|
-
label: day + suffix,
|
|
64
|
-
};
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Function to get days number options based on selected time unit
|
|
70
|
-
export function getDaysNumberOptions(timeUnit) {
|
|
71
|
-
if (timeUnit === "months") {
|
|
72
|
-
return Array.from({ length: 12 }, (_, i) => ({
|
|
73
|
-
value: (i + 1).toString(),
|
|
74
|
-
label: (i + 1).toString(),
|
|
75
|
-
}));
|
|
76
|
-
} else if (timeUnit === "weeks") {
|
|
77
|
-
return Array.from({ length: 10 }, (_, i) => ({
|
|
78
|
-
value: (i + 1).toString(),
|
|
79
|
-
label: (i + 1).toString(),
|
|
80
|
-
}));
|
|
81
|
-
} else {
|
|
82
|
-
return Array.from({ length: 31 }, (_, i) => ({
|
|
83
|
-
value: (i + 1).toString(),
|
|
84
|
-
label: (i + 1).toString(),
|
|
85
|
-
}));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const ROLE_PERMISSION_LIST = [
|
|
90
|
-
{
|
|
91
|
-
icon: EventIcon,
|
|
92
|
-
title: "Event creation",
|
|
93
|
-
description:
|
|
94
|
-
"Allow users to enter event info, create tickets & customize order forms",
|
|
95
|
-
checkbox: [
|
|
96
|
-
"Create Events",
|
|
97
|
-
"Edit Event Details",
|
|
98
|
-
"Manage event status",
|
|
99
|
-
"Manage tickets",
|
|
100
|
-
"Manage Collections",
|
|
101
|
-
],
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
icon: BookingIcon,
|
|
105
|
-
title: "Booking",
|
|
106
|
-
description:
|
|
107
|
-
"Allow users to manage performers, their invitations and statuses",
|
|
108
|
-
checkbox: [
|
|
109
|
-
"Access the roster page and view performer profiles",
|
|
110
|
-
"Edit performer profiles",
|
|
111
|
-
"Send booking invitations",
|
|
112
|
-
"Manually confirm/decline performers to spots",
|
|
113
|
-
"Send avails requests",
|
|
114
|
-
],
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
icon: VenueIcon,
|
|
118
|
-
title: "Venue creation",
|
|
119
|
-
description: "Allow users to create new venues",
|
|
120
|
-
checkbox: ["Add/edit/delete venues"],
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
icon: MarketingIcon,
|
|
124
|
-
title: "Marketing",
|
|
125
|
-
description:
|
|
126
|
-
"Sell more tickets by creating campaigns, tracking engagements, etc.",
|
|
127
|
-
checkbox: [
|
|
128
|
-
"Access social media posts",
|
|
129
|
-
"Manage tracking links",
|
|
130
|
-
"Manage promo codes",
|
|
131
|
-
],
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
icon: OrdersIcon,
|
|
135
|
-
title: "Orders & attendees",
|
|
136
|
-
description:
|
|
137
|
-
"Allow users to view, update & refund orders, manage attendee guest or waitlists & release tickets",
|
|
138
|
-
checkbox: [
|
|
139
|
-
"Add attendees",
|
|
140
|
-
"Manage orders, refunds, transfers and attendees",
|
|
141
|
-
"View list of attendees",
|
|
142
|
-
"Check in attendees",
|
|
143
|
-
"Resend confirmation emails",
|
|
144
|
-
"Override ticket restrictions",
|
|
145
|
-
"Sell tickets at the door",
|
|
146
|
-
"Revoke and reissue barcodes",
|
|
147
|
-
],
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
icon: OrganisationIcon,
|
|
151
|
-
title: "Organization",
|
|
152
|
-
description:
|
|
153
|
-
"Keep your users organized with assigned permissions per user, enable access to APIs & extensions",
|
|
154
|
-
checkbox: [
|
|
155
|
-
"Manage organization members & permissions",
|
|
156
|
-
"Edit organization infomation",
|
|
157
|
-
],
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
icon: EmailIcon,
|
|
161
|
-
title: "Contacts",
|
|
162
|
-
description:
|
|
163
|
-
"Keep our users in the loop, select which emails you would like them to receive",
|
|
164
|
-
checkbox: ["Email attendees", "Email/SMS performers"],
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
icon: ReportingIcon,
|
|
168
|
-
title: "Reporting",
|
|
169
|
-
description:
|
|
170
|
-
"Allow users to access, filter & export data across your organization",
|
|
171
|
-
checkbox: ["Access reports pages"],
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
icon: PayoutIcon,
|
|
175
|
-
title: "Payouts & billing",
|
|
176
|
-
description:
|
|
177
|
-
"Users can configure payout methods, manage event payment options & track financials with reporting",
|
|
178
|
-
checkbox: ["Manage financial accounts (Stripe)"],
|
|
179
|
-
},
|
|
180
|
-
];
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Parse a location string into street address and city/state/zip components
|
|
184
|
-
* @param {string} locationString - Full location string (e.g., "3400 Warner Blvd, Burbank, CA 91505")
|
|
185
|
-
* @returns {{street: string, cityStateZip: string}} Parsed location object
|
|
186
|
-
*/
|
|
187
|
-
export function parseLocation(locationString) {
|
|
188
|
-
if (!locationString) return { street: '', cityStateZip: '' };
|
|
189
|
-
|
|
190
|
-
// Split by comma to separate components
|
|
191
|
-
const parts = locationString.split(',').map(part => part.trim());
|
|
192
|
-
|
|
193
|
-
if (parts.length >= 3) {
|
|
194
|
-
// Format: "3400 Warner Blvd, Burbank, CA 91505"
|
|
195
|
-
const street = parts[0];
|
|
196
|
-
const cityStateZip = parts.slice(1).join(', ');
|
|
197
|
-
return { street, cityStateZip };
|
|
198
|
-
} else if (parts.length === 2) {
|
|
199
|
-
// Format: "Street, City State Zip"
|
|
200
|
-
return { street: parts[0], cityStateZip: parts[1] };
|
|
201
|
-
} else {
|
|
202
|
-
// Single part or unexpected format
|
|
203
|
-
return { street: locationString, cityStateZip: '' };
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Set authentication cookies with proper domain and security settings
|
|
209
|
-
* @param {string} token - Authentication token
|
|
210
|
-
* @param {Object} userDetails - User details object
|
|
211
|
-
* @param {boolean} rememberMe - Whether to persist cookies (default true)
|
|
212
|
-
* @param {string} refreshToken - Refresh token for token renewal
|
|
213
|
-
*/
|
|
214
|
-
export function setAuthCookies(token, userDetails, rememberMe = true, refreshToken = null) {
|
|
215
|
-
const isProd = window.location.hostname.includes("get-micdrop.com");
|
|
216
|
-
const domainAttr = isProd ? "domain=.get-micdrop.com;" : "";
|
|
217
|
-
const secureAttr = window.location.protocol === "https:" ? "secure;" : "";
|
|
218
|
-
const maxAge = rememberMe ? "max-age=2592000;" : ""; // 30 days or session
|
|
219
|
-
|
|
220
|
-
document.cookie = `performer_token=${token}; path=/; ${maxAge} ${domainAttr} ${secureAttr} samesite=lax`;
|
|
221
|
-
document.cookie = `userDetails=${encodeURIComponent(
|
|
222
|
-
JSON.stringify(userDetails),
|
|
223
|
-
)}; path=/; ${maxAge} ${domainAttr} ${secureAttr} samesite=lax`;
|
|
224
|
-
|
|
225
|
-
// Set refresh token if provided
|
|
226
|
-
if (refreshToken) {
|
|
227
|
-
document.cookie = `performer_refresh_token=${refreshToken}; path=/; ${maxAge} ${domainAttr} ${secureAttr} samesite=lax`;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Clear authentication cookies
|
|
233
|
-
*/
|
|
234
|
-
export function clearAuthCookies() {
|
|
235
|
-
const isProd = window.location.hostname.includes("get-micdrop.com");
|
|
236
|
-
const domainAttr = isProd ? "domain=.get-micdrop.com;" : "";
|
|
237
|
-
|
|
238
|
-
document.cookie = `userDetails=; path=/; max-age=0; ${domainAttr}`;
|
|
239
|
-
document.cookie = `performer_token=; path=/; max-age=0; ${domainAttr}`;
|
|
240
|
-
document.cookie = `performer_refresh_token=; path=/; max-age=0; ${domainAttr}`;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
// Export microphone placeholder for universal event image fallback
|
|
244
|
-
export { microphonePlaceholder };
|
|
245
|
-
|
|
246
|
-
// ============================================
|
|
247
|
-
// COOKIE UTILITIES
|
|
248
1
|
// ============================================
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
export
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
} catch {
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Get suppressed alerts from cookies
|
|
314
|
-
* @returns {string[]} Array of suppressed alert IDs
|
|
315
|
-
*/
|
|
316
|
-
export function getSuppressedAlerts() {
|
|
317
|
-
const alerts = getCookie("suppressedAlerts");
|
|
318
|
-
if (!alerts) return [];
|
|
319
|
-
try {
|
|
320
|
-
return JSON.parse(alerts);
|
|
321
|
-
} catch {
|
|
322
|
-
return [];
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Save suppressed alerts to cookies
|
|
328
|
-
* @param {string[]} alertIds - Array of alert IDs to suppress
|
|
329
|
-
*/
|
|
330
|
-
export function saveSuppressedAlerts(alertIds) {
|
|
331
|
-
setCookie("suppressedAlerts", JSON.stringify(alertIds), { maxAge: 31536000 }); // 1 year
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// ============================================
|
|
335
|
-
// DATA FETCHING UTILITIES
|
|
336
|
-
// ============================================
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Fetch data from an API endpoint with error handling
|
|
340
|
-
* @param {string} endpoint - API endpoint
|
|
341
|
-
* @param {Object} options - Fetch options
|
|
342
|
-
* @returns {Promise<{data: any, error: string|null}>}
|
|
343
|
-
*/
|
|
344
|
-
export async function fetchData(endpoint, options = {}) {
|
|
345
|
-
try {
|
|
346
|
-
const res = await fetch(endpoint, {
|
|
347
|
-
headers: { "Content-Type": "application/json", ...options.headers },
|
|
348
|
-
...options,
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
if (!res.ok) {
|
|
352
|
-
const errorText = await res.text().catch(() => "Unknown error");
|
|
353
|
-
throw new Error(errorText || `Request failed with status ${res.status}`);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
const data = await res.json();
|
|
357
|
-
return { data, error: null };
|
|
358
|
-
} catch (err) {
|
|
359
|
-
return { data: null, error: err.message };
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Post data to an API endpoint
|
|
365
|
-
* @param {string} endpoint - API endpoint
|
|
366
|
-
* @param {Object} data - Data to post
|
|
367
|
-
* @returns {Promise<{data: any, error: string|null, ok: boolean}>}
|
|
368
|
-
*/
|
|
369
|
-
export async function postData(endpoint, data) {
|
|
370
|
-
try {
|
|
371
|
-
const res = await fetch(endpoint, {
|
|
372
|
-
method: "POST",
|
|
373
|
-
headers: { "Content-Type": "application/json" },
|
|
374
|
-
body: JSON.stringify(data),
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
const responseData = await res.json().catch(() => ({}));
|
|
378
|
-
|
|
379
|
-
return {
|
|
380
|
-
data: responseData,
|
|
381
|
-
error: res.ok ? null : (responseData.message || "Request failed"),
|
|
382
|
-
ok: res.ok
|
|
383
|
-
};
|
|
384
|
-
} catch (err) {
|
|
385
|
-
return { data: null, error: err.message, ok: false };
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
// ============================================
|
|
390
|
-
// DATE/TIME FORMATTING UTILITIES
|
|
391
|
-
// (Merged from utils/utils/utils.js)
|
|
392
|
-
// ============================================
|
|
393
|
-
|
|
394
|
-
export function convertToDate(value) {
|
|
395
|
-
return value ? new Date(value).toDateString() : null;
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
export function convertToCustomDateTimeFormat(isoDateString) {
|
|
399
|
-
const date = new Date(isoDateString);
|
|
400
|
-
return new Date(
|
|
401
|
-
Date.UTC(
|
|
402
|
-
date.getUTCFullYear(),
|
|
403
|
-
date.getUTCMonth(),
|
|
404
|
-
date.getUTCDate(),
|
|
405
|
-
date.getUTCHours(),
|
|
406
|
-
date.getUTCMinutes()
|
|
407
|
-
)
|
|
408
|
-
);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
export function formatHour(dateString) {
|
|
412
|
-
const date = new Date(dateString);
|
|
413
|
-
const hour = date.getUTCHours();
|
|
414
|
-
const minutes = date.getUTCMinutes();
|
|
415
|
-
const suffix = hour >= 12 ? "PM" : "AM";
|
|
416
|
-
const displayHour = hour % 12 || 12;
|
|
417
|
-
|
|
418
|
-
// Ensure minutes are always two digits
|
|
419
|
-
const displayMinutes = minutes < 10 ? "0" + minutes : minutes;
|
|
420
|
-
|
|
421
|
-
return `${displayHour}:${displayMinutes} ${suffix}`;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
export function formattedDate(date) {
|
|
425
|
-
const options = {
|
|
426
|
-
weekday: "short", // 'Thu'
|
|
427
|
-
month: "short", // 'Oct'
|
|
428
|
-
day: "2-digit", // '24'
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
return new Date(date).toLocaleDateString("en-US", options);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
// Helper function to get the ordinal suffix (st, nd, rd, th)
|
|
435
|
-
function getOrdinalSuffix(day) {
|
|
436
|
-
if (day >= 11 && day <= 13) return "th"; // Special case for 11th, 12th, and 13th
|
|
437
|
-
switch (day % 10) {
|
|
438
|
-
case 1:
|
|
439
|
-
return "st";
|
|
440
|
-
case 2:
|
|
441
|
-
return "nd";
|
|
442
|
-
case 3:
|
|
443
|
-
return "rd";
|
|
444
|
-
default:
|
|
445
|
-
return "th";
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
export function formattedFullDate(date) {
|
|
450
|
-
const options = {
|
|
451
|
-
weekday: "long", // 'Thursday'
|
|
452
|
-
month: "long", // 'October'
|
|
453
|
-
day: "numeric", // '24'
|
|
454
|
-
year: "numeric", // '2024'
|
|
455
|
-
};
|
|
456
|
-
|
|
457
|
-
const formattedDate = new Date(date).toLocaleDateString("en-US", options);
|
|
458
|
-
|
|
459
|
-
// Get the day of the month to append the ordinal suffix
|
|
460
|
-
const day = new Date(date).getDate();
|
|
461
|
-
const ordinalSuffix = getOrdinalSuffix(day);
|
|
462
|
-
|
|
463
|
-
// Replace the day number with the day + ordinal suffix
|
|
464
|
-
const fullDate = formattedDate.replace(/\d+/, day + ordinalSuffix);
|
|
465
|
-
return fullDate;
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
export const formatDateTime = (dateTimeString, timeZone = "UTC") => {
|
|
469
|
-
const options = {
|
|
470
|
-
weekday: "short", // Mon, Tue, etc.
|
|
471
|
-
year: "numeric", // 2024
|
|
472
|
-
month: "short", // Dec
|
|
473
|
-
day: "numeric", // 12
|
|
474
|
-
hour: "numeric", // 11
|
|
475
|
-
minute: "numeric", // 00
|
|
476
|
-
hour12: true, // 11:00 PM format
|
|
477
|
-
timeZone: timeZone, // Account for the timezone, defaults to 'UTC'
|
|
478
|
-
};
|
|
479
|
-
|
|
480
|
-
const date = new Date(dateTimeString);
|
|
481
|
-
|
|
482
|
-
return new Intl.DateTimeFormat("en-US", options).format(date);
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
export const formatTimeline = (startDateTime) => {
|
|
486
|
-
const formatHourInternal = (date) => {
|
|
487
|
-
let hours = date.getUTCHours();
|
|
488
|
-
const minutes = date.getUTCMinutes();
|
|
489
|
-
const suffix = hours >= 12 ? "PM" : "AM";
|
|
490
|
-
hours = hours % 12 || 12;
|
|
491
|
-
|
|
492
|
-
return `${hours}:${minutes < 10 ? "0" + minutes : minutes} ${suffix}`;
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
const start = formatHourInternal(new Date(startDateTime));
|
|
496
|
-
return `${start}`;
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
export function formatTimeRange(startDate, endDate) {
|
|
500
|
-
const start = new Date(startDate);
|
|
501
|
-
const end = new Date(endDate);
|
|
502
|
-
|
|
503
|
-
function formatTime(date) {
|
|
504
|
-
let hours = date.getUTCHours();
|
|
505
|
-
const minutes = date.getUTCMinutes();
|
|
506
|
-
const ampm = hours >= 12 ? "PM" : "AM";
|
|
507
|
-
hours = hours % 12;
|
|
508
|
-
hours = hours ? hours : 12;
|
|
509
|
-
const minutesStr = minutes < 10 ? "0" + minutes : minutes;
|
|
510
|
-
return hours + ":" + minutesStr + " " + ampm;
|
|
511
|
-
}
|
|
512
|
-
const startTime = formatTime(start);
|
|
513
|
-
const endTime = formatTime(end);
|
|
514
|
-
return `${startTime} - ${endTime}`;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
export function getDateRange(startDate, endDate) {
|
|
518
|
-
const start = new Date(startDate);
|
|
519
|
-
const end = new Date(endDate);
|
|
520
|
-
|
|
521
|
-
const dateArray = [];
|
|
522
|
-
const currentDate = new Date(start);
|
|
523
|
-
|
|
524
|
-
while (currentDate <= end) {
|
|
525
|
-
dateArray.push(
|
|
526
|
-
`${currentDate.getUTCFullYear()}-${currentDate.getUTCMonth() + 1
|
|
527
|
-
}-${currentDate.getUTCDate()}`
|
|
528
|
-
);
|
|
529
|
-
currentDate.setUTCDate(currentDate.getUTCDate() + 1); // Move to the next day
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
return dateArray;
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
export const getDay = (dateString) => {
|
|
536
|
-
const days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
537
|
-
const date = new Date(dateString);
|
|
538
|
-
return days[date.getUTCDay()];
|
|
539
|
-
};
|
|
540
|
-
|
|
541
|
-
export const getMonth = (dateString) => {
|
|
542
|
-
const months = [
|
|
543
|
-
"Jan",
|
|
544
|
-
"Feb",
|
|
545
|
-
"Mar",
|
|
546
|
-
"Apr",
|
|
547
|
-
"May",
|
|
548
|
-
"Jun",
|
|
549
|
-
"Jul",
|
|
550
|
-
"Aug",
|
|
551
|
-
"Sep",
|
|
552
|
-
"Oct",
|
|
553
|
-
"Nov",
|
|
554
|
-
"Dec",
|
|
555
|
-
];
|
|
556
|
-
const date = new Date(dateString);
|
|
557
|
-
return months[date.getUTCMonth()];
|
|
558
|
-
};
|
|
559
|
-
|
|
560
|
-
export const getDateOfMonth = (dateString) => {
|
|
561
|
-
const date = new Date(dateString);
|
|
562
|
-
return date.getUTCDate();
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
// ============================================
|
|
566
|
-
// EVENT FORMATTING UTILITIES
|
|
567
|
-
// ============================================
|
|
568
|
-
|
|
569
|
-
// Map roleOnStage numeric value to role name string
|
|
570
|
-
// These correspond to the lineup position roles in the operator panel
|
|
571
|
-
const ROLE_ON_STAGE_MAP = {
|
|
572
|
-
0: "Performer",
|
|
573
|
-
1: "Host",
|
|
574
|
-
2: "Headliner",
|
|
575
|
-
3: "Feature",
|
|
576
|
-
4: "Special Guest",
|
|
577
|
-
5: "Opener",
|
|
578
|
-
6: "Guest",
|
|
579
|
-
7: "Teacher",
|
|
580
|
-
8: "Assistant",
|
|
581
|
-
};
|
|
582
|
-
|
|
583
|
-
export const getRoleFromRoleOnStage = (roleOnStage) => {
|
|
584
|
-
return ROLE_ON_STAGE_MAP[roleOnStage] || "Performer";
|
|
585
|
-
};
|
|
586
|
-
|
|
587
|
-
// Format Event as Show for Listing data
|
|
588
|
-
// Handles both V1 (EventPerformer with event.Event) and V2 (PerformerInvite with event.event) shapes
|
|
589
|
-
export const formatEvent = (event) => {
|
|
590
|
-
// V2 uses lowercase "event", V1 uses uppercase "Event"
|
|
591
|
-
const eventData = event.event || event.Event;
|
|
592
|
-
|
|
593
|
-
// Get venue stage name (the physical stage at the venue, e.g., "Main Room", "Showroom")
|
|
594
|
-
// Not to be confused with performer's stage name (their performance alias)
|
|
595
|
-
const venueStageName = eventData?.stage?.name || eventData?.stage?.googleName || eventData?.googleName || "";
|
|
596
|
-
|
|
597
|
-
// Handle potentially undefined venue address
|
|
598
|
-
const venueAddress = eventData?.venue?.address || "";
|
|
599
|
-
|
|
600
|
-
// Map roleOnStage number to role name string
|
|
601
|
-
const role = getRoleFromRoleOnStage(event.roleOnStage);
|
|
602
|
-
|
|
603
|
-
// Get custom booking notification message from venue (set in venue edit page)
|
|
604
|
-
const bookingMessage = eventData?.venue?.booking_notification || "No additional details available.";
|
|
605
|
-
|
|
606
|
-
// V2 returns "status" string, V1 returns numeric "acceptedState"
|
|
607
|
-
const status = event.status || (event.acceptedState !== undefined ? { 0: "invited", 2: "confirmed", 1: "declined", 3: "declined", 4: "cancelled" }[event.acceptedState] : "unknown");
|
|
608
|
-
|
|
609
|
-
const setLength = event.setLength ?? 0;
|
|
610
|
-
|
|
611
|
-
return {
|
|
612
|
-
eventId: eventData?.ID,
|
|
613
|
-
venueId: eventData?.venue?.ID,
|
|
614
|
-
title: eventData?.title,
|
|
615
|
-
role: role,
|
|
616
|
-
startDateTime: eventData?.startDateTime,
|
|
617
|
-
status: status,
|
|
618
|
-
doorsOpenTime: eventData?.doorsOpenTime,
|
|
619
|
-
spotDuration: `${setLength} min spot`,
|
|
620
|
-
venueName: eventData?.venue?.name,
|
|
621
|
-
location: venueAddress,
|
|
622
|
-
id: event.invitationId || String(event.id || event.ID),
|
|
623
|
-
image: eventData?.image,
|
|
624
|
-
details: {
|
|
625
|
-
venue: eventData?.venue?.name,
|
|
626
|
-
stageName: venueStageName,
|
|
627
|
-
address: venueAddress,
|
|
628
|
-
setLength: `${setLength} min`,
|
|
629
|
-
eventDetails: bookingMessage,
|
|
630
|
-
},
|
|
631
|
-
lastUpdated: event.updatedAt || event.UpdatedAt,
|
|
632
|
-
};
|
|
633
|
-
};
|
|
634
|
-
|
|
635
|
-
export const formatRosterEventPerformerInvite = (event) => {
|
|
636
|
-
return {
|
|
637
|
-
venueId: event.venueId,
|
|
638
|
-
role: event.role || "Performer",
|
|
639
|
-
acceptedState: event.acceptedState,
|
|
640
|
-
name: event.Venue.name,
|
|
641
|
-
shortVenue: `${event.Venue.firstName} ${event.Venue.lastName} - ${event.Venue.role}`,
|
|
642
|
-
location: `${event.Venue.address}`,
|
|
643
|
-
id: event.invitationId,
|
|
644
|
-
lastUpdated: event.UpdatedAt,
|
|
645
|
-
image: event.Venue.image,
|
|
646
|
-
hasAvailability: true,
|
|
647
|
-
invitationAccepted: event.acceptedState === 2,
|
|
648
|
-
};
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
export const formatVenue = (event) => {
|
|
652
|
-
return {
|
|
653
|
-
venueId: event.Event.venueId,
|
|
654
|
-
name: event.Event.venue.name,
|
|
655
|
-
image: event.Event.venue.squareImageUrl || event.Event.venue.image,
|
|
656
|
-
location: `${event.Event.venue.address}`,
|
|
657
|
-
start: event.Event.startDateTime,
|
|
658
|
-
end: event.Event.endDateTime,
|
|
659
|
-
doorOpen: event.Event.doorsOpenTime,
|
|
660
|
-
email: event.Event.venue.email,
|
|
661
|
-
phone: event.Event.venue.phone,
|
|
662
|
-
description: event.Event.venue.description,
|
|
663
|
-
instagram: event.Event.venue.instagram,
|
|
664
|
-
facebook: event.Event.venue.facebook,
|
|
665
|
-
twitter: event.Event.venue.twitter,
|
|
666
|
-
lastUpdated: event.UpdatedAt,
|
|
667
|
-
timeRange: formatTimeRange(event.Event.startDateTime, event.Event.endDateTime),
|
|
668
|
-
dateRange: getDateRange(event.Event.startDateTime, event.Event.endDateTime),
|
|
669
|
-
};
|
|
670
|
-
};
|
|
671
|
-
|
|
672
|
-
// ============================================
|
|
673
|
-
// STRING UTILITIES
|
|
674
|
-
// ============================================
|
|
675
|
-
|
|
676
|
-
export function capitalize(word) {
|
|
677
|
-
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
export function timeAgo(date) {
|
|
681
|
-
const now = new Date();
|
|
682
|
-
const seconds = Math.floor((now - new Date(date)) / 1000);
|
|
683
|
-
const minutes = Math.floor(seconds / 60);
|
|
684
|
-
const hours = Math.floor(minutes / 60);
|
|
685
|
-
const days = Math.floor(hours / 24);
|
|
686
|
-
const months = Math.floor(days / 30);
|
|
687
|
-
const years = Math.floor(months / 12);
|
|
688
|
-
|
|
689
|
-
if (seconds < 60) {
|
|
690
|
-
return `${seconds} second${seconds !== 1 ? "s" : ""} ago`;
|
|
691
|
-
} else if (minutes < 60) {
|
|
692
|
-
return `${minutes} minute${minutes !== 1 ? "s" : ""} ago`;
|
|
693
|
-
} else if (hours < 24) {
|
|
694
|
-
return `${hours} hour${hours !== 1 ? "s" : ""} ago`;
|
|
695
|
-
} else if (days < 30) {
|
|
696
|
-
return `${days} day${days !== 1 ? "s" : ""} ago`;
|
|
697
|
-
} else if (months < 12) {
|
|
698
|
-
return `${months} month${months !== 1 ? "s" : ""} ago`;
|
|
699
|
-
} else {
|
|
700
|
-
return `${years} year${years !== 1 ? "s" : ""} ago`;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
2
|
+
// BARREL RE-EXPORTS
|
|
3
|
+
// ============================================
|
|
4
|
+
// This file is kept for backward compatibility.
|
|
5
|
+
// All functions have been decomposed into purpose-specific modules:
|
|
6
|
+
//
|
|
7
|
+
// classNames.ts - classNames, cn
|
|
8
|
+
// stringHelpers.ts - truncateTitle, capitalize, parseLocation
|
|
9
|
+
// dateHelpers.ts - date/time formatting, getDays, getDaysNumberOptions
|
|
10
|
+
// cookieHelpers.ts - cookie CRUD, auth cookies, performer token
|
|
11
|
+
// fetchHelpers.ts - fetchData, postData
|
|
12
|
+
// eventFormatters.ts - formatEvent, formatVenue, formatRosterEventPerformerInvite, getRoleFromRoleOnStage
|
|
13
|
+
// permissions.ts - ROLE_PERMISSION_LIST
|
|
14
|
+
// formatters.ts - roundCurrency, formatCreditCardNumber, formatPhoneNumber
|
|
15
|
+
// assets.ts - microphonePlaceholder
|
|
16
|
+
//
|
|
17
|
+
// Prefer importing directly from the specific module.
|
|
18
|
+
// ============================================
|
|
19
|
+
|
|
20
|
+
export { classNames, cn } from "./classNames";
|
|
21
|
+
export { truncateTitle, capitalize, parseLocation } from "./stringHelpers";
|
|
22
|
+
export {
|
|
23
|
+
convertToDate,
|
|
24
|
+
convertToCustomDateFormat,
|
|
25
|
+
convertToCustomDateTimeFormat,
|
|
26
|
+
formatHour,
|
|
27
|
+
formattedDate,
|
|
28
|
+
formattedFullDate,
|
|
29
|
+
formatDateTime,
|
|
30
|
+
formatTimeline,
|
|
31
|
+
formatTimeRange,
|
|
32
|
+
getDateRange,
|
|
33
|
+
getDay,
|
|
34
|
+
getMonth,
|
|
35
|
+
getDateOfMonth,
|
|
36
|
+
timeAgo,
|
|
37
|
+
getDays,
|
|
38
|
+
getDaysNumberOptions,
|
|
39
|
+
} from "./dateHelpers";
|
|
40
|
+
export {
|
|
41
|
+
parseCookies,
|
|
42
|
+
getCookie,
|
|
43
|
+
setCookie,
|
|
44
|
+
getPerformerToken,
|
|
45
|
+
getUserDetails,
|
|
46
|
+
getSuppressedAlerts,
|
|
47
|
+
saveSuppressedAlerts,
|
|
48
|
+
setAuthCookies,
|
|
49
|
+
clearAuthCookies,
|
|
50
|
+
} from "./cookieHelpers";
|
|
51
|
+
export { fetchData, postData } from "./fetchHelpers";
|
|
52
|
+
export {
|
|
53
|
+
getRoleFromRoleOnStage,
|
|
54
|
+
formatEvent,
|
|
55
|
+
formatRosterEventPerformerInvite,
|
|
56
|
+
formatVenue,
|
|
57
|
+
} from "./eventFormatters";
|
|
58
|
+
export { ROLE_PERMISSION_LIST } from "./permissions";
|
|
59
|
+
export { microphonePlaceholder } from "./assets";
|