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
87 lines (78 loc) · 2.25 KB
/
List.tsx
File metadata and controls
87 lines (78 loc) · 2.25 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
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';
export interface SessionListProps {
showActions?: boolean;
}
@observer
export class SessionList extends ObservedComponent<SessionListProps, typeof i18n> {
static contextType = I18nContext;
@computed
get columns(): Column<Session>[] {
const { t } = this.observedContext;
const { showActions = true } = this.observedProps;
const baseColumns: Column<Session>[] = [
{
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,
},
];
if (showActions) {
baseColumns.push({
renderHead: t('actions'),
renderBody: () => (
<Button variant="outline-success" size="sm" href="/user/agenda">
{t('submit_to_activity')}
</Button>
),
});
}
return baseColumns;
}
render() {
const { showActions = true } = this.observedProps;
return (
<RestTable
className="h-100 text-center"
striped
hover
editable={showActions}
deletable={showActions}
columns={this.columns}
store={sessionStore}
translator={this.observedContext}
/>
);
}
}