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 { Notification } from "../../../domain/entities"; |
| #3 | import { notifications as mockNotifications } from "../../../infrastructure/mock-data/notifications"; |
| #4 | import type { StoreState } from "../store.types"; |
| #5 | |
| #6 | export interface NotificationSlice { |
| #7 | notifications: Notification[]; |
| #8 | markNotificationRead: (id: string) => void; |
| #9 | markAllNotificationsRead: () => void; |
| #10 | } |
| #11 | |
| #12 | export const createNotificationSlice: StateCreator< |
| #13 | StoreState, |
| #14 | [], |
| #15 | [], |
| #16 | NotificationSlice |
| #17 | > = (set) => ({ |
| #18 | notifications: mockNotifications, |
| #19 | markNotificationRead: (id) => { |
| #20 | set((s) => ({ |
| #21 | notifications: s.notifications.map((n) => |
| #22 | n.id === id ? { ...n, read: true } : n |
| #23 | ), |
| #24 | })); |
| #25 | }, |
| #26 | markAllNotificationsRead: () => { |
| #27 | set((s) => ({ |
| #28 | notifications: s.notifications.map((n) => ({ ...n, read: true })), |
| #29 | })); |
| #30 | }, |
| #31 | }); |
| #32 |