-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.ts
34 lines (31 loc) · 895 Bytes
/
store.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import create from 'zustand'
import { EditedNotice, EditedTask } from './types/types'
type State = {
editedTask: EditedTask
editedNotice: EditedNotice
updateEditedTask: (payload: EditedTask) => void
updateEditedNotice: (payload: EditedNotice) => void
resetEditedTask: () => void
resetEditedNotice: () => void
}
const useStore = create<State>((set) => ({
editedTask: { id: '', title: '' },
editedNotice: { id: '', content: '' },
updateEditedTask: (payload) =>
set({
editedTask: {
id: payload.id,
title: payload.title,
},
}),
resetEditedTask: () => set({ editedTask: { id: '', title: '' } }),
updateEditedNotice: (payload) =>
set({
editedNotice: {
id: payload.id,
content: payload.content,
},
}),
resetEditedNotice: () => set({ editedNotice: { id: '', content: '' } }),
}))
export default useStore