27cdd1c954
* tidy: added eslintrc and prettierrc rules * tidy: formated the files via ‚yarn format‘ * import sort improvements * format script regex fix * replace eslint import severity to warning * remove staged file Co-authored-by: Gustavo Mauricio <gustavo.mauricio58@gmail.com>
38 lines
891 B
TypeScript
38 lines
891 B
TypeScript
import create from 'zustand'
|
|
import { persist } from 'zustand/middleware'
|
|
|
|
interface CreditManagerStore {
|
|
isOpen: boolean
|
|
selectedAccount: string | null
|
|
actions: {
|
|
toggleCreditManager: () => void
|
|
setSelectedAccount: (id: string) => void
|
|
}
|
|
}
|
|
|
|
const useCreditManagerStore = create<CreditManagerStore>()(
|
|
persist(
|
|
(set, get) => ({
|
|
isOpen: false,
|
|
selectedAccount: null,
|
|
actions: {
|
|
toggleCreditManager: () => set(() => ({ isOpen: !get().isOpen })),
|
|
setSelectedAccount: (accountId: string) => {
|
|
set(() => ({
|
|
selectedAccount: accountId,
|
|
}))
|
|
},
|
|
},
|
|
}),
|
|
{
|
|
name: 'creditManager',
|
|
partialize: (state) =>
|
|
Object.fromEntries(
|
|
Object.entries(state).filter(([key]) => ['selectedAccount'].includes(key)),
|
|
),
|
|
},
|
|
),
|
|
)
|
|
|
|
export default useCreditManagerStore
|