Skip to content
Snippets Groups Projects
Overview.tsx 2.17 KiB
Newer Older
  • Learn to ignore specific revisions
  • Neil's avatar
    Neil committed
    import React from 'react';
    
    import { useLocation } from 'react-router-dom';
    
    import { useReports } from 'loot-core/src/client/data-hooks/reports';
    
    
    import { useAccounts } from '../../hooks/useAccounts';
    
    import { useFeatureFlag } from '../../hooks/useFeatureFlag';
    
    Neil's avatar
    Neil committed
    import { useResponsive } from '../../ResponsiveProvider';
    
    Neil's avatar
    Neil committed
    import { Button } from '../common/Button';
    
    Neil's avatar
    Neil committed
    import { Link } from '../common/Link';
    
    Neil's avatar
    Neil committed
    import { Text } from '../common/Text';
    
    import { View } from '../common/View';
    
    import { MOBILE_NAV_HEIGHT } from '../mobile/MobileNavTabs';
    import { MobilePageHeader, Page, PageHeader } from '../Page';
    
    James Long's avatar
    James Long committed
    
    
    import { CashFlowCard } from './reports/CashFlowCard';
    
    import { CustomReportListCards } from './reports/CustomReportListCards';
    
    import { NetWorthCard } from './reports/NetWorthCard';
    
    Neil's avatar
    Neil committed
    import { SpendingCard } from './reports/SpendingCard';
    
    James Long's avatar
    James Long committed
    
    
    export function Overview() {
    
      const customReports = useReports();
    
    Neil's avatar
    Neil committed
      const { isNarrowWidth } = useResponsive();
    
      const location = useLocation();
      sessionStorage.setItem('url', location.pathname);
    
    
    Neil's avatar
    Neil committed
      const spendingReportFeatureFlag = useFeatureFlag('spendingReport');
    
      const accounts = useAccounts();
    
    James Long's avatar
    James Long committed
      return (
    
        <Page
          header={
            isNarrowWidth ? (
              <MobilePageHeader title="Reports" />
            ) : (
              <View
                style={{
                  flexDirection: 'row',
                  justifyContent: 'space-between',
                  marginRight: 15,
                }}
              >
                <PageHeader title="Reports" />
    
    Neil's avatar
    Neil committed
                {!isNarrowWidth && (
    
                  <Link to="/reports/custom" style={{ textDecoration: 'none' }}>
                    <Button type="primary">
                      <Text>Create new custom report</Text>
                    </Button>
                  </Link>
                )}
              </View>
            )
          }
          padding={0}
          style={{ paddingBottom: MOBILE_NAV_HEIGHT }}
    
    James Long's avatar
    James Long committed
        >
          <View
            style={{
    
    Neil's avatar
    Neil committed
              flexDirection: isNarrowWidth ? 'column' : 'row',
    
    James Long's avatar
    James Long committed
            }}
          >
            <NetWorthCard accounts={accounts} />
            <CashFlowCard />
    
    Neil's avatar
    Neil committed
            {spendingReportFeatureFlag && <SpendingCard />}
    
    James Long's avatar
    James Long committed
          </View>
    
    Neil's avatar
    Neil committed
          <CustomReportListCards reports={customReports} />
    
    James Long's avatar
    James Long committed
      );
    }