forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrganizationDetails.js
More file actions
126 lines (121 loc) · 3.02 KB
/
OrganizationDetails.js
File metadata and controls
126 lines (121 loc) · 3.02 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import React from 'react'
import { useQuery } from '@apollo/client'
import { t, Trans } from '@lingui/macro'
import { Layout } from './Layout'
import { IconButton, Heading, Stack, useToast, Text } from '@chakra-ui/core'
import { ORGANIZATION_BY_SLUG } from './graphql/queries'
import { useLingui } from '@lingui/react'
import { useUserState } from './UserState'
import { useParams, useHistory } from 'react-router-dom'
import SummaryTable from './SummaryTable'
import makeSummaryTableData from './makeSummaryTableData'
export default function OrganizationDetails() {
const { i18n } = useLingui()
const { orgSlug } = useParams()
const { currentUser } = useUserState()
const toast = useToast()
const history = useHistory()
const { loading, _error, data } = useQuery(ORGANIZATION_BY_SLUG, {
variables: { slug: orgSlug },
context: {
headers: {
authorization: currentUser.jwt,
},
},
onError: error => {
const [_, message] = error.message.split(': ')
toast({
title: 'Error',
description: message,
status: 'failure',
duration: 9000,
isClosable: true,
})
},
})
let domainName = ''
if (data && data.organization.domains.edges) {
domainName = data.organization.name
}
if (loading) {
return (
<p>
<Trans>Loading...</Trans>
</p>
)
}
const columns = [
{
Header: i18n._(t`Domain`),
accessor: 'host_domain',
},
{
Header: 'HTTPS',
accessor: 'https_result',
},
{
Header: 'HSTS',
accessor: 'hsts_result',
},
{
Header: i18n._(t`HSTS Preloaded`),
accessor: 'preloaded_result',
},
{
Header: 'SSL',
accessor: 'ssl_result',
},
{
Header: i18n._(t`Protocols & Ciphers`),
accessor: 'protocol_cipher_result',
},
{
Header: i18n._(t`Certificate Use`),
accessor: 'cert_use_result',
},
{
Header: 'SPF',
accessor: 'spf_result',
},
{
Header: 'DKIM',
accessor: 'dkim_result',
},
{
Header: 'DMARC',
accessor: 'dmarc_result',
},
]
const tableEntries = Math.floor(Math.random() * 20)
return (
<Layout>
<Stack spacing={10} shouldWrapChildren mb="4">
<Stack isInline align="center">
<IconButton
icon="arrow-left"
onClick={history.goBack}
color="gray.900"
fontSize="2xl"
aria-label="back to organizations"
/>
<Heading as="h1">
<Trans>{domainName}</Trans>
</Heading>
</Stack>
<Stack>
{tableEntries > 0 ? (
<SummaryTable
data={makeSummaryTableData(tableEntries)}
columns={columns}
/>
) : (
<Text fontSize="2xl" fontWeight="bold">
<Trans>No domains yet.</Trans>
</Text>
)}
</Stack>
</Stack>
<Trans>*All data represented is mocked for demonstration purposes</Trans>
</Layout>
)
}