17 lines
400 B
TypeScript
17 lines
400 B
TypeScript
import type { EventData } from './eventApi';
|
|
|
|
export function buildEventShareLink(event: EventData | null, token: string | null): string {
|
|
if (typeof window === 'undefined') {
|
|
return '';
|
|
}
|
|
|
|
const origin = window.location.origin;
|
|
const eventToken = token ?? event?.join_token ?? '';
|
|
|
|
if (!eventToken) {
|
|
return origin;
|
|
}
|
|
|
|
return `${origin}/e/${encodeURIComponent(eventToken)}`;
|
|
}
|