Welcome.tsx 10.7 KB
Newer Older
1
import * as React from 'react';
2
import { withTranslation, WithTranslation } from 'react-i18next';
Oleksii Savran's avatar
Oleksii Savran committed
3
import { withStyles, WithStyles } from '@material-ui/core/styles';
Matija Obreza's avatar
Matija Obreza committed
4
import ContentHeader from '@gringlobal/client/ui/common/heading/ContentHeader';
Oleksii Savran's avatar
Oleksii Savran committed
5
6
7
import Grid from '@material-ui/core/Grid';
import { Link } from 'react-router-dom';
import { Card, CardContent, CardHeader } from '@material-ui/core';
8
import Authorize from '@gringlobal/client/ui/common/authorized/Authorize';
9
import { UserRole } from '@gringlobal/client/model/gringlobal/SysUser';
10
import PageTitle from '@gringlobal/client/ui/common/PageTitle';
Oleksii Savran's avatar
Oleksii Savran committed
11
import SectionHeader from '@gringlobal/client/ui/common/heading/SectionHeader';
12

13
const styles = (theme) => ({
Oleksii Savran's avatar
Oleksii Savran committed
14
  card: {
15
16
17
18
19
    color: 'black',
    height: '100%',
  },
  cardDisabled: {
    backgroundColor: theme.palette.action.disabled,
Oleksii Savran's avatar
Oleksii Savran committed
20
21
22
23
  },
});

class WelcomePage extends React.Component<WithTranslation & WithStyles> {
24
25

