-
-
Notifications
You must be signed in to change notification settings - Fork 185
Expand file tree
/
Copy pathuseProjectStore.ts
More file actions
23 lines (20 loc) · 695 Bytes
/
useProjectStore.ts
File metadata and controls
23 lines (20 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { create } from 'zustand';
interface CurrentProject {
id: string;
slug: string;
ownerUsername: string;
isPublic: boolean;
}
interface ProjectState {
currentProject: CurrentProject | null;
setCurrentProject: (project: CurrentProject) => void;
clearCurrentProject: () => void;
setVisibility: (isPublic: boolean) => void;
}
export const useProjectStore = create<ProjectState>((set) => ({
currentProject: null,
setCurrentProject: (project) => set({ currentProject: project }),
clearCurrentProject: () => set({ currentProject: null }),
setVisibility: (isPublic) =>
set((s) => (s.currentProject ? { currentProject: { ...s.currentProject, isPublic } } : s)),
}));