generated from EasyWebApp/WebCell-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathList.tsx
More file actions
75 lines (70 loc) · 1.94 KB
/
List.tsx
File metadata and controls
75 lines (70 loc) · 1.94 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
import { Session } from '@open-source-bazaar/activityhub-service';
import { computed } from 'mobx';
import { observer } from 'mobx-react';
import { ObservedComponent } from 'mobx-react-helper';
import { Column, RestTable } from 'mobx-restful-table';
import { Button } from 'react-bootstrap';
import sessionStore from '../../models/Session';
import { i18n, I18nContext } from '../../models/Translation';
@observer
export class SessionList extends ObservedComponent<{}, typeof i18n> {
static contextType = I18nContext;
@computed
get columns(): Column<Session>[] {
const { t } = this.observedContext;
return [
{
key: 'title',
renderHead: t('title'),
renderBody: ({ title }) => title || t('unknown'),
required: true,
invalidMessage: t('field_required'),
},
{
key: 'summary',
renderHead: t('summary'),
renderBody: ({ summary }) => summary || '-',
type: 'textarea',
rows: 3,
},
{
key: 'durationMinute',
renderHead: t('duration_minutes'),
renderBody: ({ durationMinute }) => `${durationMinute || 0} ${t('minutes')}`,
type: 'number',
min: 1,
required: true,
invalidMessage: t('field_required'),
},
{
key: 'peopleCapacity',
renderHead: t('people_capacity'),
renderBody: ({ peopleCapacity }) => peopleCapacity || '-',
type: 'number',
min: 1,
},
{
renderHead: t('actions'),
renderBody: () => (
<Button variant="outline-success" size="sm" href="/user/agenda">
{t('submit_to_activity')}
</Button>
),
},
];
}
render() {
return (
<RestTable
className="h-100 text-center"
striped
hover
editable
deletable
columns={this.columns}
store={sessionStore}
translator={this.observedContext}
/>
);
}
}