-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathOverview.tsx
78 lines (70 loc) · 2.37 KB
/
Overview.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React from 'react';
import { useLocation } from 'react-router-dom';
import { css } from 'glamor';
import { useReports } from 'loot-core/src/client/data-hooks/reports';
import { useAccounts } from '../../hooks/useAccounts';
import { useFeatureFlag } from '../../hooks/useFeatureFlag';
import { useResponsive } from '../../ResponsiveProvider';
import { Button } from '../common/Button';
import { Link } from '../common/Link';
import { Text } from '../common/Text';
import { View } from '../common/View';
import { MOBILE_NAV_HEIGHT } from '../mobile/MobileNavTabs';
import { MobilePageHeader, Page, PageHeader } from '../Page';
import { CashFlowCard } from './reports/CashFlowCard';
import { CustomReportListCards } from './reports/CustomReportListCards';
import { NetWorthCard } from './reports/NetWorthCard';
import { SpendingCard } from './reports/SpendingCard';
export function Overview() {
const { data: customReports } = useReports();
const { isNarrowWidth } = useResponsive();
const location = useLocation();
sessionStorage.setItem('url', location.pathname);
const spendingReportFeatureFlag = useFeatureFlag('spendingReport');
const accounts = useAccounts();
return (
<Page
header={
isNarrowWidth ? (
<MobilePageHeader title="Reports" />
) : (
<View
style={{
flexDirection: 'row',
justifyContent: 'space-between',
marginRight: 15,
}}
>
<PageHeader title="Reports" />
{!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 }}
>
<View
className={`${css({
flex: '0 0 auto',
flexDirection: isNarrowWidth ? 'column' : 'row',
flexWrap: isNarrowWidth ? 'nowrap' : 'wrap',
padding: '10',
'> a, > div': {
margin: '10',
},
})}`}
>
<NetWorthCard accounts={accounts} />
<CashFlowCard />
{spendingReportFeatureFlag && <SpendingCard />}
<CustomReportListCards reports={customReports} />
</View>
</Page>
);
}