@getmicdrop/svelte-components 2.0.4 → 2.0.6
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/components/Alert/Alert.spec.js +170 -170
- package/dist/components/Badges/Badge.spec.js +103 -103
- package/dist/components/BottomSheet/BottomSheet.spec.js +127 -127
- package/dist/components/Breadcrumb/Breadcrumb.spec.js +120 -120
- package/dist/components/Button/Button.spec.js +211 -211
- package/dist/components/Button/ButtonSaveDemo.spec.js +48 -48
- package/dist/components/Calendar/Calendar.spec.js +131 -131
- package/dist/components/Calendar/QuarterView.spec.js +394 -394
- package/dist/components/Card.spec.js +47 -47
- package/dist/components/CropImage/CropImage.spec.js +216 -216
- package/dist/components/DarkModeToggle.spec.js +357 -357
- package/dist/components/ErrorDisplay.spec.js +69 -69
- package/dist/components/FormActions.spec.js +88 -88
- package/dist/components/FormValidationSummary.spec.js +203 -203
- package/dist/components/Icons/Icon.spec.js +175 -175
- package/dist/components/Icons/MoreHori.spec.js +67 -67
- package/dist/components/Icons/WarningIcon.spec.js +30 -30
- package/dist/components/Input/Input.spec.js +573 -573
- package/dist/components/Input/MultiSelect.spec.js +257 -257
- package/dist/components/Input/OTPInput.spec.js +238 -238
- package/dist/components/Input/Select.spec.js +218 -218
- package/dist/components/Layout/BottomNav.spec.js +130 -130
- package/dist/components/Layout/Header.spec.js +203 -203
- package/dist/components/Modal/ConfirmationModal.spec.js +191 -191
- package/dist/components/Modal/Modal.spec.js +95 -95
- package/dist/components/Modal/ModalStateManager.spec.js +100 -100
- package/dist/components/PageLoader.spec.js +54 -54
- package/dist/components/PasswordStrengthIndicator/PasswordStrengthIndicator.spec.js +173 -173
- package/dist/components/PlaceAutocomplete/PlaceAutocomplete.spec.js +300 -300
- package/dist/components/Spinner/Spinner.spec.js +75 -75
- package/dist/components/StatusIndicator/StatusIndicator.spec.js +129 -129
- package/dist/components/Toaster/Toaster.stories.svelte +1 -1
- package/dist/components/Toggle.spec.js +158 -158
- package/dist/components/ValidationError.spec.js +79 -79
- package/dist/components/pages/performers/AvailabilityCalendarModal.spec.js +606 -606
- package/dist/components/pages/performers/AvailabilityCalendarModal.svelte +4 -4
- package/dist/components/pages/performers/ModalShowInfo.spec.js +124 -124
- package/dist/components/pages/performers/ModalShowInfo.svelte +1 -1
- package/dist/components/pages/performers/PageBackButton.spec.js +89 -89
- package/dist/components/pages/performers/SectionHeader.spec.js +75 -75
- package/dist/components/pages/performers/ShowDetails.spec.js +166 -166
- package/dist/components/pages/performers/ShowItemCard.spec.js +793 -793
- package/dist/components/pages/performers/ShowItemCard.svelte +4 -4
- package/dist/components/pages/performers/SwitchOption.spec.js +127 -127
- package/dist/components/pages/performers/VenueInfo.spec.js +167 -167
- package/dist/components/pages/performers/VenueInfo.svelte +1 -1
- package/dist/components/pages/performers/VenueItemCard.spec.js +763 -763
- package/dist/components/pages/performers/VenueItemCard.svelte +4 -4
- package/dist/components/pages/profile/profile-form.spec.js +9 -9
- package/dist/components/pages/settings/tabs/CustomImageDropzone.svelte +3 -3
- package/dist/components/pages/shows/ShowList.spec.js +33 -33
- package/dist/components/pages/shows/TabContent.spec.js +90 -90
- package/dist/components/pages/shows/TabNavigation.spec.js +143 -143
- package/dist/config.js +5 -5
- package/dist/config.spec.js +29 -29
- package/dist/constants/formOptions.js +25 -25
- package/dist/constants/formOptions.spec.js +88 -88
- package/dist/index.js +111 -111
- package/dist/stores/auth.d.ts +9 -0
- package/dist/stores/auth.d.ts.map +1 -0
- package/dist/stores/auth.js +36 -0
- package/dist/stores/auth.spec.d.ts +2 -0
- package/dist/stores/auth.spec.d.ts.map +1 -0
- package/dist/stores/auth.spec.js +139 -0
- package/dist/stores/formDataStore.d.ts +17 -0
- package/dist/stores/formDataStore.d.ts.map +1 -0
- package/dist/stores/formDataStore.js +25 -0
- package/dist/stores/formDataStore.spec.d.ts +2 -0
- package/dist/stores/formDataStore.spec.d.ts.map +1 -0
- package/dist/stores/formDataStore.spec.js +257 -0
- package/dist/stores/formSave.d.ts +24 -0
- package/dist/stores/formSave.d.ts.map +1 -0
- package/dist/stores/formSave.js +132 -0
- package/dist/stores/formSave.spec.d.ts +2 -0
- package/dist/stores/formSave.spec.d.ts.map +1 -0
- package/dist/stores/formSave.spec.js +296 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/stores/index.d.ts.map +1 -0
- package/dist/stores/index.js +0 -0
- package/dist/stores/navigation.d.ts +5 -0
- package/dist/stores/navigation.d.ts.map +1 -0
- package/dist/stores/navigation.js +12 -0
- package/dist/stores/navigation.spec.d.ts +2 -0
- package/dist/stores/navigation.spec.d.ts.map +1 -0
- package/dist/stores/navigation.spec.js +136 -0
- package/dist/stores/toaster.d.ts +4 -0
- package/dist/stores/toaster.d.ts.map +1 -0
- package/dist/stores/toaster.js +13 -0
- package/dist/stores/toaster.spec.d.ts +2 -0
- package/dist/stores/toaster.spec.d.ts.map +1 -0
- package/dist/stores/toaster.spec.js +59 -0
- package/dist/telemetry.js +357 -357
- package/dist/telemetry.server.js +211 -211
- package/dist/telemetry.server.spec.js +434 -434
- package/dist/telemetry.spec.js +660 -660
- package/dist/utils/apiConfig.js +49 -49
- package/dist/utils/apiConfig.spec.js +118 -118
- package/dist/utils/greetings.js +187 -187
- package/dist/utils/greetings.spec.js +337 -337
- package/dist/utils/imageValidation.js +121 -121
- package/dist/utils/imageValidation.spec.js +220 -220
- package/dist/utils/portal.js +25 -25
- package/dist/utils/portal.spec.js +143 -143
- package/dist/utils/utils/utils.js +323 -323
- package/dist/utils/utils/utils.spec.js +698 -698
- package/dist/utils/utils.spec.js +643 -643
- package/package.json +1 -1
|
@@ -1,323 +1,323 @@
|
|
|
1
|
-
import { clsx } from "clsx";
|
|
2
|
-
import { twMerge } from "tailwind-merge";
|
|
3
|
-
|
|
4
|
-
export function cn(...inputs) {
|
|
5
|
-
return twMerge(clsx(inputs));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function convertToDate(value) {
|
|
9
|
-
return value ? new Date(value).toDateString() : null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function classNames(...classes) {
|
|
13
|
-
return classes.filter(Boolean).join(" ");
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function truncateTitle(title, maxLength) {
|
|
17
|
-
if (title.length > maxLength) {
|
|
18
|
-
return title.slice(0, maxLength) + "...";
|
|
19
|
-
}
|
|
20
|
-
return title;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function convertToCustomDateFormat(isoString) {
|
|
24
|
-
const date = new Date(isoString);
|
|
25
|
-
|
|
26
|
-
const year = date.getUTCFullYear();
|
|
27
|
-
const month = date.getUTCMonth();
|
|
28
|
-
const day = date.getUTCDate();
|
|
29
|
-
|
|
30
|
-
const customDate = new Date(year, month, day);
|
|
31
|
-
|
|
32
|
-
return customDate;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function convertToCustomDateTimeFormat(isoDateString) {
|
|
36
|
-
const date = new Date(isoDateString);
|
|
37
|
-
return new Date(
|
|
38
|
-
Date.UTC(
|
|
39
|
-
date.getUTCFullYear(),
|
|
40
|
-
date.getUTCMonth(),
|
|
41
|
-
date.getUTCDate(),
|
|
42
|
-
date.getUTCHours(),
|
|
43
|
-
date.getUTCMinutes()
|
|
44
|
-
)
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function formatHour(dateString) {
|
|
49
|
-
const date = new Date(dateString);
|
|
50
|
-
const hour = date.getUTCHours();
|
|
51
|
-
const minutes = date.getUTCMinutes();
|
|
52
|
-
const suffix = hour >= 12 ? "PM" : "AM";
|
|
53
|
-
const displayHour = hour % 12 || 12;
|
|
54
|
-
|
|
55
|
-
// Ensure minutes are always two digits
|
|
56
|
-
const displayMinutes = minutes < 10 ? "0" + minutes : minutes;
|
|
57
|
-
|
|
58
|
-
return `${displayHour}:${displayMinutes} ${suffix}`;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function formattedDate(date) {
|
|
62
|
-
const options = {
|
|
63
|
-
weekday: "short", // 'Thu'
|
|
64
|
-
month: "short", // 'Oct'
|
|
65
|
-
day: "2-digit", // '24'
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
return new Date(date).toLocaleDateString("en-US", options);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function formattedFullDate(date) {
|
|
72
|
-
const options = {
|
|
73
|
-
weekday: "long", // 'Thursday'
|
|
74
|
-
month: "long", // 'October'
|
|
75
|
-
day: "numeric", // '24'
|
|
76
|
-
year: "numeric", // '2024'
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const formattedDate = new Date(date).toLocaleDateString("en-US", options);
|
|
80
|
-
|
|
81
|
-
// Get the day of the month to append the ordinal suffix
|
|
82
|
-
const day = new Date(date).getDate();
|
|
83
|
-
const ordinalSuffix = getOrdinalSuffix(day);
|
|
84
|
-
|
|
85
|
-
// Replace the day number with the day + ordinal suffix
|
|
86
|
-
const fullDate = formattedDate.replace(/\d+/, day + ordinalSuffix);
|
|
87
|
-
return fullDate;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Helper function to get the ordinal suffix (st, nd, rd, th)
|
|
91
|
-
function getOrdinalSuffix(day) {
|
|
92
|
-
if (day >= 11 && day <= 13) return "th"; // Special case for 11th, 12th, and 13th
|
|
93
|
-
switch (day % 10) {
|
|
94
|
-
case 1:
|
|
95
|
-
return "st";
|
|
96
|
-
case 2:
|
|
97
|
-
return "nd";
|
|
98
|
-
case 3:
|
|
99
|
-
return "rd";
|
|
100
|
-
default:
|
|
101
|
-
return "th";
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export const formatDateTime = (dateTimeString, timeZone = "UTC") => {
|
|
106
|
-
const options = {
|
|
107
|
-
weekday: "short", // Mon, Tue, etc.
|
|
108
|
-
year: "numeric", // 2024
|
|
109
|
-
month: "short", // Dec
|
|
110
|
-
day: "numeric", // 12
|
|
111
|
-
hour: "numeric", // 11
|
|
112
|
-
minute: "numeric", // 00
|
|
113
|
-
hour12: true, // 11:00 PM format
|
|
114
|
-
timeZone: timeZone, // Account for the timezone, defaults to 'UTC'
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const date = new Date(dateTimeString);
|
|
118
|
-
|
|
119
|
-
return new Intl.DateTimeFormat("en-US", options).format(date);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const formatTimeline = (startDateTime) => {
|
|
123
|
-
const formatHour = (date) => {
|
|
124
|
-
let hours = date.getUTCHours();
|
|
125
|
-
const minutes = date.getUTCMinutes();
|
|
126
|
-
const suffix = hours >= 12 ? "PM" : "AM";
|
|
127
|
-
hours = hours % 12 || 12;
|
|
128
|
-
|
|
129
|
-
return `${hours}:${minutes < 10 ? "0" + minutes : minutes} ${suffix}`;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const start = formatHour(new Date(startDateTime));
|
|
133
|
-
return `${start}`;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export function formatTimeRange(startDate, endDate) {
|
|
137
|
-
const start = new Date(startDate);
|
|
138
|
-
const end = new Date(endDate);
|
|
139
|
-
|
|
140
|
-
function formatTime(date) {
|
|
141
|
-
let hours = date.getUTCHours();
|
|
142
|
-
const minutes = date.getUTCMinutes();
|
|
143
|
-
const ampm = hours >= 12 ? "PM" : "AM";
|
|
144
|
-
hours = hours % 12;
|
|
145
|
-
hours = hours ? hours : 12;
|
|
146
|
-
const minutesStr = minutes < 10 ? "0" + minutes : minutes;
|
|
147
|
-
return hours + ":" + minutesStr + " " + ampm;
|
|
148
|
-
}
|
|
149
|
-
const startTime = formatTime(start);
|
|
150
|
-
const endTime = formatTime(end);
|
|
151
|
-
return `${startTime} - ${endTime}`;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export function getDateRange(startDate, endDate) {
|
|
155
|
-
const start = new Date(startDate);
|
|
156
|
-
const end = new Date(endDate);
|
|
157
|
-
|
|
158
|
-
const dateArray = [];
|
|
159
|
-
const currentDate = new Date(start);
|
|
160
|
-
|
|
161
|
-
while (currentDate <= end) {
|
|
162
|
-
dateArray.push(
|
|
163
|
-
`${currentDate.getUTCFullYear()}-${currentDate.getUTCMonth() + 1
|
|
164
|
-
}-${currentDate.getUTCDate()}`
|
|
165
|
-
);
|
|
166
|
-
currentDate.setUTCDate(currentDate.getUTCDate() + 1); // Move to the next day
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return dateArray;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export const getDay = (dateString) => {
|
|
173
|
-
const days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
174
|
-
const date = new Date(dateString);
|
|
175
|
-
return days[date.getUTCDay()];
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
export const getMonth = (dateString) => {
|
|
179
|
-
const months = [
|
|
180
|
-
"Jan",
|
|
181
|
-
"Feb",
|
|
182
|
-
"Mar",
|
|
183
|
-
"Apr",
|
|
184
|
-
"May",
|
|
185
|
-
"Jun",
|
|
186
|
-
"Jul",
|
|
187
|
-
"Aug",
|
|
188
|
-
"Sep",
|
|
189
|
-
"Oct",
|
|
190
|
-
"Nov",
|
|
191
|
-
"Dec",
|
|
192
|
-
];
|
|
193
|
-
const date = new Date(dateString);
|
|
194
|
-
return months[date.getUTCMonth()];
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
export const getDateOfMonth = (dateString) => {
|
|
198
|
-
const date = new Date(dateString);
|
|
199
|
-
return date.getUTCDate();
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
// Map roleOnStage numeric value to role name string
|
|
203
|
-
// These correspond to the lineup position roles in the operator panel
|
|
204
|
-
const ROLE_ON_STAGE_MAP = {
|
|
205
|
-
0: "Performer",
|
|
206
|
-
1: "Host",
|
|
207
|
-
2: "Headliner",
|
|
208
|
-
3: "Feature",
|
|
209
|
-
4: "Special Guest",
|
|
210
|
-
5: "Opener",
|
|
211
|
-
6: "Guest",
|
|
212
|
-
7: "Teacher",
|
|
213
|
-
8: "Assistant",
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export const getRoleFromRoleOnStage = (roleOnStage) => {
|
|
217
|
-
return ROLE_ON_STAGE_MAP[roleOnStage] || "Performer";
|
|
218
|
-
};
|
|
219
|
-
|
|
220
|
-
// Format Event as Show for Listing data
|
|
221
|
-
export const formatEvent = (event) => {
|
|
222
|
-
// Get venue stage name (the physical stage at the venue, e.g., "Main Room", "Showroom")
|
|
223
|
-
// Not to be confused with performer's stage name (their performance alias)
|
|
224
|
-
const venueStageName = event.Event.stage?.name || event.Event.stage?.googleName || event.Event.googleName || "";
|
|
225
|
-
|
|
226
|
-
// Handle potentially undefined venue address
|
|
227
|
-
const venueAddress = event.Event.venue.address || "";
|
|
228
|
-
|
|
229
|
-
// Map roleOnStage number to role name string
|
|
230
|
-
const role = getRoleFromRoleOnStage(event.roleOnStage);
|
|
231
|
-
|
|
232
|
-
// Get custom booking notification message from venue (set in venue edit page)
|
|
233
|
-
const bookingMessage = event.Event.venue.booking_notification || "No additional details available.";
|
|
234
|
-
|
|
235
|
-
return {
|
|
236
|
-
eventId: event.Event.ID,
|
|
237
|
-
venueId: event.Event.venue.ID,
|
|
238
|
-
title: event.Event.title,
|
|
239
|
-
role: role,
|
|
240
|
-
startDateTime: event.Event.startDateTime,
|
|
241
|
-
acceptedState: event.acceptedState,
|
|
242
|
-
doorsOpenTime: event.Event.doorsOpenTime,
|
|
243
|
-
spotDuration: `${event.setLength} min spot`,
|
|
244
|
-
venueName: event.Event.venue.name,
|
|
245
|
-
location: venueAddress,
|
|
246
|
-
id: event.invitationId,
|
|
247
|
-
image: event.Event.image,
|
|
248
|
-
details: {
|
|
249
|
-
venue: event.Event.venue.name,
|
|
250
|
-
stageName: venueStageName,
|
|
251
|
-
address: venueAddress,
|
|
252
|
-
setLength: `${event.setLength} min`,
|
|
253
|
-
eventDetails: bookingMessage,
|
|
254
|
-
},
|
|
255
|
-
lastUpdated: event.UpdatedAt,
|
|
256
|
-
};
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
export const formatRosterEventPerformerInvite = (event) => {
|
|
260
|
-
console.log("whats in this venue", event);
|
|
261
|
-
return {
|
|
262
|
-
venueId: event.venueId,
|
|
263
|
-
role: event.role || "Performer",
|
|
264
|
-
acceptedState: event.acceptedState,
|
|
265
|
-
name: event.Venue.name,
|
|
266
|
-
shortVenue: `${event.Venue.firstName} ${event.Venue.lastName} - ${event.Venue.role}`,
|
|
267
|
-
location: `${event.Venue.address}`,
|
|
268
|
-
id: event.invitationId,
|
|
269
|
-
lastUpdated: event.UpdatedAt,
|
|
270
|
-
image: event.Venue.image,
|
|
271
|
-
hasAvailability: true,
|
|
272
|
-
invitationAccepted: event.acceptedState === 2,
|
|
273
|
-
};
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
export const formatVenue = (event) => {
|
|
277
|
-
return {
|
|
278
|
-
venueId: event.Event.venueId,
|
|
279
|
-
name: event.Event.venue.name,
|
|
280
|
-
image: event.Event.venue.squareImageUrl || event.Event.venue.image,
|
|
281
|
-
location: `${event.Event.venue.address}`,
|
|
282
|
-
start: event.Event.startDateTime,
|
|
283
|
-
end: event.Event.endDateTime,
|
|
284
|
-
doorOpen: event.Event.doorsOpenTime,
|
|
285
|
-
email: event.Event.venue.email,
|
|
286
|
-
phone: event.Event.venue.phone,
|
|
287
|
-
description: event.Event.venue.description,
|
|
288
|
-
instagram: event.Event.venue.instagram,
|
|
289
|
-
facebook: event.Event.venue.facebook,
|
|
290
|
-
twitter: event.Event.venue.twitter,
|
|
291
|
-
lastUpdated: event.UpdatedAt,
|
|
292
|
-
timeRange: formatTimeRange(event.Event.startDateTime, event.Event.endDateTime),
|
|
293
|
-
dateRange: getDateRange(event.Event.startDateTime, event.Event.endDateTime),
|
|
294
|
-
};
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
export function capitalize(word) {
|
|
298
|
-
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
export function timeAgo(date) {
|
|
302
|
-
const now = new Date();
|
|
303
|
-
const seconds = Math.floor((now - new Date(date)) / 1000);
|
|
304
|
-
const minutes = Math.floor(seconds / 60);
|
|
305
|
-
const hours = Math.floor(minutes / 60);
|
|
306
|
-
const days = Math.floor(hours / 24);
|
|
307
|
-
const months = Math.floor(days / 30);
|
|
308
|
-
const years = Math.floor(months / 12);
|
|
309
|
-
|
|
310
|
-
if (seconds < 60) {
|
|
311
|
-
return `${seconds} second${seconds !== 1 ? "s" : ""} ago`;
|
|
312
|
-
} else if (minutes < 60) {
|
|
313
|
-
return `${minutes} minute${minutes !== 1 ? "s" : ""} ago`;
|
|
314
|
-
} else if (hours < 24) {
|
|
315
|
-
return `${hours} hour${hours !== 1 ? "s" : ""} ago`;
|
|
316
|
-
} else if (days < 30) {
|
|
317
|
-
return `${days} day${days !== 1 ? "s" : ""} ago`;
|
|
318
|
-
} else if (months < 12) {
|
|
319
|
-
return `${months} month${months !== 1 ? "s" : ""} ago`;
|
|
320
|
-
} else {
|
|
321
|
-
return `${years} year${years !== 1 ? "s" : ""} ago`;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
|
|
4
|
+
export function cn(...inputs) {
|
|
5
|
+
return twMerge(clsx(inputs));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function convertToDate(value) {
|
|
9
|
+
return value ? new Date(value).toDateString() : null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function classNames(...classes) {
|
|
13
|
+
return classes.filter(Boolean).join(" ");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function truncateTitle(title, maxLength) {
|
|
17
|
+
if (title.length > maxLength) {
|
|
18
|
+
return title.slice(0, maxLength) + "...";
|
|
19
|
+
}
|
|
20
|
+
return title;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function convertToCustomDateFormat(isoString) {
|
|
24
|
+
const date = new Date(isoString);
|
|
25
|
+
|
|
26
|
+
const year = date.getUTCFullYear();
|
|
27
|
+
const month = date.getUTCMonth();
|
|
28
|
+
const day = date.getUTCDate();
|
|
29
|
+
|
|
30
|
+
const customDate = new Date(year, month, day);
|
|
31
|
+
|
|
32
|
+
return customDate;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function convertToCustomDateTimeFormat(isoDateString) {
|
|
36
|
+
const date = new Date(isoDateString);
|
|
37
|
+
return new Date(
|
|
38
|
+
Date.UTC(
|
|
39
|
+
date.getUTCFullYear(),
|
|
40
|
+
date.getUTCMonth(),
|
|
41
|
+
date.getUTCDate(),
|
|
42
|
+
date.getUTCHours(),
|
|
43
|
+
date.getUTCMinutes()
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function formatHour(dateString) {
|
|
49
|
+
const date = new Date(dateString);
|
|
50
|
+
const hour = date.getUTCHours();
|
|
51
|
+
const minutes = date.getUTCMinutes();
|
|
52
|
+
const suffix = hour >= 12 ? "PM" : "AM";
|
|
53
|
+
const displayHour = hour % 12 || 12;
|
|
54
|
+
|
|
55
|
+
// Ensure minutes are always two digits
|
|
56
|
+
const displayMinutes = minutes < 10 ? "0" + minutes : minutes;
|
|
57
|
+
|
|
58
|
+
return `${displayHour}:${displayMinutes} ${suffix}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function formattedDate(date) {
|
|
62
|
+
const options = {
|
|
63
|
+
weekday: "short", // 'Thu'
|
|
64
|
+
month: "short", // 'Oct'
|
|
65
|
+
day: "2-digit", // '24'
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return new Date(date).toLocaleDateString("en-US", options);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function formattedFullDate(date) {
|
|
72
|
+
const options = {
|
|
73
|
+
weekday: "long", // 'Thursday'
|
|
74
|
+
month: "long", // 'October'
|
|
75
|
+
day: "numeric", // '24'
|
|
76
|
+
year: "numeric", // '2024'
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const formattedDate = new Date(date).toLocaleDateString("en-US", options);
|
|
80
|
+
|
|
81
|
+
// Get the day of the month to append the ordinal suffix
|
|
82
|
+
const day = new Date(date).getDate();
|
|
83
|
+
const ordinalSuffix = getOrdinalSuffix(day);
|
|
84
|
+
|
|
85
|
+
// Replace the day number with the day + ordinal suffix
|
|
86
|
+
const fullDate = formattedDate.replace(/\d+/, day + ordinalSuffix);
|
|
87
|
+
return fullDate;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Helper function to get the ordinal suffix (st, nd, rd, th)
|
|
91
|
+
function getOrdinalSuffix(day) {
|
|
92
|
+
if (day >= 11 && day <= 13) return "th"; // Special case for 11th, 12th, and 13th
|
|
93
|
+
switch (day % 10) {
|
|
94
|
+
case 1:
|
|
95
|
+
return "st";
|
|
96
|
+
case 2:
|
|
97
|
+
return "nd";
|
|
98
|
+
case 3:
|
|
99
|
+
return "rd";
|
|
100
|
+
default:
|
|
101
|
+
return "th";
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const formatDateTime = (dateTimeString, timeZone = "UTC") => {
|
|
106
|
+
const options = {
|
|
107
|
+
weekday: "short", // Mon, Tue, etc.
|
|
108
|
+
year: "numeric", // 2024
|
|
109
|
+
month: "short", // Dec
|
|
110
|
+
day: "numeric", // 12
|
|
111
|
+
hour: "numeric", // 11
|
|
112
|
+
minute: "numeric", // 00
|
|
113
|
+
hour12: true, // 11:00 PM format
|
|
114
|
+
timeZone: timeZone, // Account for the timezone, defaults to 'UTC'
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const date = new Date(dateTimeString);
|
|
118
|
+
|
|
119
|
+
return new Intl.DateTimeFormat("en-US", options).format(date);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const formatTimeline = (startDateTime) => {
|
|
123
|
+
const formatHour = (date) => {
|
|
124
|
+
let hours = date.getUTCHours();
|
|
125
|
+
const minutes = date.getUTCMinutes();
|
|
126
|
+
const suffix = hours >= 12 ? "PM" : "AM";
|
|
127
|
+
hours = hours % 12 || 12;
|
|
128
|
+
|
|
129
|
+
return `${hours}:${minutes < 10 ? "0" + minutes : minutes} ${suffix}`;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const start = formatHour(new Date(startDateTime));
|
|
133
|
+
return `${start}`;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export function formatTimeRange(startDate, endDate) {
|
|
137
|
+
const start = new Date(startDate);
|
|
138
|
+
const end = new Date(endDate);
|
|
139
|
+
|
|
140
|
+
function formatTime(date) {
|
|
141
|
+
let hours = date.getUTCHours();
|
|
142
|
+
const minutes = date.getUTCMinutes();
|
|
143
|
+
const ampm = hours >= 12 ? "PM" : "AM";
|
|
144
|
+
hours = hours % 12;
|
|
145
|
+
hours = hours ? hours : 12;
|
|
146
|
+
const minutesStr = minutes < 10 ? "0" + minutes : minutes;
|
|
147
|
+
return hours + ":" + minutesStr + " " + ampm;
|
|
148
|
+
}
|
|
149
|
+
const startTime = formatTime(start);
|
|
150
|
+
const endTime = formatTime(end);
|
|
151
|
+
return `${startTime} - ${endTime}`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export function getDateRange(startDate, endDate) {
|
|
155
|
+
const start = new Date(startDate);
|
|
156
|
+
const end = new Date(endDate);
|
|
157
|
+
|
|
158
|
+
const dateArray = [];
|
|
159
|
+
const currentDate = new Date(start);
|
|
160
|
+
|
|
161
|
+
while (currentDate <= end) {
|
|
162
|
+
dateArray.push(
|
|
163
|
+
`${currentDate.getUTCFullYear()}-${currentDate.getUTCMonth() + 1
|
|
164
|
+
}-${currentDate.getUTCDate()}`
|
|
165
|
+
);
|
|
166
|
+
currentDate.setUTCDate(currentDate.getUTCDate() + 1); // Move to the next day
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return dateArray;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export const getDay = (dateString) => {
|
|
173
|
+
const days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
174
|
+
const date = new Date(dateString);
|
|
175
|
+
return days[date.getUTCDay()];
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export const getMonth = (dateString) => {
|
|
179
|
+
const months = [
|
|
180
|
+
"Jan",
|
|
181
|
+
"Feb",
|
|
182
|
+
"Mar",
|
|
183
|
+
"Apr",
|
|
184
|
+
"May",
|
|
185
|
+
"Jun",
|
|
186
|
+
"Jul",
|
|
187
|
+
"Aug",
|
|
188
|
+
"Sep",
|
|
189
|
+
"Oct",
|
|
190
|
+
"Nov",
|
|
191
|
+
"Dec",
|
|
192
|
+
];
|
|
193
|
+
const date = new Date(dateString);
|
|
194
|
+
return months[date.getUTCMonth()];
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export const getDateOfMonth = (dateString) => {
|
|
198
|
+
const date = new Date(dateString);
|
|
199
|
+
return date.getUTCDate();
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
// Map roleOnStage numeric value to role name string
|
|
203
|
+
// These correspond to the lineup position roles in the operator panel
|
|
204
|
+
const ROLE_ON_STAGE_MAP = {
|
|
205
|
+
0: "Performer",
|
|
206
|
+
1: "Host",
|
|
207
|
+
2: "Headliner",
|
|
208
|
+
3: "Feature",
|
|
209
|
+
4: "Special Guest",
|
|
210
|
+
5: "Opener",
|
|
211
|
+
6: "Guest",
|
|
212
|
+
7: "Teacher",
|
|
213
|
+
8: "Assistant",
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export const getRoleFromRoleOnStage = (roleOnStage) => {
|
|
217
|
+
return ROLE_ON_STAGE_MAP[roleOnStage] || "Performer";
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// Format Event as Show for Listing data
|
|
221
|
+
export const formatEvent = (event) => {
|
|
222
|
+
// Get venue stage name (the physical stage at the venue, e.g., "Main Room", "Showroom")
|
|
223
|
+
// Not to be confused with performer's stage name (their performance alias)
|
|
224
|
+
const venueStageName = event.Event.stage?.name || event.Event.stage?.googleName || event.Event.googleName || "";
|
|
225
|
+
|
|
226
|
+
// Handle potentially undefined venue address
|
|
227
|
+
const venueAddress = event.Event.venue.address || "";
|
|
228
|
+
|
|
229
|
+
// Map roleOnStage number to role name string
|
|
230
|
+
const role = getRoleFromRoleOnStage(event.roleOnStage);
|
|
231
|
+
|
|
232
|
+
// Get custom booking notification message from venue (set in venue edit page)
|
|
233
|
+
const bookingMessage = event.Event.venue.booking_notification || "No additional details available.";
|
|
234
|
+
|
|
235
|
+
return {
|
|
236
|
+
eventId: event.Event.ID,
|
|
237
|
+
venueId: event.Event.venue.ID,
|
|
238
|
+
title: event.Event.title,
|
|
239
|
+
role: role,
|
|
240
|
+
startDateTime: event.Event.startDateTime,
|
|
241
|
+
acceptedState: event.acceptedState,
|
|
242
|
+
doorsOpenTime: event.Event.doorsOpenTime,
|
|
243
|
+
spotDuration: `${event.setLength} min spot`,
|
|
244
|
+
venueName: event.Event.venue.name,
|
|
245
|
+
location: venueAddress,
|
|
246
|
+
id: event.invitationId,
|
|
247
|
+
image: event.Event.image,
|
|
248
|
+
details: {
|
|
249
|
+
venue: event.Event.venue.name,
|
|
250
|
+
stageName: venueStageName,
|
|
251
|
+
address: venueAddress,
|
|
252
|
+
setLength: `${event.setLength} min`,
|
|
253
|
+
eventDetails: bookingMessage,
|
|
254
|
+
},
|
|
255
|
+
lastUpdated: event.UpdatedAt,
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export const formatRosterEventPerformerInvite = (event) => {
|
|
260
|
+
console.log("whats in this venue", event);
|
|
261
|
+
return {
|
|
262
|
+
venueId: event.venueId,
|
|
263
|
+
role: event.role || "Performer",
|
|
264
|
+
acceptedState: event.acceptedState,
|
|
265
|
+
name: event.Venue.name,
|
|
266
|
+
shortVenue: `${event.Venue.firstName} ${event.Venue.lastName} - ${event.Venue.role}`,
|
|
267
|
+
location: `${event.Venue.address}`,
|
|
268
|
+
id: event.invitationId,
|
|
269
|
+
lastUpdated: event.UpdatedAt,
|
|
270
|
+
image: event.Venue.image,
|
|
271
|
+
hasAvailability: true,
|
|
272
|
+
invitationAccepted: event.acceptedState === 2,
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export const formatVenue = (event) => {
|
|
277
|
+
return {
|
|
278
|
+
venueId: event.Event.venueId,
|
|
279
|
+
name: event.Event.venue.name,
|
|
280
|
+
image: event.Event.venue.squareImageUrl || event.Event.venue.image,
|
|
281
|
+
location: `${event.Event.venue.address}`,
|
|
282
|
+
start: event.Event.startDateTime,
|
|
283
|
+
end: event.Event.endDateTime,
|
|
284
|
+
doorOpen: event.Event.doorsOpenTime,
|
|
285
|
+
email: event.Event.venue.email,
|
|
286
|
+
phone: event.Event.venue.phone,
|
|
287
|
+
description: event.Event.venue.description,
|
|
288
|
+
instagram: event.Event.venue.instagram,
|
|
289
|
+
facebook: event.Event.venue.facebook,
|
|
290
|
+
twitter: event.Event.venue.twitter,
|
|
291
|
+
lastUpdated: event.UpdatedAt,
|
|
292
|
+
timeRange: formatTimeRange(event.Event.startDateTime, event.Event.endDateTime),
|
|
293
|
+
dateRange: getDateRange(event.Event.startDateTime, event.Event.endDateTime),
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
export function capitalize(word) {
|
|
298
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export function timeAgo(date) {
|
|
302
|
+
const now = new Date();
|
|
303
|
+
const seconds = Math.floor((now - new Date(date)) / 1000);
|
|
304
|
+
const minutes = Math.floor(seconds / 60);
|
|
305
|
+
const hours = Math.floor(minutes / 60);
|
|
306
|
+
const days = Math.floor(hours / 24);
|
|
307
|
+
const months = Math.floor(days / 30);
|
|
308
|
+
const years = Math.floor(months / 12);
|
|
309
|
+
|
|
310
|
+
if (seconds < 60) {
|
|
311
|
+
return `${seconds} second${seconds !== 1 ? "s" : ""} ago`;
|
|
312
|
+
} else if (minutes < 60) {
|
|
313
|
+
return `${minutes} minute${minutes !== 1 ? "s" : ""} ago`;
|
|
314
|
+
} else if (hours < 24) {
|
|
315
|
+
return `${hours} hour${hours !== 1 ? "s" : ""} ago`;
|
|
316
|
+
} else if (days < 30) {
|
|
317
|
+
return `${days} day${days !== 1 ? "s" : ""} ago`;
|
|
318
|
+
} else if (months < 12) {
|
|
319
|
+
return `${months} month${months !== 1 ? "s" : ""} ago`;
|
|
320
|
+
} else {
|
|
321
|
+
return `${years} year${years !== 1 ? "s" : ""} ago`;
|
|
322
|
+
}
|
|
323
|
+
}
|