repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
Projectflow
stars
latest
clone command
git clone gitlawb://did:key:z6Mkfh4Y...QBEi/projectflowgit clone gitlawb://did:key:z6Mkfh4Y.../projectflowb3cded1async from playground1d ago| #1 | import { StateCreator } from "zustand"; |
| #2 | import type { Workspace } from "../../../domain/entities"; |
| #3 | import { workspaces } from "../../../infrastructure/mock-data/workspaces"; |
| #4 | import type { StoreState } from "../store.types"; |
| #5 | |
| #6 | export interface WorkspaceSlice { |
| #7 | currentWorkspace: Workspace | null; |
| #8 | workspaces: Workspace[]; |
| #9 | setCurrentWorkspace: (id: string) => void; |
| #10 | } |
| #11 | |
| #12 | export const createWorkspaceSlice: StateCreator< |
| #13 | StoreState, |
| #14 | [], |
| #15 | [], |
| #16 | WorkspaceSlice |
| #17 | > = (set) => ({ |
| #18 | currentWorkspace: workspaces[0], |
| #19 | workspaces, |
| #20 | setCurrentWorkspace: (id: string) => { |
| #21 | const ws = workspaces.find((w) => w.id === id); |
| #22 | if (ws) set({ currentWorkspace: ws }); |
| #23 | }, |
| #24 | }); |
| #25 |