30 lines
786 B
TypeScript
30 lines
786 B
TypeScript
import { create } from "zustand";
|
|
import { persist } from "zustand/middleware";
|
|
|
|
type Theme = "light" | "dark" | "system";
|
|
|
|
interface SettingsState {
|
|
projectId: string | null;
|
|
channelId: string | null;
|
|
theme: Theme;
|
|
setProjectId: (projectId: string) => void;
|
|
setChannelId: (channelId: string) => void;
|
|
setTheme: (theme: Theme) => void;
|
|
}
|
|
|
|
export const useSettingsStore = create<SettingsState>()(
|
|
persist(
|
|
(set) => ({
|
|
projectId: import.meta.env.VITE_DEFAULT_PROJECT_ID,
|
|
channelId: import.meta.env.VITE_DEFAULT_CHANNEL_ID,
|
|
theme: "light",
|
|
setProjectId: (projectId) => set({ projectId }),
|
|
setChannelId: (channelId) => set({ channelId }),
|
|
setTheme: (theme) => set({ theme }),
|
|
}),
|
|
{
|
|
name: "settings-storage", // localStorage에 저장될 이름
|
|
},
|
|
),
|
|
);
|