This commit is contained in:
ZacharyZhang-NY committed 2026-03-23 16:27:55 -04:00
1 parent b15f1c0e5e
commit b56aaa1498
71 files changed
+866 -659

No files matched your search

+21
View File
@@ -3,6 +3,14 @@ import type { AppState } from "../store";
import type { AppLocale } from "@shared/locale";
import { DEFAULT_LOCALE } from "@shared/locale";
export interface Toast {
id: string;
message: string;
tone: "success" | "danger" | "warn";
}
function nextToastId() { return `t-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`; }
export interface UiSlice {
locale: AppLocale;
showOnboarding: boolean;
@@ -10,12 +18,15 @@ export interface UiSlice {
confirmDeleteCompanyId: string | null;
taskViewMode: "list" | "kanban";
logRevision: number;
toasts: Toast[];
setLocale: (locale: AppLocale) => void;
setShowOnboarding: (show: boolean) => void;
setInitialOnboardingLocked: (locked: boolean) => void;
setConfirmDeleteCompanyId: (id: string | null) => void;
setTaskViewMode: (mode: "list" | "kanban") => void;
incrementLogRevision: () => void;
addToast: (message: string, tone?: Toast["tone"]) => void;
dismissToast: (id: string) => void;
}
export const createUiSlice: StateCreator<
@@ -30,6 +41,7 @@ export const createUiSlice: StateCreator<
confirmDeleteCompanyId: null,
taskViewMode: "list",
logRevision: 0,
toasts: [],
setLocale: (locale) =>
set((state) => {
state.locale = locale;
@@ -54,4 +66,13 @@ export const createUiSlice: StateCreator<
set((state) => {
state.logRevision += 1;
}),
addToast: (message, tone = "success") => {
const id = nextToastId();
set((state) => { state.toasts.push({ id, message, tone }); });
setTimeout(() => {
set((state) => { state.toasts = state.toasts.filter((t) => t.id !== id); });
}, 4000);
},
dismissToast: (id) =>
set((state) => { state.toasts = state.toasts.filter((t) => t.id !== id); }),
});