import { Flex } from 'antd'
import useCollapseState from '../hooks/useCollapseState'
import StatsDisplay from '../common/StatsDisplay'
import InfoCollapse from '../common/InfoCollapse'
import ScrollBox from '../common/ScrollBox'

const FinanceOverview = () => {
  const [collapseState, updateCollapseState] = useCollapseState(
    'FinanceOverview',
    {
      invoiceStats: true,
      paymentStats: true
    }
  )

  return (
    <Flex
      gap='large'
      vertical='true'
      style={{
        maxHeight: '100%',
        minHeight: 0
      }}
    >
      <ScrollBox>
        <Flex vertical gap={'large'}>
          <InfoCollapse
            title='Invoice Statistics'
            icon={null}
            active={collapseState.invoiceStats}
            onToggle={(isActive) =>
              updateCollapseState('invoiceStats', isActive)
            }
            className='no-t-padding-collapse'
            collapseKey='invoiceStats'
            canCollapse={false}
          >
            <Flex
              justify='flex-start'
              gap='middle'
              wrap='wrap'
              align='flex-start'
            >
              <StatsDisplay objectType='invoice' />
            </Flex>
          </InfoCollapse>
          <InfoCollapse
            title='Payment Statistics'
            icon={null}
            active={collapseState.paymentStats}
            onToggle={(isActive) =>
              updateCollapseState('paymentStats', isActive)
            }
            className='no-t-padding-collapse'
            collapseKey='paymentStats'
            canCollapse={false}
          >
            <Flex
              justify='flex-start'
              gap='middle'
              wrap='wrap'
              align='flex-start'
            >
              <StatsDisplay objectType='payment' />
            </Flex>
          </InfoCollapse>
        </Flex>
      </ScrollBox>
    </Flex>
  )
}

export default FinanceOverview
