mars-v2-frontend/src/components/Modals/ModalContentWithSummary.tsx
Linkie Link b0c9cca51c
v2.0.5 (#636)
* fix: fixed the trading chart load

* fix: prevent wrapped checkboxes to be double clicked

* fix: refactored funding account modal

* fix: fixed modal classes

* fix: adjusted width classes

* fix: fixed the slider masks

* listed: TIA and USDT

* fix: fixed the slider initial position

* env: version update
2023-11-15 16:27:05 +01:00

54 lines
1.5 KiB
TypeScript

import classNames from 'classnames'
import React from 'react'
import AccountSummary from 'components/Account/AccountSummary'
import Card from 'components/Card'
import { CircularProgress } from 'components/CircularProgress'
import Modal, { ModalProps } from 'components/Modal'
import useStore from 'store'
interface Props extends ModalProps {
account?: Account
isContentCard?: boolean
subHeader?: React.ReactNode
}
function modalContent(content: React.ReactNode, isContentCard?: boolean, account?: Account) {
if (!account)
return (
<div className='flex items-center justify-center w-full h-[380px]'>
<CircularProgress />
</div>
)
if (isContentCard)
return (
<Card
className='flex flex-1 p-4 bg-white/5'
contentClassName='gap-6 flex flex-col justify-between h-full min-h-[380px]'
>
{content}
</Card>
)
return content
}
export default function ModalContentWithSummary(props: Props) {
const updatedAccount = useStore((s) => s.updatedAccount)
return (
<Modal
{...props}
headerClassName={classNames(
'gradient-header pl-2 pr-2.5 py-3 border-b-white/5 border-b',
props.headerClassName,
)}
contentClassName={classNames('flex items-start flex-1 gap-6 p-6', props.contentClassName)}
>
{props.subHeader && props.subHeader}
{modalContent(props.content, props.isContentCard, props.account)}
{props.account && <AccountSummary account={updatedAccount || props.account} />}
</Modal>
)
}