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.
Files changed (35) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/.prettierrc +13 -0
  3. package/lib/index.cjs.js +1 -1
  4. package/lib/index.cjs.js.map +1 -1
  5. package/lib/index.js +1 -1
  6. package/lib/index.js.map +1 -1
  7. package/package.json +22 -11
  8. package/src/App.tsx +19 -23
  9. package/src/index.tsx +1 -2
  10. package/src/library/actions/AlertActions.ts +91 -66
  11. package/src/library/actions/TableActions.ts +55 -54
  12. package/src/library/components/AlertModal/AlertModal.tsx +251 -152
  13. package/src/library/components/AlertModal/AlertModalContainer.tsx +16 -14
  14. package/src/library/components/AlertModal/index.ts +1 -1
  15. package/src/library/components/AlertsTable/AlertsTable.tsx +144 -66
  16. package/src/library/components/AlertsTable/AlertsTableContainer.tsx +37 -24
  17. package/src/library/components/AlertsTable/SortableRow/SortableRow.tsx +53 -33
  18. package/src/library/components/AlertsTable/SortableRow/index.ts +1 -1
  19. package/src/library/components/AlertsTable/index.ts +1 -1
  20. package/src/library/components/Header/Header.tsx +11 -12
  21. package/src/library/components/Header/HeaderContainer.tsx +13 -11
  22. package/src/library/components/Header/index.ts +1 -1
  23. package/src/library/components/MainPage/MainPage.tsx +17 -18
  24. package/src/library/components/MainPage/index.ts +2 -2
  25. package/src/library/configureStore.ts +10 -14
  26. package/src/library/helpers/appendZero.ts +1 -1
  27. package/src/library/helpers/printDate.ts +1 -1
  28. package/src/library/index.ts +1 -1
  29. package/src/library/reducers/alertReducer.ts +19 -20
  30. package/src/library/reducers/index.ts +6 -6
  31. package/src/library/reducers/tableReducer.ts +32 -33
  32. package/src/react-app-env.d.ts +1 -1
  33. package/src/setupProxy.js +9 -7
  34. package/src/translations/elements_et.json +231 -244
  35. package/tsconfig.json +1 -1
