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
106 lines (101 loc) · 2.4 KB
/
OrganizationDetails.js
File metadata and controls
106 lines (101 loc) · 2.4 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
import React from 'react'
import { useQuery } from '@apollo/client'
import { Trans } from '@lingui/macro'
import { Layout } from './Layout'
import {
IconButton,
Heading,
Stack,
useToast,
Tabs,
TabList,
TabPanels,
Tab,
TabPanel,
} from '@chakra-ui/core'
import { ORG_DETAILS_PAGE } from './graphql/queries'
import { useUserState } from './UserState'
import { useParams, useHistory } from 'react-router-dom'
import DomainsPage from './DomainsPage'
import UserList from './UserList'
import { OrganizationSummary } from './OrganizationSummary'
export default function OrganizationDetails() {
const { orgSlug } = useParams()
const { currentUser } = useUserState()
const toast = useToast()
const history = useHistory()
const { loading, _error, data } = useQuery(ORG_DETAILS_PAGE, {
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,
position: 'bottom-left',
})
},
})
let orgName = ''
if (data?.organization) {
orgName = data.organization.name
}
if (loading) {
return (
<p>
<Trans>Loading...</Trans>
</p>
)
}
return (
<Layout>
<Stack isInline align="center" mb="4">
<IconButton
icon="arrow-left"
onClick={history.goBack}
color="gray.900"
fontSize="2xl"
aria-label="back to organizations"
/>
<Heading as="h1" textAlign={['center', 'left']}>
<Trans>{orgName}</Trans>
</Heading>
</Stack>
<Tabs isFitted>
<TabList mb="4">
<Tab>
<Trans>Summary</Trans>
</Tab>
<Tab>
<Trans>Domains</Trans>
</Tab>
<Tab>
<Trans>Users</Trans>
</Tab>
</TabList>
<TabPanels>
<TabPanel>
<OrganizationSummary />
</TabPanel>
<TabPanel>
<DomainsPage />
</TabPanel>
<TabPanel>
<UserList
userListData={data.userList}
orgName={orgName}
orgSlug={orgSlug}
/>
</TabPanel>
</TabPanels>
</Tabs>
</Layout>
)
}