import { createStaticParty } from '../../api/staticParty'; import { navigate } from '../../router'; import { showToast } from '../../toast'; /** * "Créer une watch party permanente" - shared by views/series and * views/playlist: creates a static watch party over `sourceId` (a series * or a video playlist - the server decides which, and refuses anything * else with a message) and opens its page. */ export function wireCreateStaticButton(btn: HTMLButtonElement, sourceId: string): void { const idleLabel = btn.textContent || ''; btn.addEventListener('click', () => { btn.disabled = true; btn.textContent = 'Création...'; createStaticParty(sourceId) .then((sp) => { console.info('[staticParty] created', sp.id, 'from', sourceId); navigate(`/static/${sp.id}`); }) .catch((err: unknown) => { console.error('[staticParty] create failed', sourceId, err); showToast((err as Error).message, { variant: 'error' }); btn.disabled = false; btn.textContent = idleLabel; }); }); }