forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLandingPage.js
More file actions
60 lines (55 loc) · 1.63 KB
/
Copy pathLandingPage.js
File metadata and controls
60 lines (55 loc) · 1.63 KB
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
import React from 'react'
import { Trans } from '@lingui/macro'
import { Layout } from './Layout'
import { Text, Image, Stack, useToast } from '@chakra-ui/core'
import { SummaryGroup } from './SummaryGroup'
import trackerLogo from './images/tracker_v-03.png'
import { WelcomeMessage } from './WelcomeMessage'
import { ErrorBoundary } from 'react-error-boundary'
import { ErrorFallbackMessage } from './ErrorFallbackMessage'
import { useQuery } from '@apollo/client'
import { WEB_AND_EMAIL_SUMMARIES } from './graphql/queries'
import { LoadingMessage } from './LoadingMessage'
export function LandingPage() {
const toast = useToast()
const { loading, error, data } = useQuery(WEB_AND_EMAIL_SUMMARIES, {
onError: ({ message }) => {
toast({
title: 'Error',
description: message,
status: 'error',
duration: 9000,
isClosable: true,
position: 'top-left',
})
},
})
if (error) return <ErrorFallbackMessage error={error} />
if (loading) {
return (
<LoadingMessage>
<Trans>Summary Cards</Trans>
</LoadingMessage>
)
}
return (
<Layout>
<Stack align="center">
<Image
src={trackerLogo}
alt={'Tracker Logo'}
size={['100%', '100%', '0%', '0%', '0%']}
/>
<WelcomeMessage />
</Stack>
<ErrorBoundary FallbackComponent={ErrorFallbackMessage}>
<SummaryGroup web={data.webSummary} mail={data.mailSummary} />
<Text>
<Trans>
*All data represented is mocked for demonstration purposes
</Trans>
</Text>
</ErrorBoundary>
</Layout>
)
}