19 lines
446 B
TypeScript
19 lines
446 B
TypeScript
export type GuestToastPayload = {
|
|
text: string;
|
|
type?: 'success' | 'error' | 'info';
|
|
action?: { label: string; onClick: () => void };
|
|
durationMs?: number;
|
|
};
|
|
|
|
export function pushGuestToast(detail: GuestToastPayload) {
|
|
if (typeof window === 'undefined') {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
window.dispatchEvent(new CustomEvent('guest-toast', { detail }));
|
|
} catch (error) {
|
|
console.warn('Dispatching toast event failed', error);
|
|
}
|
|
}
|