-
Notifications
You must be signed in to change notification settings - Fork 12
/
OwnerHome.jsx
85 lines (78 loc) · 2.36 KB
/
OwnerHome.jsx
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
import React from 'react';
import {
Person as UserIcon,
Home as OrgIcon,
} from '@mui/icons-material';
import { getAppliedServerConfig } from '../../common/utils';
import FhirTabs from './FhirTabs';
import OwnerButton from '../common/OwnerButton';
import { FHIR_DEFAULT_CONFIG } from "../../common/defaultConfigs"
class OwnerHome extends React.Component {
constructor(props) {
super(props);
this.serverConfig = getAppliedServerConfig()
let owner;
let ownerType;
if(props.match.params.org) {
ownerType = 'org'
owner = props.match.params.org
} else {
ownerType = 'user'
owner = props.match.params.user
}
this.state = {
owner: {ownerType: ownerType, owner: owner, id: owner,},
tab: this.getDefaultTab(),
config: FHIR_DEFAULT_CONFIG
}
}
getIcon() {
if(this.state.owner.ownerType === 'org')
return <OrgIcon className='default-svg' />
return <UserIcon className='default-svg' />
}
getDefaultTab = () => {
if(window.location.hash.match('/ValueSet'))
return 1
if(window.location.hash.match('/ConceptMap'))
return 2
return 0
}
onTabChange = (event, value) => this.setState({tab: value})
render() {
const { tab, config, owner } = this.state;
const { info, hapi } = this.serverConfig;
const { org, pageSize } = info;
return (
<div className='col-md-12 home-container no-side-padding'>
<header className='home-header col-md-12'>
<div className='col-md-12 no-side-padding container' style={{padding: '10px'}}>
<div className='col-md-12'>
<div className='col-md-12 no-side-padding flex-vertical-center'>
<OwnerButton owner={org.id} uri='#/' />
<span className='separator'>/</span>
<OwnerButton {...owner} uri={window.location.hash} />
</div>
</div>
</div>
</header>
{
tab !== null &&
<FhirTabs
nested
tab={tab}
onTabChange={this.onTabChange}
org={owner}
location={this.props.location}
match={this.props.match}
url={`/${owner.ownerType}s/${owner.id}/`}
selectedConfig={config}
limit={pageSize}
hapi={hapi}
/>
}
</div>
)
}
}
export default OwnerHome;