mars-v2-frontend/src/hooks/useLendAndReclaimModal.ts
Yusuf Seyrek 2c399a2f16
feat: lend and withdraw modals (#257)
* feat: lend/withdraw functionality

* feat: addressed to pr discussions

* rename: data hook members
2023-06-23 13:30:08 +03:00

28 lines
789 B
TypeScript

import { useCallback } from 'react'
import useStore from 'store'
function useLendAndReclaimModal() {
const config = useStore((s) => s.lendAndReclaimModal)
const open = useCallback((action: LendAndReclaimModalAction, data: LendingMarketTableData) => {
const _config: LendAndReclaimModalConfig = {
action,
data,
}
useStore.setState({ lendAndReclaimModal: _config })
}, [])
const close = useCallback(() => {
useStore.setState({ lendAndReclaimModal: null })
}, [])
const openLend = useCallback((data: LendingMarketTableData) => open('lend', data), [open])
const openReclaim = useCallback((data: LendingMarketTableData) => open('reclaim', data), [open])
return { config, openLend, openReclaim, close }
}
export default useLendAndReclaimModal