@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/apiConfig.js
CHANGED
|
@@ -8,7 +8,7 @@ export const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'https://get-mi
|
|
|
8
8
|
export const FRONTEND_BASE_URL = import.meta.env.VITE_FRONTEND_BASE_URL ||
|
|
9
9
|
(API_BASE_URL.includes('get-micdrop.com') ? 'https://performers.get-micdrop.com' : 'http://localhost:5173');
|
|
10
10
|
|
|
11
|
-
export const API_VERSION = import.meta.env.VITE_API_VERSION || '
|
|
11
|
+
export const API_VERSION = import.meta.env.VITE_API_VERSION || 'v2';
|
|
12
12
|
export const USE_V2_API = API_VERSION === 'v2';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -56,90 +56,97 @@ describe('apiConfig', () => {
|
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
describe('API_ENDPOINTS', () => {
|
|
59
|
+
describe('API_ENDPOINTS (defaults to V2)', () => {
|
|
60
60
|
it('has LOGIN endpoint', () => {
|
|
61
|
-
expect(API_ENDPOINTS.LOGIN).toBe('/api/
|
|
61
|
+
expect(API_ENDPOINTS.LOGIN).toBe('/api/v2/auth/login');
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
it('has PERFORMER_PROFILE endpoint', () => {
|
|
65
|
-
expect(API_ENDPOINTS.PERFORMER_PROFILE).toBe('/api/performer/
|
|
65
|
+
expect(API_ENDPOINTS.PERFORMER_PROFILE).toBe('/api/v2/performer/profile');
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
it('has MODIFY_PERFORMER_PROFILE endpoint', () => {
|
|
69
|
-
expect(API_ENDPOINTS.MODIFY_PERFORMER_PROFILE).toBe('/api/performer/
|
|
69
|
+
expect(API_ENDPOINTS.MODIFY_PERFORMER_PROFILE).toBe('/api/v2/performer/profile');
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
it('has PERFORMER_AVAILABILITIES endpoint', () => {
|
|
73
|
-
expect(API_ENDPOINTS.PERFORMER_AVAILABILITIES).toBe('/api/performer/
|
|
73
|
+
expect(API_ENDPOINTS.PERFORMER_AVAILABILITIES).toBe('/api/v2/performer/availabilities');
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
it('has GET_EVENT_PERFORMER_INVITES endpoint', () => {
|
|
77
|
-
expect(API_ENDPOINTS.GET_EVENT_PERFORMER_INVITES).toBe('/api/performer/
|
|
77
|
+
expect(API_ENDPOINTS.GET_EVENT_PERFORMER_INVITES).toBe('/api/v2/performer/invites');
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
it('has GET_ROSTER_EVENT_PERFORMERS_FOR_USER endpoint', () => {
|
|
81
|
-
expect(API_ENDPOINTS.GET_ROSTER_EVENT_PERFORMERS_FOR_USER).toBe('/api/
|
|
81
|
+
expect(API_ENDPOINTS.GET_ROSTER_EVENT_PERFORMERS_FOR_USER).toBe('/api/v2/performers/roster');
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
it('has GET_EVENTS_FOR_VENUE endpoint', () => {
|
|
85
|
-
expect(API_ENDPOINTS.GET_EVENTS_FOR_VENUE).toBe('/api/public/
|
|
85
|
+
expect(API_ENDPOINTS.GET_EVENTS_FOR_VENUE).toBe('/api/v2/public/events/venue');
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
it('has GET_VENUE endpoint', () => {
|
|
89
|
-
expect(API_ENDPOINTS.GET_VENUE).toBe('/api/public/
|
|
89
|
+
expect(API_ENDPOINTS.GET_VENUE).toBe('/api/v2/public/venues');
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it('has ACCEPT_EVENT_PERFORMER_INVITE endpoint', () => {
|
|
93
|
-
expect(API_ENDPOINTS.ACCEPT_EVENT_PERFORMER_INVITE).toBe('/api/
|
|
93
|
+
expect(API_ENDPOINTS.ACCEPT_EVENT_PERFORMER_INVITE).toBe('/api/v2/event-performers');
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
it('has DECLINE_EVENT_PERFORMER_INVITE endpoint', () => {
|
|
97
|
-
expect(API_ENDPOINTS.DECLINE_EVENT_PERFORMER_INVITE).toBe('/api/
|
|
97
|
+
expect(API_ENDPOINTS.DECLINE_EVENT_PERFORMER_INVITE).toBe('/api/v2/event-performers');
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
it('has CANCEL_EVENT_PERFORMER_INVITE endpoint', () => {
|
|
101
|
-
expect(API_ENDPOINTS.CANCEL_EVENT_PERFORMER_INVITE).toBe('/api/
|
|
101
|
+
expect(API_ENDPOINTS.CANCEL_EVENT_PERFORMER_INVITE).toBe('/api/v2/event-performers');
|
|
102
102
|
});
|
|
103
103
|
|
|
104
104
|
it('has SEND_VENUE_MESSAGE endpoint', () => {
|
|
105
|
-
expect(API_ENDPOINTS.SEND_VENUE_MESSAGE).toBe('/api/performer/
|
|
105
|
+
expect(API_ENDPOINTS.SEND_VENUE_MESSAGE).toBe('/api/v2/performer/invites');
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
it('has REJECT_ROSTER_INVITE endpoint', () => {
|
|
109
|
-
expect(API_ENDPOINTS.REJECT_ROSTER_INVITE).toBe('/api/public/
|
|
109
|
+
expect(API_ENDPOINTS.REJECT_ROSTER_INVITE).toBe('/api/v2/public/roster-invites');
|
|
110
110
|
});
|
|
111
111
|
|
|
112
112
|
it('has REMOVE_VENUE_FROM_ROSTER endpoint', () => {
|
|
113
|
-
expect(API_ENDPOINTS.REMOVE_VENUE_FROM_ROSTER).toBe('/api/performer/
|
|
113
|
+
expect(API_ENDPOINTS.REMOVE_VENUE_FROM_ROSTER).toBe('/api/v2/performer/venues');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('has TICKETING_EVENTS endpoint', () => {
|
|
117
|
+
expect(API_ENDPOINTS.TICKETING_EVENTS).toBe('/ticketing/events');
|
|
114
118
|
});
|
|
115
119
|
|
|
116
120
|
it('uses buildApiUrl for full URLs', () => {
|
|
117
121
|
const loginUrl = buildApiUrl(API_ENDPOINTS.LOGIN);
|
|
118
|
-
expect(loginUrl).toContain('/api/
|
|
122
|
+
expect(loginUrl).toContain('/api/v2/auth/login');
|
|
119
123
|
});
|
|
120
124
|
});
|
|
121
125
|
|
|
122
|
-
describe('buildPerformerInviteUrl', () => {
|
|
123
|
-
it('builds
|
|
126
|
+
describe('buildPerformerInviteUrl (defaults to V2)', () => {
|
|
127
|
+
it('builds V2 accept URL (maps to confirm)', () => {
|
|
124
128
|
const url = buildPerformerInviteUrl(123, 'accept');
|
|
125
|
-
expect(url).toContain('/api/
|
|
129
|
+
expect(url).toContain('/api/v2/event-performers/123/confirm');
|
|
126
130
|
});
|
|
127
131
|
|
|
128
|
-
it('builds
|
|
132
|
+
it('builds V2 decline URL', () => {
|
|
129
133
|
const url = buildPerformerInviteUrl(456, 'decline');
|
|
130
|
-
expect(url).toContain('/api/
|
|
134
|
+
expect(url).toContain('/api/v2/event-performers/456/decline');
|
|
131
135
|
});
|
|
132
136
|
|
|
133
|
-
it('builds
|
|
137
|
+
it('builds V2 cancel URL', () => {
|
|
134
138
|
const url = buildPerformerInviteUrl(789, 'cancel');
|
|
135
|
-
expect(url).toContain('/api/
|
|
139
|
+
expect(url).toContain('/api/v2/event-performers/789/cancel');
|
|
136
140
|
});
|
|
137
141
|
});
|
|
138
142
|
|
|
139
|
-
describe('getPerformerInviteMethod', () => {
|
|
140
|
-
it('returns
|
|
141
|
-
expect(getPerformerInviteMethod('accept')).toBe('
|
|
142
|
-
expect(getPerformerInviteMethod('decline')).toBe('
|
|
143
|
+
describe('getPerformerInviteMethod (defaults to V2)', () => {
|
|
144
|
+
it('returns POST for V2 accept and decline actions', () => {
|
|
145
|
+
expect(getPerformerInviteMethod('accept')).toBe('POST');
|
|
146
|
+
expect(getPerformerInviteMethod('decline')).toBe('POST');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('returns PUT for V2 cancel action', () => {
|
|
143
150
|
expect(getPerformerInviteMethod('cancel')).toBe('PUT');
|
|
144
151
|
});
|
|
145
152
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/lib/utils/assets.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,iCAAiC,CAAC;AAGpE,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Join class names, filtering out falsy values.
|
|
3
|
+
*/
|
|
4
|
+
export declare function classNames(...classes: unknown[]): string;
|
|
5
|
+
/**
|
|
6
|
+
* Merge Tailwind CSS classes with conflict resolution.
|
|
7
|
+
* Combines clsx (conditional classes) with tailwind-merge (conflict resolution).
|
|
8
|
+
*/
|
|
9
|
+
export declare function cn(...inputs: unknown[]): string;
|
|
10
|
+
//# sourceMappingURL=classNames.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classNames.d.ts","sourceRoot":"","sources":["../../src/lib/utils/classNames.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAE/C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { twMerge } from "tailwind-merge";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
/**
|
|
4
|
+
* Join class names, filtering out falsy values.
|
|
5
|
+
*/
|
|
6
|
+
export function classNames(...classes) {
|
|
7
|
+
return classes.filter(Boolean).join(" ");
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Merge Tailwind CSS classes with conflict resolution.
|
|
11
|
+
* Combines clsx (conditional classes) with tailwind-merge (conflict resolution).
|
|
12
|
+
*/
|
|
13
|
+
export function cn(...inputs) {
|
|
14
|
+
return twMerge(clsx(inputs));
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clickOutside.d.ts","sourceRoot":"","sources":["../../src/lib/utils/clickOutside.js"],"names":[],"mappings":"AAAA;;EAYC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function clickOutside(node, callback) {
|
|
2
|
+
const handleClick = event => {
|
|
3
|
+
if (!node.contains(event.target)) {
|
|
4
|
+
callback();
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
document.addEventListener('mousedown', handleClick, true);
|
|
8
|
+
return {
|
|
9
|
+
destroy() {
|
|
10
|
+
document.removeEventListener('mousedown', handleClick, true);
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse all cookies into an object.
|
|
3
|
+
*/
|
|
4
|
+
export declare function parseCookies(): Record<string, string>;
|
|
5
|
+
/**
|
|
6
|
+
* Get a specific cookie value by name.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCookie(name: string): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Set a cookie with options.
|
|
11
|
+
*/
|
|
12
|
+
export declare function setCookie(name: string, value: string, options?: {
|
|
13
|
+
maxAge?: number;
|
|
14
|
+
path?: string;
|
|
15
|
+
}): void;
|
|
16
|
+
/**
|
|
17
|
+
* Get the performer token from cookies.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getPerformerToken(): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Get user details from cookies, parsed as JSON.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getUserDetails(): Record<string, unknown> | null;
|
|
24
|
+
/**
|
|
25
|
+
* Get suppressed alert IDs from cookies.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getSuppressedAlerts(): string[];
|
|
28
|
+
/**
|
|
29
|
+
* Save suppressed alert IDs to cookies (1 year expiry).
|
|
30
|
+
*/
|
|
31
|
+
export declare function saveSuppressedAlerts(alertIds: string[]): void;
|
|
32
|
+
/**
|
|
33
|
+
* Set authentication cookies with proper domain and security settings.
|
|
34
|
+
*/
|
|
35
|
+
export declare function setAuthCookies(token: string, userDetails: Record<string, unknown>, rememberMe?: boolean, refreshToken?: string | null): void;
|
|
36
|
+
/**
|
|
37
|
+
* Clear authentication cookies.
|
|
38
|
+
*/
|
|
39
|
+
export declare function clearAuthCookies(): void;
|
|
40
|
+
//# sourceMappingURL=cookieHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookieHelpers.d.ts","sourceRoot":"","sources":["../../src/lib/utils/cookieHelpers.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQrD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGrD;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/C,IAAI,CAQN;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAEjD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAQ/D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAQ9C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAE7D;AAMD;;GAEG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,UAAU,GAAE,OAAc,EAC1B,YAAY,GAAE,MAAM,GAAG,IAAW,GACjC,IAAI,CAcN;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAOvC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// ============================================
|
|
2
|
+
// COOKIE UTILITIES
|
|
3
|
+
// ============================================
|
|
4
|
+
/**
|
|
5
|
+
* Parse all cookies into an object.
|
|
6
|
+
*/
|
|
7
|
+
export function parseCookies() {
|
|
8
|
+
if (typeof document === "undefined")
|
|
9
|
+
return {};
|
|
10
|
+
return document.cookie.split("; ").reduce((acc, cookie) => {
|
|
11
|
+
if (!cookie)
|
|
12
|
+
return acc;
|
|
13
|
+
const [name, ...valueParts] = cookie.split("=");
|
|
14
|
+
acc[name] = decodeURIComponent(valueParts.join("="));
|
|
15
|
+
return acc;
|
|
16
|
+
}, {});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get a specific cookie value by name.
|
|
20
|
+
*/
|
|
21
|
+
export function getCookie(name) {
|
|
22
|
+
const cookies = parseCookies();
|
|
23
|
+
return cookies[name] || null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Set a cookie with options.
|
|
27
|
+
*/
|
|
28
|
+
export function setCookie(name, value, options = {}) {
|
|
29
|
+
const isProd = typeof window !== "undefined" && window.location.hostname.includes("get-micdrop.com");
|
|
30
|
+
const domainAttr = isProd ? "domain=.get-micdrop.com;" : "";
|
|
31
|
+
const secureAttr = typeof window !== "undefined" && window.location.protocol === "https:" ? "secure;" : "";
|
|
32
|
+
const maxAge = options.maxAge ? `max-age=${options.maxAge};` : "";
|
|
33
|
+
const path = options.path || "/";
|
|
34
|
+
document.cookie = `${name}=${encodeURIComponent(value)}; path=${path}; ${maxAge} ${domainAttr} ${secureAttr} samesite=lax`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get the performer token from cookies.
|
|
38
|
+
*/
|
|
39
|
+
export function getPerformerToken() {
|
|
40
|
+
return getCookie("performer_token");
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get user details from cookies, parsed as JSON.
|
|
44
|
+
*/
|
|
45
|
+
export function getUserDetails() {
|
|
46
|
+
const details = getCookie("userDetails");
|
|
47
|
+
if (!details)
|
|
48
|
+
return null;
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(details);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get suppressed alert IDs from cookies.
|
|
58
|
+
*/
|
|
59
|
+
export function getSuppressedAlerts() {
|
|
60
|
+
const alerts = getCookie("suppressedAlerts");
|
|
61
|
+
if (!alerts)
|
|
62
|
+
return [];
|
|
63
|
+
try {
|
|
64
|
+
return JSON.parse(alerts);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Save suppressed alert IDs to cookies (1 year expiry).
|
|
72
|
+
*/
|
|
73
|
+
export function saveSuppressedAlerts(alertIds) {
|
|
74
|
+
setCookie("suppressedAlerts", JSON.stringify(alertIds), { maxAge: 31536000 });
|
|
75
|
+
}
|
|
76
|
+
// ============================================
|
|
77
|
+
// AUTH COOKIE HELPERS
|
|
78
|
+
// ============================================
|
|
79
|
+
/**
|
|
80
|
+
* Set authentication cookies with proper domain and security settings.
|
|
81
|
+
*/
|
|
82
|
+
export function setAuthCookies(token, userDetails, rememberMe = true, refreshToken = null) {
|
|
83
|
+
const isProd = window.location.hostname.includes("get-micdrop.com");
|
|
84
|
+
const domainAttr = isProd ? "domain=.get-micdrop.com;" : "";
|
|
85
|
+
const secureAttr = window.location.protocol === "https:" ? "secure;" : "";
|
|
86
|
+
const maxAge = rememberMe ? "max-age=2592000;" : ""; // 30 days or session
|
|
87
|
+
document.cookie = `performer_token=${token}; path=/; ${maxAge} ${domainAttr} ${secureAttr} samesite=lax`;
|
|
88
|
+
document.cookie = `userDetails=${encodeURIComponent(JSON.stringify(userDetails))}; path=/; ${maxAge} ${domainAttr} ${secureAttr} samesite=lax`;
|
|
89
|
+
if (refreshToken) {
|
|
90
|
+
document.cookie = `performer_refresh_token=${refreshToken}; path=/; ${maxAge} ${domainAttr} ${secureAttr} samesite=lax`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Clear authentication cookies.
|
|
95
|
+
*/
|
|
96
|
+
export function clearAuthCookies() {
|
|
97
|
+
const isProd = window.location.hostname.includes("get-micdrop.com");
|
|
98
|
+
const domainAttr = isProd ? "domain=.get-micdrop.com;" : "";
|
|
99
|
+
document.cookie = `userDetails=; path=/; max-age=0; ${domainAttr}`;
|
|
100
|
+
document.cookie = `performer_token=; path=/; max-age=0; ${domainAttr}`;
|
|
101
|
+
document.cookie = `performer_refresh_token=; path=/; max-age=0; ${domainAttr}`;
|
|
102
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a value to a date string using Date.toDateString().
|
|
3
|
+
* Returns null if the value is falsy.
|
|
4
|
+
*/
|
|
5
|
+
export declare function convertToDate(value: string | null | undefined): string | null;
|
|
6
|
+
/**
|
|
7
|
+
* Convert an ISO date string to a local Date using UTC components (date only, no time).
|
|
8
|
+
*/
|
|
9
|
+
export declare function convertToCustomDateFormat(isoString: string): Date;
|
|
10
|
+
/**
|
|
11
|
+
* Convert an ISO date string to a UTC Date preserving hours and minutes.
|
|
12
|
+
*/
|
|
13
|
+
export declare function convertToCustomDateTimeFormat(isoDateString: string): Date;
|
|
14
|
+
/**
|
|
15
|
+
* Format a date string's time as "H:MM AM/PM" using UTC hours.
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatHour(dateString: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Format a date as short form: "Thu, Oct 24".
|
|
20
|
+
*/
|
|
21
|
+
export declare function formattedDate(date: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Format a date as long form with ordinal: "Thursday, October 24th, 2024".
|
|
24
|
+
*/
|
|
25
|
+
export declare function formattedFullDate(date: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Format a datetime string using Intl.DateTimeFormat with timezone support.
|
|
28
|
+
*/
|
|
29
|
+
export declare const formatDateTime: (dateTimeString: string, timeZone?: string) => string;
|
|
30
|
+
/**
|
|
31
|
+
* Format a start datetime as a single "H:MM AM/PM" time string (UTC).
|
|
32
|
+
*/
|
|
33
|
+
export declare const formatTimeline: (startDateTime: string) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Format a time range as "H:MM AM - H:MM PM" (UTC).
|
|
36
|
+
*/
|
|
37
|
+
export declare function formatTimeRange(startDate: string, endDate: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Get an array of date strings between two dates (inclusive), formatted as "YYYY-M-D".
|
|
40
|
+
*/
|
|
41
|
+
export declare function getDateRange(startDate: string, endDate: string): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Get abbreviated day of week from a date string (e.g., "Mon", "Tue").
|
|
44
|
+
*/
|
|
45
|
+
export declare const getDay: (dateString: string) => string;
|
|
46
|
+
/**
|
|
47
|
+
* Get abbreviated month from a date string (e.g., "Jan", "Feb").
|
|
48
|
+
*/
|
|
49
|
+
export declare const getMonth: (dateString: string) => string;
|
|
50
|
+
/**
|
|
51
|
+
* Get the day of the month (1-31) from a date string.
|
|
52
|
+
*/
|
|
53
|
+
export declare const getDateOfMonth: (dateString: string) => number;
|
|
54
|
+
/**
|
|
55
|
+
* Relative time string (e.g., "5 minutes ago", "2 days ago").
|
|
56
|
+
*/
|
|
57
|
+
export declare function timeAgo(date: string | Date): string;
|
|
58
|
+
interface DayOption {
|
|
59
|
+
value: string;
|
|
60
|
+
label: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get day options: weekdays if "weeks", or numbered days 1-31 with ordinal suffixes.
|
|
64
|
+
*/
|
|
65
|
+
export declare function getDays(params: string): DayOption[];
|
|
66
|
+
/**
|
|
67
|
+
* Get numeric options based on time unit: 12 for months, 10 for weeks, 31 for days.
|
|
68
|
+
*/
|
|
69
|
+
export declare function getDaysNumberOptions(timeUnit: string): DayOption[];
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=dateHelpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dateHelpers.d.ts","sourceRoot":"","sources":["../../src/lib/utils/dateHelpers.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAE7E;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAQjE;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAWzE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CASrD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQlD;AAiBD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CActD;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,gBAAgB,MAAM,EAAE,WAAU,MAAc,KAAG,MAcjF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,eAAe,MAAM,KAAG,MAYtD,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAgB1E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAezE;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,YAAY,MAAM,KAAG,MAI3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,YAAY,MAAM,KAAG,MAO7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,MAAM,KAAG,MAGnD,CAAC;AAEF;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAsBnD;AAMD,UAAU,SAAS;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,CA0BnD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,CAiBlE"}
|