Skip to content

Commit

Permalink
Fix issues for eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
kkosiorowska committed Dec 14, 2023
1 parent 567d04a commit bb9bb62
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
4 changes: 3 additions & 1 deletion dapp/src/components/Overview/PositionDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export default function PositionDetails(props: CardProps) {
</CardBody>
<CardFooter flexDirection="column" gap={2}>
{/* TODO: Handle click actions */}
<Button size="lg" onClick={() => setIsOpenStakingModal(true)}>Stake</Button>
<Button size="lg" onClick={() => setIsOpenStakingModal(true)}>
Stake
</Button>
<Button size="lg" variant="outline">
Unstake
</Button>
Expand Down
22 changes: 13 additions & 9 deletions dapp/src/components/shared/ModalBase/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function ModalBase({
isOpen: boolean
onClose: () => void
steps: string[]
// eslint-disable-next-line react/require-default-props
defaultIndex?: number
children: React.ReactNode
}) {
Expand All @@ -30,6 +31,11 @@ export default function ModalBase({
onClose()
}, [onClose])

const resetState = useCallback(() => {
setActiveStep(steps[defaultIndex])
setIndex(defaultIndex)
}, [defaultIndex, steps])

useEffect(() => {
if (index >= steps.length) {
handleClose()
Expand All @@ -39,18 +45,16 @@ export default function ModalBase({
}, [steps, index, handleClose])

useEffect(() => {
if (!isOpen) {
closeSidebar()
let timeout: NodeJS.Timeout

const timeout = setTimeout(() => {
setActiveStep(steps[defaultIndex])
setIndex(defaultIndex)
}, 100)
return () => clearTimeout(timeout)
} else {
if (isOpen) {
openSideBar()
} else {
closeSidebar()
timeout = setTimeout(resetState, 100)
}
}, [isOpen, steps, defaultIndex, closeSidebar, openSideBar])
return () => clearTimeout(timeout)
}, [isOpen, resetState, openSideBar, closeSidebar])

const contextValue: ModalFlowContextValue = useMemo<ModalFlowContextValue>(
() => ({
Expand Down

0 comments on commit bb9bb62

Please sign in to comment.