Skip to content

Commit

Permalink
fix: branch store persist
Browse files Browse the repository at this point in the history
  • Loading branch information
jiohjung98 committed May 31, 2024
1 parent 6888c18 commit 7a1ccf2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/home/CurrentOffice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const CurrentOffice = () => {
<img src="/home/location.svg" alt="" />
</div>
<div className="text-white text-lg underline font-medium cursor-pointer" onClick={handleSearchClick}>
{selectedBranch ? selectedBranch.branchName : 'ㅌㅌ'}
{selectedBranch ? selectedBranch.branchName : '지점을 설정해주세요'}
</div>
</div>
</div>
Expand Down
16 changes: 12 additions & 4 deletions src/store/branch.store.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { create } from 'zustand';
import { Branch } from '@/api/types/branch';
import { persist } from 'zustand/middleware';

interface BranchStore {
selectedBranch: Branch | null;
setSelectedBranch: (branch: Branch | null) => void;
}

export const useBranchStore = create<BranchStore>((set) => ({
selectedBranch: null,
setSelectedBranch: (branch: Branch | null) => set({ selectedBranch: branch }),
}));
export const useBranchStore = create(
persist<BranchStore>(
(set) => ({
selectedBranch: null,
setSelectedBranch: (branch: Branch | null) => set({ selectedBranch: branch }),
}),
{
name: 'selectedBranch'
}
)
);

0 comments on commit 7a1ccf2

Please sign in to comment.