Skip to content

Commit

Permalink
feat: BlockList 클라이언트에서 관리할 수 있도록 store 추가(#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonncho committed Mar 2, 2023
1 parent 96bf182 commit 0aef3f9
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/store/blocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { create } from 'zustand'
import { immer } from 'zustand/middleware/immer'
import { GetDayBlocksResponse } from '@/api/types/base.types'

type State = {
blockList: GetDayBlocksResponse
}

const INITIAL_STATE: State['blockList'] = {
date: '',
totalBlock: 0,
totalTask: 0,
reviewId: null,
blocks: [],
}

type Actions = {
setBlockList: (data: State['blockList']) => void
}

const useBlockListStore = create(
immer<State & Actions>((set) => ({
blockList: INITIAL_STATE,
setBlockList: (data) =>
set((state) => {
state.blockList = data
}),
})),
)

export default useBlockListStore

0 comments on commit 0aef3f9

Please sign in to comment.