@getmicdrop/svelte-components 5.3.13 → 5.3.14

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.
@@ -1,50 +1,120 @@
1
- /**
2
- * API Configuration utility
3
- * Centralized place to manage API base URL
4
- */
5
-
6
- // Get API base URL from environment variable or fallback to default
7
- export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'https://get-micdrop.com';
8
-
9
- // Get frontend base URL from environment variable or derive from API URL
10
- export const FRONTEND_BASE_URL = import.meta.env.VITE_FRONTEND_BASE_URL ||
11
- (API_BASE_URL.includes('get-micdrop.com') ? 'https://performers.get-micdrop.com' : 'http://localhost:5173');
12
-
13
- /**
14
- * Helper function to build API endpoints
15
- * @param {string} path - The API path (e.g., '/api/public/login')
16
- * @returns {string} - Full API URL
17
- */
18
- export function buildApiUrl(path) {
19
- // Ensure path starts with /
20
- const cleanPath = path.startsWith('/') ? path : `/${path}`;
21
- return `${API_BASE_URL}${cleanPath}`;
22
- }
23
-
24
- /**
25
- * Common API endpoints
26
- */
27
- export const API_ENDPOINTS = {
28
- // Auth
29
- LOGIN: '/api/public/login',
30
-
31
- // Performer
32
- PERFORMER_PROFILE: '/api/performer/getPerformerProfile',
33
- MODIFY_PERFORMER_PROFILE: '/api/performer/modifyPerformerProfile',
34
- PERFORMER_AVAILABILITIES: '/api/performer/performerAvailabilities',
35
- GET_EVENT_PERFORMER_INVITES: '/api/performer/getEventPerformerInvites',
36
- GET_ROSTER_EVENT_PERFORMERS_FOR_USER: '/api/performer/getRosterEventPerformersForUser',
37
-
38
- // Public
39
- GET_EVENTS_FOR_VENUE: '/api/public/getEventsForVenue',
40
- GET_VENUE: '/api/public/getVenue',
41
- ACCEPT_EVENT_PERFORMER_INVITE: '/api/public/acceptEventPerformerInvite',
42
- DECLINE_EVENT_PERFORMER_INVITE: '/api/public/declineEventPerformerInvite',
43
- CANCEL_EVENT_PERFORMER_INVITE: '/api/public/cancelEventPerformerInvite',
44
- SEND_VENUE_MESSAGE: '/api/performer/sendVenueMessage',
45
- REJECT_ROSTER_INVITE: '/api/public/rejectRosterInvite',
46
- REMOVE_VENUE_FROM_ROSTER: '/api/performer/removeVenueFromRoster',
47
-
48
- // Ticketing
49
- TICKETING_EVENTS: 'icketing/events', // Note: This appears to be missing the 't' in the original
50
- };
1
+ /**
2
+ * API Configuration - Centralized URL and version management
3
+ * @module utils/apiConfig
4
+ */
5
+
6
+ export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'https://get-micdrop.com';
7
+
8
+ export const FRONTEND_BASE_URL = import.meta.env.VITE_FRONTEND_BASE_URL ||
9
+ (API_BASE_URL.includes('get-micdrop.com') ? 'https://performers.get-micdrop.com' : 'http://localhost:5173');
10
+
11
+ export const API_VERSION = import.meta.env.VITE_API_VERSION || 'v1';
12
+ export const USE_V2_API = API_VERSION === 'v2';
13
+
14
+ /**
15
+ * @param {string} path - API path starting with /
16
+ * @returns {string} Full API URL
17
+ */
18
+ export function buildApiUrl(path) {
19
+ const cleanPath = path.startsWith('/') ? path : `/${path}`;
20
+ return `${API_BASE_URL}${cleanPath}`;
21
+ }
22
+
23
+ export const API_ENDPOINTS_V1 = {
24
+ // Auth
25
+ LOGIN: '/api/public/login',
26
+
27
+ // Performer
28
+ PERFORMER_PROFILE: '/api/performer/getPerformerProfile',
29
+ MODIFY_PERFORMER_PROFILE: '/api/performer/modifyPerformerProfile',
30
+ PERFORMER_AVAILABILITIES: '/api/performer/performerAvailabilities',
31
+ GET_EVENT_PERFORMER_INVITES: '/api/performer/getEventPerformerInvites',
32
+ GET_ROSTER_EVENT_PERFORMERS_FOR_USER: '/api/performer/getRosterEventPerformersForUser',
33
+
34
+ // Public
35
+ GET_EVENTS_FOR_VENUE: '/api/public/getEventsForVenue',
36
+ GET_VENUE: '/api/public/getVenue',
37
+ ACCEPT_EVENT_PERFORMER_INVITE: '/api/public/acceptEventPerformerInvite',
38
+ DECLINE_EVENT_PERFORMER_INVITE: '/api/public/declineEventPerformerInvite',
39
+ CANCEL_EVENT_PERFORMER_INVITE: '/api/public/cancelEventPerformerInvite',
40
+ SEND_VENUE_MESSAGE: '/api/performer/sendVenueMessage',
41
+ REJECT_ROSTER_INVITE: '/api/public/rejectRosterInvite',
42
+ REMOVE_VENUE_FROM_ROSTER: '/api/performer/removeVenueFromRoster',
43
+
44
+ // Ticketing
45
+ TICKETING_EVENTS: '/ticketing/events',
46
+ };
47
+
48
+ export const API_ENDPOINTS_V2 = {
49
+ // Auth
50
+ LOGIN: '/api/public/login',
51
+
52
+ // Performer
53
+ PERFORMER_PROFILE: '/api/performer/getPerformerProfile',
54
+ MODIFY_PERFORMER_PROFILE: '/api/performer/modifyPerformerProfile',
55
+ PERFORMER_AVAILABILITIES: '/api/performer/performerAvailabilities',
56
+ GET_EVENT_PERFORMER_INVITES: '/api/performer/getEventPerformerInvites',
57
+ GET_ROSTER_EVENT_PERFORMERS_FOR_USER: '/api/performer/getRosterEventPerformersForUser',
58
+
59
+ // Public
60
+ GET_EVENTS_FOR_VENUE: '/api/public/getEventsForVenue',
61
+ GET_VENUE: '/api/public/getVenue',
62
+ SEND_VENUE_MESSAGE: '/api/performer/sendVenueMessage',
63
+ REJECT_ROSTER_INVITE: '/api/public/rejectRosterInvite',
64
+ REMOVE_VENUE_FROM_ROSTER: '/api/performer/removeVenueFromRoster',
65
+
66
+ // V2 Event Performer endpoints
67
+ CONFIRM_EVENT_PERFORMER: '/api/v2/event-performers',
68
+ DECLINE_EVENT_PERFORMER: '/api/v2/event-performers',
69
+ ACCEPT_EVENT_PERFORMER_INVITE: '/api/v2/event-performers',
70
+ DECLINE_EVENT_PERFORMER_INVITE: '/api/v2/event-performers',
71
+ CANCEL_EVENT_PERFORMER_INVITE: '/api/public/cancelEventPerformerInvite',
72
+
73
+ // Ticketing
74
+ TICKETING_EVENTS: '/ticketing/events',
75
+ };
76
+
77
+ /** Current API endpoints based on version */
78
+ export const API_ENDPOINTS = USE_V2_API ? API_ENDPOINTS_V2 : API_ENDPOINTS_V1;
79
+
80
+ /**
81
+ * Build URL for V2 performer actions
82
+ * @param {string|number} eventPerformerId
83
+ * @param {'confirm'|'decline'|'reassign'} action
84
+ * @returns {string} Full API URL
85
+ */
86
+ export function buildV2PerformerActionUrl(eventPerformerId, action) {
87
+ return buildApiUrl(`/api/v2/event-performers/${eventPerformerId}/${action}`);
88
+ }
89
+
90
+ /**
91
+ * Build URL for performer invite actions (handles V1/V2 differences)
92
+ * @param {string|number} inviteId
93
+ * @param {'accept'|'decline'|'cancel'} action
94
+ * @returns {string} Full API URL
95
+ */
96
+ export function buildPerformerInviteUrl(inviteId, action) {
97
+ if (USE_V2_API) {
98
+ const v2Action = action === 'accept' ? 'confirm' : action;
99
+ if (v2Action === 'cancel') {
100
+ return buildApiUrl(`${API_ENDPOINTS_V1.CANCEL_EVENT_PERFORMER_INVITE}/${inviteId}`);
101
+ }
102
+ return buildApiUrl(`/api/v2/event-performers/${inviteId}/${v2Action}`);
103
+ }
104
+
105
+ const v1Endpoint = action === 'accept'
106
+ ? API_ENDPOINTS_V1.ACCEPT_EVENT_PERFORMER_INVITE
107
+ : action === 'decline'
108
+ ? API_ENDPOINTS_V1.DECLINE_EVENT_PERFORMER_INVITE
109
+ : API_ENDPOINTS_V1.CANCEL_EVENT_PERFORMER_INVITE;
110
+ return buildApiUrl(`${v1Endpoint}/${inviteId}`);
111
+ }
112
+
113
+ /**
114
+ * Get HTTP method for performer invite actions
115
+ * @param {'accept'|'decline'|'cancel'} action
116
+ * @returns {'PUT'|'POST'} HTTP method
117
+ */
118
+ export function getPerformerInviteMethod(action) {
119
+ return USE_V2_API && action !== 'cancel' ? 'POST' : 'PUT';
120
+ }
@@ -1,323 +1,3 @@
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
+ // Re-export everything from the consolidated utils.js
2
+ // This file is kept for backward compatibility
3
+ export * from '../utils.js';