forked from EduCraft/curriculum-project-hub
552c1c353e
Introduce admin-web (Skeleton/SvelteKit), Prisma models for provider connection / OrgModel / OrgRole, DB-backed runtime settings, and admin API routes so org admins can manage agent configuration end-to-end.
35 lines
811 B
TypeScript
35 lines
811 B
TypeScript
import { writable } from 'svelte/store';
|
|
|
|
export type ToastKind = 'info' | 'success' | 'error';
|
|
|
|
export interface ToastItem {
|
|
id: number;
|
|
message: string;
|
|
kind: ToastKind;
|
|
}
|
|
|
|
let seq = 0;
|
|
export const toasts = writable<ToastItem[]>([]);
|
|
|
|
export function pushToast(message: string, kind: ToastKind = 'info', ms = 3200): void {
|
|
const id = ++seq;
|
|
toasts.update((list) => [...list, { id, message, kind }]);
|
|
if (ms > 0) {
|
|
setTimeout(() => {
|
|
toasts.update((list) => list.filter((t) => t.id !== id));
|
|
}, ms);
|
|
}
|
|
}
|
|
|
|
export function dismissToast(id: number): void {
|
|
toasts.update((list) => list.filter((t) => t.id !== id));
|
|
}
|
|
|
|
export function toastSuccess(message: string): void {
|
|
pushToast(message, 'success');
|
|
}
|
|
|
|
export function toastError(message: string): void {
|
|
pushToast(message, 'error', 5000);
|
|
}
|