  public render() {
Oleksii Savran's avatar
Oleksii Savran committed
26
    const { t, classes } = this.props;
Matija Obreza's avatar
Matija Obreza committed
27
28
    return (
      <>
29
        <PageTitle title={ t('welcome.p.title') }/>
Matija Obreza's avatar
Matija Obreza committed
30
        <ContentHeader title={ t('welcome.p.title') }/>
Oleksii Savran's avatar
Oleksii Savran committed
31
32
        <div className="p-20">
          <Grid container justify="flex-start" spacing={ 2 }>
33

34
            <Authorize roles={ [ UserRole.USER ] }>
Oleksii Savran's avatar
Oleksii Savran committed
35
36
              <>
                <SectionHeader title={ t('welcome.p.sections.tools') } className="m-halfrem pt-5 pb-5"/>
37

Oleksii Savran's avatar
Oleksii Savran committed
38
39
40
41
42
43
44
45
46
47
                <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
                  <Link to="/inventory/acquisition">
                    <Card className={ classes.card }>
                      <CardHeader title={ t('welcome.p.cards.acquisition.title') }/>
                      <CardContent>
                        <div>{ t('welcome.p.cards.acquisition.description') }</div>
                      </CardContent>
                    </Card>
                  </Link>
                </Grid>
48

Matija Obreza's avatar
Matija Obreza committed
49
                <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
Oleksii Savran's avatar
Oleksii Savran committed
50
                  <Link to="/request">
Matija Obreza's avatar
Matija Obreza committed
51
                    <Card className={ classes.card }>
Oleksii Savran's avatar
Oleksii Savran committed
52
                      <CardHeader title={ t('welcome.p.cards.distribution.title') }/>
Matija Obreza's avatar
Matija Obreza committed
53
                      <CardContent>
Oleksii Savran's avatar
Oleksii Savran committed
54
                        <div>{ t('welcome.p.cards.distribution.description') }</div>
Matija Obreza's avatar
Matija Obreza committed
55
56
57
58
                      </CardContent>
                    </Card>
                  </Link>
                </Grid>
Oleksii Savran's avatar
Oleksii Savran committed
59

60
                <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
Oleksii Savran's avatar
Oleksii Savran committed
61
                  <Link to="/request/new">
62
                    <Card className={ classes.card }>
Oleksii Savran's avatar
Oleksii Savran committed
63
                      <CardHeader title={ t('welcome.p.cards.distribution.new.title') }/>
64
                      <CardContent>
Oleksii Savran's avatar
Oleksii Savran committed
65
                        <div>{ t('welcome.p.cards.distribution.new.description') }</div>
66
67
68
69
                      </CardContent>
                    </Card>
                  </Link>
                </Grid>
Oleksii Savran's avatar
Oleksii Savran committed
70

Matija Obreza's avatar
Matija Obreza committed
71
                <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
Oleksii Savran's avatar
Oleksii Savran committed
72
                  <Link to="/request/checklist">
Matija Obreza's avatar
Matija Obreza committed
73
                    <Card className={ classes.card }>
Oleksii Savran's avatar
Oleksii Savran committed
74
                      <CardHeader title={ t('welcome.p.cards.distribution.checklist.title') }/>
Matija Obreza's avatar
Matija Obreza committed
75
                      <CardContent>
Oleksii Savran's avatar
Oleksii Savran committed
76
                        <div>{ t('welcome.p.cards.distribution.checklist.description') }</div>
Matija Obreza's avatar
Matija Obreza committed
77
78
79
80
                      </CardContent>
                    </Card>
                  </Link>
                </Grid>
Oleksii Savran's avatar
Oleksii Savran committed
81
82
83
84
85
86
              </>
            </Authorize>

            <Authorize roles={ [ UserRole.USER ] }>
              <>
                <SectionHeader title={ t('client:model._.inventory') } className="m-halfrem pt-5 pb-5"/>
Matija Obreza's avatar
Matija Obreza committed
87
                <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
Oleksii Savran's avatar
Oleksii Savran committed
88
                  <Link to="/inventory/summary">
Matija Obreza's avatar
Matija Obreza committed
89
                    <Card className={ classes.card }>
Oleksii Savran's avatar
Oleksii Savran committed
90
                      <CardHeader title={ t('welcome.p.cards.inventorySummary.title') }/>
Matija Obreza's avatar
Matija Obreza committed
91
                      <CardContent>
Oleksii Savran's avatar
Oleksii Savran committed
92
                        <div>{ t('welcome.p.cards.inventorySummary.description') }</div>
Matija Obreza's avatar
Matija Obreza committed
93
94
95
96
97
                      </CardContent>
                    </Card>
                  </Link>
                </Grid>
                <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
Oleksii Savran's avatar
Oleksii Savran committed
98
                  <Link to="/inventory">
Matija Obreza's avatar
Matija Obreza committed
99
                    <Card className={ classes.card }>
Oleksii Savran's avatar
Oleksii Savran committed
100
                      <CardHeader title={ t('welcome.p.cards.inventory.title') }/>
Matija Obreza's avatar
Matija Obreza committed
101
                      <CardContent>
Oleksii Savran's avatar
Oleksii Savran committed
102
103
104
105
106
107
108
109
110
111
112
                        <div>{ t('welcome.p.cards.inventory.description') }</div>
                      </CardContent>
                    </Card>
                  </Link>
                </Grid>
                <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
                  <Link to="/inventory/group">
                    <Card className={ classes.card }>
                      <CardHeader title={ t('welcome.p.cards.inventorygroup.title') }/>
                      <CardContent>
                        <div>{ t('welcome.p.cards.inventorygroup.description') }</div>
Matija Obreza's avatar
Matija Obreza committed
113
114
115
116
                      </CardContent>
                    </Card>
                  </Link>
                </Grid>
Oleksii Savran's avatar
Oleksii Savran committed
117
118
119
120
121
122
123
124
125
126
                <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
                  <Link to="/inventory/action">
                    <Card className={ classes.card }>
                      <CardHeader title={ t('welcome.p.cards.inventoryAction.title') }/>
                      <CardContent>
                        <div>{ t('welcome.p.cards.inventoryAction.description') }</div>
                      </CardContent>
                    </Card>
                  </Link>
                </Grid>
Oleksii Savran's avatar
Oleksii Savran committed
127
                <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
Oleksii Savran's avatar
Oleksii Savran committed
128
                  <Link to="/inventory/adjust">
Oleksii Savran's avatar
Oleksii Savran committed
129
                    <Card className={ classes.card }>
Oleksii Savran's avatar
Oleksii Savran committed
130
                      <CardHeader title={ t('welcome.p.cards.inventoryadjust.title') }/>
Oleksii Savran's avatar
Oleksii Savran committed
131
                      <CardContent>
Oleksii Savran's avatar
Oleksii Savran committed
132
                        <div>{ t('welcome.p.cards.inventoryadjust.description') }</div>
Oleksii Savran's avatar
Oleksii Savran committed
133
134
135
136
                      </CardContent>
                    </Card>
                  </Link>
                </Grid>
Matija Obreza's avatar
Matija Obreza committed
137
              </>
138
139
            </Authorize>

Oleksii Savran's avatar
Oleksii Savran committed
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
            <SectionHeader title={ t('client:model._.accession') } className="m-halfrem pt-5 pb-5"/>

            <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
              <Link to="/a/summary">
                <Card className={ classes.card }>
                  <CardHeader title={ t('welcome.p.cards.accessionSummary.title') }/>
                  <CardContent>
                    <div>{ t('welcome.p.cards.accessionSummary.description') }</div>
                  </CardContent>
                </Card>
              </Link>
            </Grid>

            <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
              <Link to="/a">
                <Card className={ classes.card }>
                  <CardHeader title={ t('welcome.p.cards.accessions.title') }/>
                  <CardContent>
                    <div>{ t('welcome.p.cards.accessions.description') }</div>
                  </CardContent>
                </Card>
              </Link>
            </Grid>

            <Authorize roles={ [ UserRole.USER ] }>
              <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
                <Link to="/a/action">
                  <Card className={ classes.card }>
                    <CardHeader title={ t('welcome.p.cards.accessionAction.title') }/>
                    <CardContent>
                      <div>{ t('welcome.p.cards.accessionAction.description') }</div>
                    </CardContent>
                  </Card>
                </Link>
              </Grid>
            </Authorize>

            <SectionHeader title={ t('welcome.p.sections.taxonomy')  } className="m-halfrem pt-5 pb-5"/>

            <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
              <Link to="/t/species">
                <Card className={ classes.card }>
                  <CardHeader title={ t('welcome.p.cards.species.title') }/>
                  <CardContent>
                    <div>{ t('welcome.p.cards.species.description') }</div>
                  </CardContent>
                </Card>
              </Link>
            </Grid>
            <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
              <Link to="/t/genus">
                <Card className={ classes.card }>
                  <CardHeader title={ t('welcome.p.cards.genera.title') }/>
                  <CardContent>
                    <div>{ t('welcome.p.cards.genera.description') }</div>
                  </CardContent>
                </Card>
              </Link>
            </Grid>

            <Authorize roles={ [ UserRole.USER ] }>
              <SectionHeader title={ t('welcome.p.sections.other') } className="m-halfrem pt-5 pb-5"/>
            </Authorize>

204
            <Authorize roles={ [ UserRole.USER ] }>
205
              <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
206
207
208
209
210
211
212
213
214
215
216
                <Link to="/cooperator">
                  <Card className={ classes.card }>
                    <CardHeader title={ t('welcome.p.cards.cooperators.title') }/>
                    <CardContent>
                      <div>{ t('welcome.p.cards.cooperators.description') }</div>
                    </CardContent>
                  </Card>
                </Link>
              </Grid>
            </Authorize>

217
            <Authorize roles={ [ UserRole.USER ] }>
218
              <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
219
                <Card className={ `${classes.card} ${classes.cardDisabled}` }>
Matija Obreza's avatar
Matija Obreza committed
220
                  <CardHeader title={ t('welcome.p.cards.todo.title') }/>
221
                  <CardContent>
Matija Obreza's avatar
Matija Obreza committed
222
                    <div>{ t('welcome.p.cards.todo.description') }</div>
223
224
                  </CardContent>
                </Card>
225
226
227
              </Grid>
            </Authorize>

228
            <Authorize roles={ [ UserRole.ADMINISTRATOR ] }>
229
              <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
230
231
232
233
234
235
236
237
238
239
240
                <Link to="/admin/location">
                  <Card className={ classes.card }>
                    <CardHeader title={ t('welcome.p.cards.siteLocation.title') }/>
                    <CardContent>
                      <div>{ t('welcome.p.cards.siteLocation.description') }</div>
                    </CardContent>
                  </Card>
                </Link>
              </Grid>
            </Authorize>

Oleksii Savran's avatar
Oleksii Savran committed
241
242
243
244
245
246
247
248
249
250
251
252
253
            <Authorize roles={ [ UserRole.ADMINISTRATOR ] }>
              <Grid item xs={ 12 } sm={ 6 } md={ 4 } lg={ 3 }>
                <Link to="/admin/site">
                  <Card className={ classes.card }>
                    <CardHeader title={ t('welcome.p.cards.site.title') }/>
                    <CardContent>
                      <div>{ t('welcome.p.cards.site.description') }</div>
                    </CardContent>
                  </Card>
                </Link>
              </Grid>
            </Authorize>

Oleksii Savran's avatar
Oleksii Savran committed
254
255
          </Grid>
        </div>
Matija Obreza's avatar
Matija Obreza committed
256
257
      </>
    );
258
259
260
261
  }

}

Oleksii Savran's avatar
Oleksii Savran committed
262
export default withTranslation()(withStyles(styles)(WelcomePage));