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 { Activity } from "../../../domain/entities"; |
| #3 | import { activities as mockActivities } from "../../../infrastructure/mock-data/activities"; |
| #4 | import { generateId } from "../../../infrastructure/helpers"; |
| #5 | import type { StoreState } from "../store.types"; |
| #6 | |
| #7 | export interface ActivitySlice { |
| #8 | activities: Activity[]; |
| #9 | addActivity: (activity: Omit<Activity, "id" | "createdAt">) => void; |
| #10 | } |
| #11 | |
| #12 | export const createActivitySlice: StateCreator< |
| #13 | StoreState, |
| #14 | [], |
| #15 | [], |
| #16 | ActivitySlice |
| #17 | > = (set) => ({ |
| #18 | activities: mockActivities, |
| #19 | addActivity: (activityData) => { |
| #20 | const activity: Activity = { |
| #21 | ...activityData, |
| #22 | id: generateId(), |
| #23 | createdAt: new Date().toISOString(), |
| #24 | }; |
| #25 | set((s) => ({ activities: [activity, ...s.activities] })); |
| #26 | }, |
| #27 | }); |
| #28 |