ehr-alerts-ui 0.0.25 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.husky/pre-commit +4 -0
- package/.prettierrc +13 -0
- package/lib/index.cjs.js +1 -1
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +22 -11
- package/src/App.tsx +19 -23
- package/src/index.tsx +1 -2
- package/src/library/actions/AlertActions.ts +91 -66
- package/src/library/actions/TableActions.ts +55 -54
- package/src/library/components/AlertModal/AlertModal.tsx +251 -152
- package/src/library/components/AlertModal/AlertModalContainer.tsx +16 -14
- package/src/library/components/AlertModal/index.ts +1 -1
- package/src/library/components/AlertsTable/AlertsTable.tsx +144 -66
- package/src/library/components/AlertsTable/AlertsTableContainer.tsx +37 -24
- package/src/library/components/AlertsTable/SortableRow/SortableRow.tsx +53 -33
- package/src/library/components/AlertsTable/SortableRow/index.ts +1 -1
- package/src/library/components/AlertsTable/index.ts +1 -1
- package/src/library/components/Header/Header.tsx +11 -12
- package/src/library/components/Header/HeaderContainer.tsx +13 -11
- package/src/library/components/Header/index.ts +1 -1
- package/src/library/components/MainPage/MainPage.tsx +17 -18
- package/src/library/components/MainPage/index.ts +2 -2
- package/src/library/configureStore.ts +10 -14
- package/src/library/helpers/appendZero.ts +1 -1
- package/src/library/helpers/printDate.ts +1 -1
- package/src/library/index.ts +1 -1
- package/src/library/reducers/alertReducer.ts +19 -20
- package/src/library/reducers/index.ts +6 -6
- package/src/library/reducers/tableReducer.ts +32 -33
- package/src/react-app-env.d.ts +1 -1
- package/src/setupProxy.js +9 -7
- package/src/translations/elements_et.json +231 -244
- package/tsconfig.json +1 -1
|
@@ -1,35 +1,47 @@
|
|
|
1
|
-
import React, {useEffect, useState} from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
CollapseTable,
|
|
5
|
+
CollapseTableRow,
|
|
6
|
+
ControlledPopover,
|
|
7
|
+
Tooltip,
|
|
8
|
+
} from 'ehr-components';
|
|
9
|
+
import SortableRow from './SortableRow';
|
|
10
|
+
import { Alert } from '../../reducers/tableReducer';
|
|
11
|
+
import { ReactComponent as CopyIcon } from '../../assets/icons/copy.svg';
|
|
12
|
+
import { ReactComponent as DeleteIcon } from '../../assets/icons/delete.svg';
|
|
13
|
+
import { ReactComponent as EditIcon } from '../../assets/icons/edit.svg';
|
|
8
14
|
import styles from '../../assets/styles/contstants.module.scss';
|
|
9
|
-
import {FormattedMessage} from
|
|
10
|
-
|
|
15
|
+
import { FormattedMessage } from 'react-intl';
|
|
11
16
|
|
|
12
17
|
export interface AlertsTableState {
|
|
13
|
-
alerts: Alert[]
|
|
18
|
+
alerts: Alert[];
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
export interface AlertsTableDispatch {
|
|
17
|
-
loadAlerts: () => void
|
|
18
|
-
clearAlerts: () => void
|
|
19
|
-
editAlert: (alert: Alert) => void
|
|
20
|
-
setDeleteOpen: (id: number) => void
|
|
21
|
-
clearDeletes: () => void
|
|
22
|
-
deleteAlert: (id: number) => void
|
|
23
|
-
duplicateAlert: (alert: Alert) => void
|
|
22
|
+
loadAlerts: () => void;
|
|
23
|
+
clearAlerts: () => void;
|
|
24
|
+
editAlert: (alert: Alert) => void;
|
|
25
|
+
setDeleteOpen: (id: number) => void;
|
|
26
|
+
clearDeletes: () => void;
|
|
27
|
+
deleteAlert: (id: number) => void;
|
|
28
|
+
duplicateAlert: (alert: Alert) => void;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
interface InnerAlert extends Alert {
|
|
27
|
-
time: string
|
|
32
|
+
time: string;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
|
-
const AlertsTable: React.FC<AlertsTableState & AlertsTableDispatch> = ({
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
const AlertsTable: React.FC<AlertsTableState & AlertsTableDispatch> = ({
|
|
36
|
+
alerts,
|
|
37
|
+
loadAlerts,
|
|
38
|
+
clearAlerts,
|
|
39
|
+
editAlert,
|
|
40
|
+
clearDeletes,
|
|
41
|
+
setDeleteOpen,
|
|
42
|
+
deleteAlert,
|
|
43
|
+
duplicateAlert,
|
|
44
|
+
}) => {
|
|
33
45
|
const [content, setContent] = useState<any[]>([]);
|
|
34
46
|
const [header, setHeader] = useState<(string | JSX.Element)[]>([]);
|
|
35
47
|
|
|
@@ -52,22 +64,23 @@ const AlertsTable: React.FC<AlertsTableState & AlertsTableDispatch> = ({alerts,
|
|
|
52
64
|
|
|
53
65
|
return () => {
|
|
54
66
|
clearAlerts();
|
|
55
|
-
}
|
|
67
|
+
};
|
|
56
68
|
}, []);
|
|
57
69
|
|
|
58
70
|
// Update content
|
|
59
71
|
useEffect(() => {
|
|
60
72
|
setContent(
|
|
61
|
-
alerts
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
73
|
+
alerts
|
|
74
|
+
.filter((alert) => !alert.deleted)
|
|
75
|
+
.map((alert) => ({
|
|
76
|
+
...alert,
|
|
77
|
+
time: `${alert.begin} - ${alert.end}`,
|
|
78
|
+
})),
|
|
65
79
|
);
|
|
66
80
|
|
|
67
81
|
updateHeader();
|
|
68
82
|
}, [alerts]);
|
|
69
83
|
|
|
70
|
-
|
|
71
84
|
function onAccenting(index: number | string) {
|
|
72
85
|
sortContent(index, -1);
|
|
73
86
|
updateHeader(index, undefined);
|
|
@@ -92,30 +105,65 @@ const AlertsTable: React.FC<AlertsTableState & AlertsTableDispatch> = ({alerts,
|
|
|
92
105
|
// for each element of that array take the index (column) in which we want to sort.
|
|
93
106
|
// Then sort it based on the direction the user has defined.
|
|
94
107
|
setContent((content) => {
|
|
95
|
-
return [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
108
|
+
return [
|
|
109
|
+
...content.sort((c1, c2) => {
|
|
110
|
+
if (c1[index] < c2[index]) {
|
|
111
|
+
return direction;
|
|
112
|
+
}
|
|
113
|
+
if (c1[index] > c2[index]) {
|
|
114
|
+
return -direction;
|
|
115
|
+
}
|
|
116
|
+
return 0;
|
|
117
|
+
}),
|
|
118
|
+
];
|
|
104
119
|
});
|
|
105
120
|
}
|
|
106
121
|
|
|
107
|
-
function updateHeader(
|
|
122
|
+
function updateHeader(
|
|
123
|
+
accentingIndex?: number | string,
|
|
124
|
+
descendingIndex?: number | string,
|
|
125
|
+
) {
|
|
108
126
|
setHeader([
|
|
109
|
-
<SortableRow
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
<SortableRow
|
|
118
|
-
|
|
127
|
+
<SortableRow
|
|
128
|
+
title="Teate pealkiri"
|
|
129
|
+
index={'title'}
|
|
130
|
+
onAccenting={onAccenting}
|
|
131
|
+
onDescending={onDescending}
|
|
132
|
+
isAccenting={accentingIndex === 'title'}
|
|
133
|
+
isDescending={descendingIndex === 'title'}
|
|
134
|
+
/>,
|
|
135
|
+
<SortableRow
|
|
136
|
+
title="Teate publik"
|
|
137
|
+
index={'audience'}
|
|
138
|
+
onAccenting={onAccenting}
|
|
139
|
+
onDescending={onDescending}
|
|
140
|
+
isAccenting={accentingIndex === 'audience'}
|
|
141
|
+
isDescending={descendingIndex === 'audience'}
|
|
142
|
+
/>,
|
|
143
|
+
<SortableRow
|
|
144
|
+
title="Teate tase"
|
|
145
|
+
index={'level'}
|
|
146
|
+
onAccenting={onAccenting}
|
|
147
|
+
onDescending={onDescending}
|
|
148
|
+
isAccenting={accentingIndex === 'level'}
|
|
149
|
+
isDescending={descendingIndex === 'level'}
|
|
150
|
+
/>,
|
|
151
|
+
<SortableRow
|
|
152
|
+
title="Teate kuvamise aeg"
|
|
153
|
+
index={'time'}
|
|
154
|
+
onAccenting={onAccenting}
|
|
155
|
+
onDescending={onDescending}
|
|
156
|
+
isAccenting={accentingIndex === 'time'}
|
|
157
|
+
isDescending={descendingIndex === 'time'}
|
|
158
|
+
/>,
|
|
159
|
+
<SortableRow
|
|
160
|
+
title="Teate sisu"
|
|
161
|
+
index={'content'}
|
|
162
|
+
onAccenting={onAccenting}
|
|
163
|
+
onDescending={onDescending}
|
|
164
|
+
isAccenting={accentingIndex === 'content'}
|
|
165
|
+
isDescending={descendingIndex === 'content'}
|
|
166
|
+
/>,
|
|
119
167
|
'',
|
|
120
168
|
'',
|
|
121
169
|
'',
|
|
@@ -125,18 +173,41 @@ const AlertsTable: React.FC<AlertsTableState & AlertsTableDispatch> = ({alerts,
|
|
|
125
173
|
const deleteContent = (id: number) => (
|
|
126
174
|
<div>
|
|
127
175
|
<h4>
|
|
128
|
-
<FormattedMessage
|
|
176
|
+
<FormattedMessage
|
|
177
|
+
defaultMessage={'Kas olete kindel, et soovite selle rea kustutada?'}
|
|
178
|
+
id={'common.confirmation.modal.header'}
|
|
179
|
+
/>
|
|
129
180
|
</h4>
|
|
130
181
|
<p>
|
|
131
|
-
<FormattedMessage
|
|
182
|
+
<FormattedMessage
|
|
183
|
+
defaultMessage={'Kustutatud ridu ei ole võimalik hiljem taastada'}
|
|
184
|
+
id={'common.confirmation.modal.description'}
|
|
185
|
+
/>
|
|
132
186
|
</p>
|
|
133
187
|
|
|
134
188
|
<div>
|
|
135
|
-
<Button
|
|
136
|
-
|
|
189
|
+
<Button
|
|
190
|
+
colourScheme={'light'}
|
|
191
|
+
squared
|
|
192
|
+
type={'reset'}
|
|
193
|
+
onClick={onDeleteCancel}
|
|
194
|
+
>
|
|
195
|
+
<FormattedMessage
|
|
196
|
+
defaultMessage={'Loobun'}
|
|
197
|
+
id={'common.confirmation.modal.no'}
|
|
198
|
+
/>
|
|
137
199
|
</Button>
|
|
138
|
-
<Button
|
|
139
|
-
|
|
200
|
+
<Button
|
|
201
|
+
className={'float-right'}
|
|
202
|
+
colourScheme={'danger'}
|
|
203
|
+
onClick={() => onDeletePress(id)}
|
|
204
|
+
squared
|
|
205
|
+
type={'submit'}
|
|
206
|
+
>
|
|
207
|
+
<FormattedMessage
|
|
208
|
+
defaultMessage={'Kustutan'}
|
|
209
|
+
id={'common.confirmation.modal.yes'}
|
|
210
|
+
/>
|
|
140
211
|
</Button>
|
|
141
212
|
</div>
|
|
142
213
|
</div>
|
|
@@ -157,13 +228,19 @@ const AlertsTable: React.FC<AlertsTableState & AlertsTableDispatch> = ({alerts,
|
|
|
157
228
|
alert.level,
|
|
158
229
|
alert.time,
|
|
159
230
|
alert.content,
|
|
160
|
-
<Tooltip content=
|
|
161
|
-
<button
|
|
231
|
+
<Tooltip content="Kopeerin">
|
|
232
|
+
<button
|
|
233
|
+
className="alerts-ui--icon-button"
|
|
234
|
+
onClick={() => duplicateAlert(alert)}
|
|
235
|
+
>
|
|
162
236
|
<CopyIcon fill={styles.colorGreyDark} />
|
|
163
237
|
</button>
|
|
164
238
|
</Tooltip>,
|
|
165
|
-
<Tooltip content=
|
|
166
|
-
<button
|
|
239
|
+
<Tooltip content="Muudan">
|
|
240
|
+
<button
|
|
241
|
+
className="alerts-ui--icon-button"
|
|
242
|
+
onClick={() => editAlert(alert)}
|
|
243
|
+
>
|
|
167
244
|
<EditIcon fill={styles.colorGreyDark} />
|
|
168
245
|
</button>
|
|
169
246
|
</Tooltip>,
|
|
@@ -176,8 +253,10 @@ const AlertsTable: React.FC<AlertsTableState & AlertsTableDispatch> = ({alerts,
|
|
|
176
253
|
toggle={() => onToggleDeletePopup(alert)}
|
|
177
254
|
>
|
|
178
255
|
<div>
|
|
179
|
-
<Tooltip content=
|
|
180
|
-
<button className=
|
|
256
|
+
<Tooltip content="Kustutan">
|
|
257
|
+
<button className="alerts-ui--icon-button">
|
|
258
|
+
<DeleteIcon fill={styles.colorGreyDark} />
|
|
259
|
+
</button>
|
|
181
260
|
</Tooltip>
|
|
182
261
|
</div>
|
|
183
262
|
</ControlledPopover>,
|
|
@@ -185,16 +264,15 @@ const AlertsTable: React.FC<AlertsTableState & AlertsTableDispatch> = ({alerts,
|
|
|
185
264
|
}
|
|
186
265
|
|
|
187
266
|
return (
|
|
188
|
-
<div id=
|
|
267
|
+
<div id="alerts-ui--alerts-table">
|
|
189
268
|
<CollapseTable
|
|
190
|
-
content={
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
269
|
+
content={content.map((file, i) => (
|
|
270
|
+
<CollapseTableRow fields={createTableRow(file)} />
|
|
271
|
+
))}
|
|
194
272
|
headers={header}
|
|
195
273
|
/>
|
|
196
274
|
</div>
|
|
197
275
|
);
|
|
198
|
-
}
|
|
276
|
+
};
|
|
199
277
|
|
|
200
|
-
export default AlertsTable;
|
|
278
|
+
export default AlertsTable;
|
|
@@ -1,18 +1,29 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import {connect} from
|
|
3
|
-
import {AlertsUiState} from
|
|
4
|
-
import AlertsTable, {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import { AlertsUiState } from '../../reducers';
|
|
4
|
+
import AlertsTable, {
|
|
5
|
+
AlertsTableDispatch,
|
|
6
|
+
AlertsTableState,
|
|
7
|
+
} from './AlertsTable';
|
|
8
|
+
import {
|
|
9
|
+
clearDeletes,
|
|
10
|
+
clearTable,
|
|
11
|
+
deleteAlert,
|
|
12
|
+
loadAlerts,
|
|
13
|
+
setDeleteOpen,
|
|
14
|
+
} from '../../actions/TableActions';
|
|
15
|
+
import { ThunkDispatch } from 'redux-thunk';
|
|
16
|
+
import { editAlert } from '../../actions/AlertActions';
|
|
8
17
|
|
|
9
18
|
function mapStateToProps(state: AlertsUiState): AlertsTableState {
|
|
10
19
|
return {
|
|
11
20
|
alerts: state.table.alerts,
|
|
12
|
-
}
|
|
21
|
+
};
|
|
13
22
|
}
|
|
14
23
|
|
|
15
|
-
function mapDispatchToProps(
|
|
24
|
+
function mapDispatchToProps(
|
|
25
|
+
dispatch: ThunkDispatch<any, any, any>,
|
|
26
|
+
): AlertsTableDispatch {
|
|
16
27
|
return {
|
|
17
28
|
loadAlerts: () => {
|
|
18
29
|
dispatch(loadAlerts());
|
|
@@ -33,21 +44,23 @@ function mapDispatchToProps(dispatch: ThunkDispatch<any, any, any>): AlertsTable
|
|
|
33
44
|
dispatch(deleteAlert(id));
|
|
34
45
|
},
|
|
35
46
|
duplicateAlert: (alert) => {
|
|
36
|
-
dispatch(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
dispatch(
|
|
48
|
+
editAlert({
|
|
49
|
+
id: 0,
|
|
50
|
+
audience: alert.audience,
|
|
51
|
+
level: alert.level,
|
|
52
|
+
title: alert.title,
|
|
53
|
+
content: alert.content,
|
|
54
|
+
begin: undefined,
|
|
55
|
+
beginHour: undefined,
|
|
56
|
+
beginMinute: undefined,
|
|
57
|
+
end: undefined,
|
|
58
|
+
endHour: undefined,
|
|
59
|
+
endMinute: undefined,
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
};
|
|
51
64
|
}
|
|
52
65
|
|
|
53
66
|
export default connect(mapStateToProps, mapDispatchToProps)(AlertsTable);
|
|
@@ -1,47 +1,67 @@
|
|
|
1
|
-
import React, {useEffect} from 'react';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
|
|
3
|
-
import {ReactComponent as ArrowDown} from
|
|
4
|
-
import {ReactComponent as ArrowUp} from
|
|
3
|
+
import { ReactComponent as ArrowDown } from '../../../assets/icons/arrow_down.svg';
|
|
4
|
+
import { ReactComponent as ArrowUp } from '../../../assets/icons/arrow_up.svg';
|
|
5
5
|
import styles from '../../../assets/styles/contstants.module.scss';
|
|
6
6
|
|
|
7
7
|
export interface SortableRowProps {
|
|
8
|
-
title: string
|
|
9
|
-
index: number | string
|
|
10
|
-
isAccenting: boolean
|
|
11
|
-
isDescending: boolean
|
|
12
|
-
onAccenting: (index: number | string) => void
|
|
13
|
-
onDescending: (index: number | string) => void
|
|
8
|
+
title: string;
|
|
9
|
+
index: number | string;
|
|
10
|
+
isAccenting: boolean;
|
|
11
|
+
isDescending: boolean;
|
|
12
|
+
onAccenting: (index: number | string) => void;
|
|
13
|
+
onDescending: (index: number | string) => void;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const SortableRow: React.FC<SortableRowProps> = ({
|
|
17
|
-
|
|
16
|
+
const SortableRow: React.FC<SortableRowProps> = ({
|
|
17
|
+
title,
|
|
18
|
+
index,
|
|
19
|
+
isDescending,
|
|
20
|
+
isAccenting,
|
|
21
|
+
onAccenting,
|
|
22
|
+
onDescending,
|
|
23
|
+
}) => {
|
|
18
24
|
return (
|
|
19
|
-
<div className=
|
|
20
|
-
<div className=
|
|
21
|
-
<button
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
<div className="alerts-ui--row-header">
|
|
26
|
+
<div className="alerts-ui--row-header--arrows">
|
|
27
|
+
<button
|
|
28
|
+
className="alerts-ui--icon-button mb-1"
|
|
29
|
+
onClick={() => onAccenting(index)}
|
|
30
|
+
>
|
|
31
|
+
{isAccenting && (
|
|
32
|
+
<ArrowUp
|
|
33
|
+
fill={styles.colorBlue}
|
|
34
|
+
aria-label="Sort based on this row, accenting enabled."
|
|
35
|
+
/>
|
|
36
|
+
)}
|
|
37
|
+
{!isAccenting && (
|
|
38
|
+
<ArrowUp
|
|
39
|
+
fill={styles.colorGrey}
|
|
40
|
+
aria-label="Sort based on this row, accenting."
|
|
41
|
+
/>
|
|
42
|
+
)}
|
|
30
43
|
</button>
|
|
31
|
-
<button
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
<button
|
|
45
|
+
className="alerts-ui--icon-button"
|
|
46
|
+
onClick={() => onDescending(index)}
|
|
47
|
+
>
|
|
48
|
+
{isDescending && (
|
|
49
|
+
<ArrowDown
|
|
50
|
+
fill={styles.colorBlue}
|
|
51
|
+
aria-label="Sort based on this row, descending enabled."
|
|
52
|
+
/>
|
|
53
|
+
)}
|
|
54
|
+
{!isDescending && (
|
|
55
|
+
<ArrowDown
|
|
56
|
+
fill={styles.colorGrey}
|
|
57
|
+
aria-label="Sort based on this row, descending."
|
|
58
|
+
/>
|
|
59
|
+
)}
|
|
40
60
|
</button>
|
|
41
61
|
</div>
|
|
42
62
|
<p>{title}</p>
|
|
43
63
|
</div>
|
|
44
64
|
);
|
|
45
|
-
}
|
|
65
|
+
};
|
|
46
66
|
|
|
47
|
-
export default SortableRow;
|
|
67
|
+
export default SortableRow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {default} from './SortableRow';
|
|
1
|
+
export { default } from './SortableRow';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {default} from './AlertsTableContainer';
|
|
1
|
+
export { default } from './AlertsTableContainer';
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import {Button} from 'ehr-components';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from 'ehr-components';
|
|
3
3
|
|
|
4
|
-
export interface HeaderState {
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
export interface HeaderState {}
|
|
7
5
|
|
|
8
6
|
export interface HeaderDispatch {
|
|
9
|
-
createAlert: () => void
|
|
7
|
+
createAlert: () => void;
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
const Header: React.FC<HeaderState & HeaderDispatch> = ({createAlert}) => {
|
|
13
|
-
|
|
10
|
+
const Header: React.FC<HeaderState & HeaderDispatch> = ({ createAlert }) => {
|
|
14
11
|
function onCreateAlert() {
|
|
15
12
|
createAlert();
|
|
16
13
|
}
|
|
17
14
|
|
|
18
15
|
return (
|
|
19
|
-
<div id=
|
|
16
|
+
<div id="alerts-ui--header">
|
|
20
17
|
<h2>Teadete haldus</h2>
|
|
21
|
-
<Button withPlus onClick={onCreateAlert}>
|
|
18
|
+
<Button withPlus onClick={onCreateAlert}>
|
|
19
|
+
Lisan uue teate
|
|
20
|
+
</Button>
|
|
22
21
|
</div>
|
|
23
22
|
);
|
|
24
|
-
}
|
|
23
|
+
};
|
|
25
24
|
|
|
26
|
-
export default Header;
|
|
25
|
+
export default Header;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import {connect} from
|
|
3
|
-
import {AlertsUiState} from
|
|
4
|
-
import Header, {HeaderDispatch, HeaderState} from
|
|
5
|
-
import {ThunkDispatch} from
|
|
6
|
-
import {createAlert} from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import { AlertsUiState } from '../../reducers';
|
|
4
|
+
import Header, { HeaderDispatch, HeaderState } from './Header';
|
|
5
|
+
import { ThunkDispatch } from 'redux-thunk';
|
|
6
|
+
import { createAlert } from '../../actions/AlertActions';
|
|
7
7
|
|
|
8
8
|
function mapStateToProps(state: AlertsUiState): HeaderState {
|
|
9
|
-
return {}
|
|
9
|
+
return {};
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
function mapDispatchToProps(
|
|
12
|
+
function mapDispatchToProps(
|
|
13
|
+
dispatch: ThunkDispatch<any, any, any>,
|
|
14
|
+
): HeaderDispatch {
|
|
13
15
|
return {
|
|
14
16
|
createAlert: () => {
|
|
15
17
|
dispatch(createAlert());
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
+
},
|
|
19
|
+
};
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
export default connect(mapStateToProps, mapDispatchToProps)(Header);
|
|
22
|
+
export default connect(mapStateToProps, mapDispatchToProps)(Header);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {default} from './HeaderContainer';
|
|
1
|
+
export { default } from './HeaderContainer';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React, {useEffect, useState} from 'react';
|
|
2
|
-
import {Section} from 'ehr-components';
|
|
3
|
-
import AlertsTable from
|
|
4
|
-
import AlertCreationModal from
|
|
5
|
-
import Header from
|
|
6
|
-
import {Provider} from
|
|
7
|
-
import configureStore from
|
|
8
|
-
import {Store} from
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Section } from 'ehr-components';
|
|
3
|
+
import AlertsTable from '../AlertsTable';
|
|
4
|
+
import AlertCreationModal from '../AlertModal';
|
|
5
|
+
import Header from '../Header';
|
|
6
|
+
import { Provider } from 'react-redux';
|
|
7
|
+
import configureStore from '../../configureStore';
|
|
8
|
+
import { Store } from 'redux';
|
|
9
9
|
|
|
10
10
|
export interface MainPageProps {
|
|
11
|
-
keycloak: any
|
|
11
|
+
keycloak: any;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const MainPage: React.FC<MainPageProps> = ({keycloak}) => {
|
|
14
|
+
const MainPage: React.FC<MainPageProps> = ({ keycloak }) => {
|
|
15
15
|
const [store, setStore] = useState<Store>();
|
|
16
16
|
|
|
17
17
|
useEffect(() => {
|
|
@@ -19,25 +19,24 @@ const MainPage: React.FC<MainPageProps> = ({keycloak}) => {
|
|
|
19
19
|
|
|
20
20
|
return () => {
|
|
21
21
|
setStore(undefined);
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
23
|
}, [keycloak]);
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
26
|
<>
|
|
27
|
-
{
|
|
28
|
-
store &&
|
|
27
|
+
{store && (
|
|
29
28
|
<Provider store={store}>
|
|
30
|
-
<div id=
|
|
29
|
+
<div id="alerts-ui">
|
|
31
30
|
<Header />
|
|
32
|
-
<Section title=
|
|
31
|
+
<Section title="Süsteemi ülesed teated" className="mt-4">
|
|
33
32
|
<AlertsTable />
|
|
34
33
|
</Section>
|
|
35
34
|
<AlertCreationModal />
|
|
36
35
|
</div>
|
|
37
36
|
</Provider>
|
|
38
|
-
}
|
|
37
|
+
)}
|
|
39
38
|
</>
|
|
40
39
|
);
|
|
41
|
-
}
|
|
40
|
+
};
|
|
42
41
|
|
|
43
|
-
export default MainPage;
|
|
42
|
+
export default MainPage;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {default} from './MainPage';
|
|
2
|
-
export type {MainPageProps as EhrAlertsUiProps} from './MainPage';
|
|
1
|
+
export { default } from './MainPage';
|
|
2
|
+
export type { MainPageProps as EhrAlertsUiProps } from './MainPage';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {applyMiddleware, createStore} from 'redux';
|
|
2
|
-
import {createLogger} from 'redux-logger';
|
|
1
|
+
import { applyMiddleware, createStore } from 'redux';
|
|
2
|
+
import { createLogger } from 'redux-logger';
|
|
3
3
|
import thunk from 'redux-thunk';
|
|
4
|
-
import {RefreshMiddleware} from 'ehr-auth-react';
|
|
4
|
+
import { RefreshMiddleware } from 'ehr-auth-react';
|
|
5
5
|
|
|
6
|
-
import reducers, {AlertsUiState} from './reducers';
|
|
6
|
+
import reducers, { AlertsUiState } from './reducers';
|
|
7
7
|
|
|
8
8
|
const middleware = [RefreshMiddleware, thunk];
|
|
9
9
|
|
|
@@ -12,18 +12,14 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
12
12
|
middleware.push(
|
|
13
13
|
createLogger({
|
|
14
14
|
predicate: (getState, action) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
action.type.toString() !== 'KEYCLOAK_REFRESH_SUCCEEDED' &&
|
|
16
|
+
action.type.toString() !== 'AXIOS_ACCESS_TOKEN',
|
|
17
|
+
}),
|
|
18
|
+
);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
|
|
21
21
|
const store = (initialState?: AlertsUiState) => {
|
|
22
|
-
return createStore(
|
|
23
|
-
|
|
24
|
-
initialState,
|
|
25
|
-
applyMiddleware(...middleware),
|
|
26
|
-
);
|
|
27
|
-
}
|
|
22
|
+
return createStore(reducers, initialState, applyMiddleware(...middleware));
|
|
23
|
+
};
|
|
28
24
|
|
|
29
25
|
export default store;
|