@@ -1,35 +1,47 @@
1
- import React, {useEffect, useState} from "react";
2
- import {Button, CollapseTable, CollapseTableRow, ControlledPopover, Tooltip} from 'ehr-components';
3
- import SortableRow from "./SortableRow";
4
- import {Alert} from "../../reducers/tableReducer";
5
- import {ReactComponent as CopyIcon} from "../../assets/icons/copy.svg";
6
- import {ReactComponent as DeleteIcon} from "../../assets/icons/delete.svg";
7
- import {ReactComponent as EditIcon} from "../../assets/icons/edit.svg";
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 "react-intl";
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> = ({alerts, loadAlerts, clearAlerts, editAlert,
31
- clearDeletes, setDeleteOpen, deleteAlert,
32
- duplicateAlert}) => {
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.filter((alert) => (!alert.deleted)).map((alert) => ({
62
- ...alert,
63
- time: `${alert.begin} - ${alert.end}`,
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 [...content.sort((c1, c2) => {
96
- if (c1[index] < c2[index]) {
97
- return direction;
98
- }
99
- if (c1[index] > c2[index]) {
100
- return -direction;
101
- }
102
- return 0;
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(accentingIndex?: number | string, descendingIndex?: number | string) {
122
+ function updateHeader(
123
+ accentingIndex?: number | string,
124
+ descendingIndex?: number | string,
125
+ ) {
108
126
  setHeader([
109
- <SortableRow title='Teate pealkiri' index={'title'} onAccenting={onAccenting} onDescending={onDescending}
110
- isAccenting={accentingIndex === 'title'} isDescending={descendingIndex === 'title'} />,
111
- <SortableRow title='Teate publik' index={'audience'} onAccenting={onAccenting} onDescending={onDescending}
112
- isAccenting={accentingIndex === 'audience'} isDescending={descendingIndex === 'audience'} />,
113
- <SortableRow title='Teate tase' index={'level'} onAccenting={onAccenting} onDescending={onDescending}
114
- isAccenting={accentingIndex === 'level'} isDescending={descendingIndex === 'level'} />,
115
- <SortableRow title='Teate kuvamise aeg' index={'time'} onAccenting={onAccenting} onDescending={onDescending}
116
- isAccenting={accentingIndex === 'time'} isDescending={descendingIndex === 'time'} />,
117
- <SortableRow title='Teate sisu' index={'content'} onAccenting={onAccenting} onDescending={onDescending}
118
- isAccenting={accentingIndex === 'content'} isDescending={descendingIndex === 'content'} />,
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 defaultMessage={'Kas olete kindel, et soovite selle rea kustutada?'} id={'common.confirmation.modal.header'} />
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 defaultMessage={'Kustutatud ridu ei ole võimalik hiljem taastada'} id={'common.confirmation.modal.description'} />
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 colourScheme={'light'} squared type={'reset'} onClick={onDeleteCancel}>
136
- <FormattedMessage defaultMessage={'Loobun'} id={'common.confirmation.modal.no'} />
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 className={'float-right'} colourScheme={'danger'} onClick={() => onDeletePress(id)} squared type={'submit'}>
139
- <FormattedMessage defaultMessage={'Kustutan'} id={'common.confirmation.modal.yes'} />
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='Kopeerin'>
161
- <button className='alerts-ui--icon-button' onClick={() => duplicateAlert(alert)}>
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='Muudan'>
166
- <button className='alerts-ui--icon-button' onClick={() => editAlert(alert)}>
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='Kustutan'>
180
- <button className='alerts-ui--icon-button'><DeleteIcon fill={styles.colorGreyDark} /></button>
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='alerts-ui--alerts-table'>
267
+ <div id="alerts-ui--alerts-table">
189
268
  <CollapseTable
190
- content={
191
- content
192
- .map((file, i) => <CollapseTableRow fields={createTableRow(file)}/>)
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 "react";
2
- import {connect} from "react-redux";
3
- import {AlertsUiState} from "../../reducers";
4
- import AlertsTable, {AlertsTableDispatch, AlertsTableState} from "./AlertsTable";
5
- import {clearDeletes, clearTable, deleteAlert, loadAlerts, setDeleteOpen} from "../../actions/TableActions";
6
- import {ThunkDispatch} from "redux-thunk";
7
- import {editAlert} from "../../actions/AlertActions";
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(dispatch: ThunkDispatch<any, any, any>): AlertsTableDispatch {
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(editAlert({
37
- id: 0,
38
- audience: alert.audience,
39
- level: alert.level,
40
- title: alert.title,
41
- content: alert.content,
42
- begin: undefined,
43
- beginHour: undefined,
44
- beginMinute: undefined,
45
- end: undefined,
46
- endHour: undefined,
47
- endMinute: undefined,
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 "../../../assets/icons/arrow_down.svg";
4
- import {ReactComponent as ArrowUp} from "../../../assets/icons/arrow_up.svg";
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> = ({title, index, isDescending, isAccenting, onAccenting, onDescending}) => {
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='alerts-ui--row-header'>
20
- <div className='alerts-ui--row-header--arrows'>
21
- <button className='alerts-ui--icon-button mb-1' onClick={() => onAccenting(index)}>
22
- {
23
- isAccenting &&
24
- <ArrowUp fill={styles.colorBlue} aria-label='Sort based on this row, accenting enabled.'/>
25
- }
26
- {
27
- !isAccenting &&
28
- <ArrowUp fill={styles.colorGrey} aria-label='Sort based on this row, accenting.'/>
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 className='alerts-ui--icon-button' onClick={() => onDescending(index)}>
32
- {
33
- isDescending &&
34
- <ArrowDown fill={styles.colorBlue} aria-label='Sort based on this row, descending enabled.'/>
35
- }
36
- {
37
- !isDescending &&
38
- <ArrowDown fill={styles.colorGrey} aria-label='Sort based on this row, descending.'/>
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 "react";
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='alerts-ui--header'>
16
+ <div id="alerts-ui--header">
20
17
  <h2>Teadete haldus</h2>
21
- <Button withPlus onClick={onCreateAlert}>Lisan uue teate</Button>
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 "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";
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(dispatch: ThunkDispatch<any, any, any>): HeaderDispatch {
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 "../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";
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='alerts-ui'>
29
+ <div id="alerts-ui">
31
30
  <Header />
32
- <Section title='Süsteemi ülesed teated' className='mt-4'>
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
- (action.type.toString() !== 'KEYCLOAK_REFRESH_SUCCEEDED' && action.type.toString() !== 'AXIOS_ACCESS_TOKEN')
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
- reducers,
24
- initialState,
25
- applyMiddleware(...middleware),
26
- );
27
- }
22
+ return createStore(reducers, initialState, applyMiddleware(...middleware));
23
+ };
28
24
 
29
25
  export default store;