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,21 +1,30 @@
1
- import React from "react";
2
- import {Button, DatePicker, FieldWrapper, Input, Section, Select, TextArea, AlertIcon} from 'ehr-components';
3
- import {Alert, Audience, MessageLevel} from "../../reducers/tableReducer";
4
- import appendZero from "../../helpers/appendZero";
5
- import {AlertModalError} from "../../reducers/alertReducer";
1
+ import React from 'react';
2
+ import {
3
+ Button,
4
+ DatePicker,
5
+ FieldWrapper,
6
+ Input,
7
+ Section,
8
+ Select,
9
+ TextArea,
10
+ AlertIcon,
11
+ } from 'ehr-components';
12
+ import { Alert, Audience, MessageLevel } from '../../reducers/tableReducer';
13
+ import appendZero from '../../helpers/appendZero';
14
+ import { AlertModalError } from '../../reducers/alertReducer';
6
15
 
7
16
  export interface AlertModalState {
8
- alert: Alert | undefined,
9
- errors: AlertModalError[],
17
+ alert: Alert | undefined;
18
+ errors: AlertModalError[];
10
19
  }
11
20
 
12
21
  export interface AlertModalDispatch {
13
- editAlert: (alert: Alert) => void,
14
- clearAlert: () => void,
15
- postAlert: () => void,
16
- updateAlert: () => void,
17
- addAlertModalError: (error: AlertModalError) => void,
18
- clearAlertModalErrors: () => void,
22
+ editAlert: (alert: Alert) => void;
23
+ clearAlert: () => void;
24
+ postAlert: () => void;
25
+ updateAlert: () => void;
26
+ addAlertModalError: (error: AlertModalError) => void;
27
+ clearAlertModalErrors: () => void;
19
28
  }
20
29
 
21
30
  enum ContentLanguage {
@@ -25,20 +34,26 @@ enum ContentLanguage {
25
34
  }
26
35
 
27
36
  const audiences = [
28
- {code: Audience.AUTHENTICATED, texts: 'Autenditud kasutaja'},
29
- {code: Audience.NOT_AUTHENTICATED, texts: 'Autentimata kasutaja'},
30
- ]
37
+ { code: Audience.AUTHENTICATED, texts: 'Autenditud kasutaja' },
38
+ { code: Audience.NOT_AUTHENTICATED, texts: 'Autentimata kasutaja' },
39
+ ];
31
40
 
32
41
  const messageLevels = [
33
- {code: MessageLevel.TEADE, texts: 'Teade (roheline)'},
34
- {code: MessageLevel.HOIATUS, texts: 'Hoiatus (kollane)'},
35
- {code: MessageLevel.VEATEADE, texts: 'Veateade (punane)'},
36
- ]
37
-
38
- const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clearAlert, editAlert, postAlert,
39
- updateAlert, addAlertModalError, errors,
40
- clearAlertModalErrors}) => {
41
-
42
+ { code: MessageLevel.TEADE, texts: 'Teade (roheline)' },
43
+ { code: MessageLevel.HOIATUS, texts: 'Hoiatus (kollane)' },
44
+ { code: MessageLevel.VEATEADE, texts: 'Veateade (punane)' },
45
+ ];
46
+
47
+ const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({
48
+ alert,
49
+ clearAlert,
50
+ editAlert,
51
+ postAlert,
52
+ updateAlert,
53
+ addAlertModalError,
54
+ errors,
55
+ clearAlertModalErrors,
56
+ }) => {
42
57
  function onAudienceChange(code: Audience) {
43
58
  if (!alert) {
44
59
  return;
@@ -91,7 +106,7 @@ const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clea
91
106
  editAlert({
92
107
  ...alert,
93
108
  beginMinute: parseInt(value) || 0,
94
- })
109
+ });
95
110
  }
96
111
 
97
112
  function onDateEndChange(date: string) {
@@ -124,7 +139,7 @@ const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clea
124
139
  editAlert({
125
140
  ...alert,
126
141
  endMinute: parseInt(value) || 0,
127
- })
142
+ });
128
143
  }
129
144
 
130
145
  function onTitleChange(lang: ContentLanguage, title: string) {
@@ -253,7 +268,7 @@ const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clea
253
268
  if (!checkMinute(alert.endMinute)) {
254
269
  addAlertModalError({
255
270
  title: 'end_minute',
256
- content: "Please add a valid minute.",
271
+ content: 'Please add a valid minute.',
257
272
  });
258
273
  errors = true;
259
274
  }
@@ -278,16 +293,15 @@ const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clea
278
293
  }
279
294
 
280
295
  function checkHour(hour: number | undefined) {
281
- return (hour !== undefined) && hour >= 0 && hour <= 23;
296
+ return hour !== undefined && hour >= 0 && hour <= 23;
282
297
  }
283
298
 
284
299
  function checkMinute(minute: number | undefined) {
285
- return (minute !== undefined) && minute >= 0 && minute <= 59;
300
+ return minute !== undefined && minute >= 0 && minute <= 59;
286
301
  }
287
302
 
288
-
289
303
  function checkSelfError(title: string): string {
290
- if (errors.filter((error) => (error.title === title)).length > 0) {
304
+ if (errors.filter((error) => error.title === title).length > 0) {
291
305
  return 'has-danger';
292
306
  }
293
307
 
@@ -296,11 +310,10 @@ const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clea
296
310
 
297
311
  return (
298
312
  <>
299
- {
300
- alert &&
301
- <div id='alerts-ui--alert-creation-modal'>
302
- <div className='alerts-ui--alert-creation-modal--modal'>
303
- <h4 className='text-primary'>Teate lisamine</h4>
313
+ {alert && (
314
+ <div id="alerts-ui--alert-creation-modal">
315
+ <div className="alerts-ui--alert-creation-modal--modal">
316
+ <h4 className="text-primary">Teate lisamine</h4>
304
317
 
305
318
  {/*<ul className="alerts-ui--alert-creation-modal--errors">*/}
306
319
  {/* {*/}
@@ -313,101 +326,163 @@ const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clea
313
326
  {/* ))*/}
314
327
  {/* }*/}
315
328
  {/*</ul>*/}
316
- <div className='alerts-ui--alert-creation-modal--content'>
317
-
318
- <FieldWrapper label='Teate publik'
319
- info={{content: 'Autentimata kasutaja on iga kasutaja, kes avab e-ehituse veebilehe. Autenditud kasutaja on kasutaja, kes logib end e-ehituse veebi sisse. Teate loomisel tuleb arvestada, kas teade on vajalik neile, kes on juba lehel sisse loginud või kõikidele, kes lehele satuvad.'}}
320
- className={checkSelfError('publik')}
321
- component={
322
- <Select name='audience' value={alert.audience} onChange={onAudienceChange} options={audiences} />
323
- }
324
- required
329
+ <div className="alerts-ui--alert-creation-modal--content">
330
+ <FieldWrapper
331
+ label="Teate publik"
332
+ info={{
333
+ content:
334
+ 'Autentimata kasutaja on iga kasutaja, kes avab e-ehituse veebilehe. Autenditud kasutaja on kasutaja, kes logib end e-ehituse veebi sisse. Teate loomisel tuleb arvestada, kas teade on vajalik neile, kes on juba lehel sisse loginud või kõikidele, kes lehele satuvad.',
335
+ }}
336
+ className={checkSelfError('publik')}
337
+ component={
338
+ <Select
339
+ name="audience"
340
+ value={alert.audience}
341
+ onChange={onAudienceChange}
342
+ options={audiences}
343
+ />
344
+ }
345
+ required
325
346
  />
326
347
 
327
- <FieldWrapper label='Teate tase'
328
- info={{content: 'Teade (roheline) on neutraalse või positiivse sisuga. Näiteks info uue teenuse või muutuse kohta keskkonnas. Hoiatus (kollane) on hoiatav info millegi kohta, mis võib häirida kasutaja tööd lehel, kuid ei takista. Näiteks suhtlus mõne teise registriga võib olla häiritud. Veateade (punane) on teade selle kohta, et midagi ei tööta ja see takistab tööd lehel. Näiteks teenus on mingi aeg maas, allkirjastamine ei tööta, sisse logida ei saa.'}}
329
- className={checkSelfError('tease')}
330
- component={
331
- <Select name='level' value={alert.level} onChange={onLevelChange} options={messageLevels} />
332
- }
333
- required
348
+ <FieldWrapper
349
+ label="Teate tase"
350
+ info={{
351
+ content:
352
+ 'Teade (roheline) on neutraalse või positiivse sisuga. Näiteks info uue teenuse või muutuse kohta keskkonnas. Hoiatus (kollane) on hoiatav info millegi kohta, mis võib häirida kasutaja tööd lehel, kuid ei takista. Näiteks suhtlus mõne teise registriga võib olla häiritud. Veateade (punane) on teade selle kohta, et midagi ei tööta ja see takistab tööd lehel. Näiteks teenus on mingi aeg maas, allkirjastamine ei tööta, sisse logida ei saa.',
353
+ }}
354
+ className={checkSelfError('tease')}
355
+ component={
356
+ <Select
357
+ name="level"
358
+ value={alert.level}
359
+ onChange={onLevelChange}
360
+ options={messageLevels}
361
+ />
362
+ }
363
+ required
334
364
  />
335
365
 
336
- <FieldWrapper label='Teate kuvamise algus'
337
- info={{content: 'Teade kuvatakse kasutajale siin märgitud kellaajast alates'}}
338
- component={
339
- <div className='alerts-ui--alert-creation-modal--content--date'>
340
- <InternalDatePicker date={alert.begin} onChange={onDateStartChange} title='start_date'
341
- checkSelfError={checkSelfError} />
342
- &nbsp;
343
- <div className='alerts-ui--alert-creation-modal--content--time'>
344
- <p>kell</p>
345
- &nbsp;
346
- <TimeInput date={alert.beginHour}
347
- checkSelfError={checkSelfError}
348
- onChange={onHourStartChange} min='0' max='23' title='start_hour' />
349
- &nbsp;
350
- <p>:</p>
351
- &nbsp;
352
- <TimeInput date={alert.beginMinute}
353
- onChange={onMinuteStartChange} min='0' max='59' title='start_minute'
354
- checkSelfError={checkSelfError} />
355
- </div>
356
- </div>
357
- }
358
- required
366
+ <FieldWrapper
367
+ label="Teate kuvamise algus"
368
+ info={{
369
+ content:
370
+ 'Teade kuvatakse kasutajale siin märgitud kellaajast alates',
371
+ }}
372
+ component={
373
+ <div className="alerts-ui--alert-creation-modal--content--date">
374
+ <InternalDatePicker
375
+ date={alert.begin}
376
+ onChange={onDateStartChange}
377
+ title="start_date"
378
+ checkSelfError={checkSelfError}
379
+ />
380
+ &nbsp;
381
+ <div className="alerts-ui--alert-creation-modal--content--time">
382
+ <p>kell</p>
383
+ &nbsp;
384
+ <TimeInput
385
+ date={alert.beginHour}
386
+ checkSelfError={checkSelfError}
387
+ onChange={onHourStartChange}
388
+ min="0"
389
+ max="23"
390
+ title="start_hour"
391
+ />
392
+ &nbsp;
393
+ <p>:</p>
394
+ &nbsp;
395
+ <TimeInput
396
+ date={alert.beginMinute}
397
+ onChange={onMinuteStartChange}
398
+ min="0"
399
+ max="59"
400
+ title="start_minute"
401
+ checkSelfError={checkSelfError}
402
+ />
403
+ </div>
404
+ </div>
405
+ }
406
+ required
359
407
  />
360
408
 
361
- <FieldWrapper label='Teate kuvamise lõpp'
362
- info={{content: 'Teate kuvamine kasutajale lõpeb siin märgitud kellaajast'}}
363
- component={
364
- <div className='alerts-ui--alert-creation-modal--content--date'>
365
- <InternalDatePicker date={alert.end} onChange={onDateEndChange} title='end_date'
366
- checkSelfError={checkSelfError} />
367
- &nbsp;
368
- <div className='alerts-ui--alert-creation-modal--content--time'>
369
- <p>kell</p>
370
- &nbsp;
371
- <TimeInput date={alert.endHour}
372
- onChange={onHourEndChange} min='0' max='23'
373
- checkSelfError={checkSelfError}
374
- title='end_hour' />
375
- &nbsp;
376
- <p>:</p>
377
- &nbsp;
378
- <TimeInput date={alert.endMinute}
379
- onChange={onMinuteEndChange} min='0' max='59' title='end_minute'
380
- checkSelfError={checkSelfError} />
381
- </div>
382
- </div>
383
- }
384
- required
409
+ <FieldWrapper
410
+ label="Teate kuvamise lõpp"
411
+ info={{
412
+ content:
413
+ 'Teate kuvamine kasutajale lõpeb siin märgitud kellaajast',
414
+ }}
415
+ component={
416
+ <div className="alerts-ui--alert-creation-modal--content--date">
417
+ <InternalDatePicker
418
+ date={alert.end}
419
+ onChange={onDateEndChange}
420
+ title="end_date"
421
+ checkSelfError={checkSelfError}
422
+ />
423
+ &nbsp;
424
+ <div className="alerts-ui--alert-creation-modal--content--time">
425
+ <p>kell</p>
426
+ &nbsp;
427
+ <TimeInput
428
+ date={alert.endHour}
429
+ onChange={onHourEndChange}
430
+ min="0"
431
+ max="23"
432
+ checkSelfError={checkSelfError}
433
+ title="end_hour"
434
+ />
435
+ &nbsp;
436
+ <p>:</p>
437
+ &nbsp;
438
+ <TimeInput
439
+ date={alert.endMinute}
440
+ onChange={onMinuteEndChange}
441
+ min="0"
442
+ max="59"
443
+ title="end_minute"
444
+ checkSelfError={checkSelfError}
445
+ />
446
+ </div>
447
+ </div>
448
+ }
449
+ required
385
450
  />
386
451
 
387
452
  {/*<Section form={true} title='EE' >*/}
388
453
 
389
- <FieldWrapper label='Teate pealkiri'
390
- className={checkSelfError('title')}
391
- component={
392
- <Input name='Title EE' value={alert.title}
393
- onChange={(c: string) => onTitleChange(ContentLanguage.EE, c)}
394
- maxLength="100"
395
- />
396
- }
397
- required
398
- />
399
-
400
- <FieldWrapper label='Teate sisu'
401
- className={checkSelfError('content')}
402
- component={
403
- <TextArea name='Content EE' value={alert.content}
404
- onChange={(c: string) => onContentChange(ContentLanguage.EE, c)}
405
- isLimitingLength={true}
406
- maxLength={500}
407
- />
408
- }
409
- required
410
- />
454
+ <FieldWrapper
455
+ label="Teate pealkiri"
456
+ className={checkSelfError('title')}
457
+ component={
458
+ <Input
459
+ name="Title EE"
460
+ value={alert.title}
461
+ onChange={(c: string) =>
462
+ onTitleChange(ContentLanguage.EE, c)
463
+ }
464
+ maxLength="100"
465
+ />
466
+ }
467
+ required
468
+ />
469
+
470
+ <FieldWrapper
471
+ label="Teate sisu"
472
+ className={checkSelfError('content')}
473
+ component={
474
+ <TextArea
475
+ name="Content EE"
476
+ value={alert.content}
477
+ onChange={(c: string) =>
478
+ onContentChange(ContentLanguage.EE, c)
479
+ }
480
+ isLimitingLength={true}
481
+ maxLength={500}
482
+ />
483
+ }
484
+ required
485
+ />
411
486
 
412
487
  {/*</Section>*/}
413
488
 
@@ -466,49 +541,73 @@ const AlertModal: React.FC<AlertModalState & AlertModalDispatch> = ({alert, clea
466
541
  {/*</Section>*/}
467
542
  </div>
468
543
 
469
- <div className='alerts-ui--alert-creation-modal--footer mt-2'>
470
- <Button colourScheme='light' onClick={onCancel}>Loobun</Button>
471
- <Button colourScheme='success' onClick={onSubmit}>Salvestan</Button>
544
+ <div className="alerts-ui--alert-creation-modal--footer mt-2">
545
+ <Button colourScheme="light" onClick={onCancel}>
546
+ Loobun
547
+ </Button>
548
+ <Button colourScheme="success" onClick={onSubmit}>
549
+ Salvestan
550
+ </Button>
472
551
  </div>
473
552
  </div>
474
553
  </div>
475
- }
554
+ )}
476
555
  </>
477
556
  );
478
- }
479
-
557
+ };
480
558
 
481
559
  interface TimeInputProps {
482
- date: number | undefined,
483
- onChange: (value: string) => void,
484
- min: string,
485
- max: string,
486
- title: string,
487
- checkSelfError: (title: string) => string,
560
+ date: number | undefined;
561
+ onChange: (value: string) => void;
562
+ min: string;
563
+ max: string;
564
+ title: string;
565
+ checkSelfError: (title: string) => string;
488
566
  }
489
567
 
490
- const TimeInput: React.FC<TimeInputProps> = ({date, onChange, max, min, title, checkSelfError}) => {
568
+ const TimeInput: React.FC<TimeInputProps> = ({
569
+ date,
570
+ onChange,
571
+ max,
572
+ min,
573
+ title,
574
+ checkSelfError,
575
+ }) => {
491
576
  return (
492
- <input className={`safari-input-rendering-bug-fix form-control ${checkSelfError(title)}`}
493
- placeholder='00'
494
- defaultValue={(date !== undefined) ? appendZero(date.toString()) : ''}
495
- onChange={(event) => onChange(event.target.value)} type='number' min={min} max={max} />
496
- )
497
- }
577
+ <input
578
+ className={`safari-input-rendering-bug-fix form-control ${checkSelfError(
579
+ title,
580
+ )}`}
581
+ placeholder="00"
582
+ defaultValue={date !== undefined ? appendZero(date.toString()) : ''}
583
+ onChange={(event) => onChange(event.target.value)}
584
+ type="number"
585
+ min={min}
586
+ max={max}
587
+ />
588
+ );
589
+ };
498
590
 
499
591
  interface InternalDatePickerProps {
500
- date: string | undefined,
501
- onChange: (value: string) => void,
502
- title: string,
503
- checkSelfError: (title: string) => string,
592
+ date: string | undefined;
593
+ onChange: (value: string) => void;
594
+ title: string;
595
+ checkSelfError: (title: string) => string;
504
596
  }
505
597
 
506
- const InternalDatePicker: React.FC<InternalDatePickerProps> = ({date, onChange, title, checkSelfError}) => {
598
+ const InternalDatePicker: React.FC<InternalDatePickerProps> = ({
599
+ date,
600
+ onChange,
601
+ title,
602
+ checkSelfError,
603
+ }) => {
507
604
  return (
508
- <DatePicker value={date}
509
- className={checkSelfError(title)}
510
- onChange={onChange} />
511
- )
512
- }
605
+ <DatePicker
606
+ value={date}
607
+ className={checkSelfError(title)}
608
+ onChange={onChange}
609
+ />
610
+ );
611
+ };
513
612
 
514
- export default AlertModal;
613
+ export default AlertModal;
@@ -1,26 +1,28 @@
1
- import React from "react";
2
- import {connect} from "react-redux";
3
- import {AlertsUiState} from "../../reducers";
4
- import AlertModal, {AlertModalDispatch, AlertModalState} from "./AlertModal";
5
- import {ThunkDispatch} from "redux-thunk";
1
+ import React from 'react';
2
+ import { connect } from 'react-redux';
3
+ import { AlertsUiState } from '../../reducers';
4
+ import AlertModal, { AlertModalDispatch, AlertModalState } from './AlertModal';
5
+ import { ThunkDispatch } from 'redux-thunk';
6
6
  import {
7
7
  addAlertModalError,
8
8
  clearAlert,
9
9
  clearAlertModalErrors,
10
10
  editAlert,
11
11
  postAlert,
12
- updateAlert
13
- } from "../../actions/AlertActions";
14
- import {Simulate} from "react-dom/test-utils";
12
+ updateAlert,
13
+ } from '../../actions/AlertActions';
14
+ import { Simulate } from 'react-dom/test-utils';
15
15
 
16
16
  function mapStateToProps(state: AlertsUiState): AlertModalState {
17
17
  return {
18
18
  alert: state.alert.alert,
19
19
  errors: state.alert.errors,
20
- }
20
+ };
21
21
  }
22
22
 
23
- function mapDispatchToProps(dispatch: ThunkDispatch<any, any, any>): AlertModalDispatch {
23
+ function mapDispatchToProps(
24
+ dispatch: ThunkDispatch<any, any, any>,
25
+ ): AlertModalDispatch {
24
26
  return {
25
27
  clearAlert: () => {
26
28
  dispatch(clearAlert());
@@ -35,12 +37,12 @@ function mapDispatchToProps(dispatch: ThunkDispatch<any, any, any>): AlertModalD
35
37
  dispatch(updateAlert());
36
38
  },
37
39
  addAlertModalError: (error) => {
38
- dispatch(addAlertModalError(error))
40
+ dispatch(addAlertModalError(error));
39
41
  },
40
42
  clearAlertModalErrors: () => {
41
43
  dispatch(clearAlertModalErrors());
42
- }
43
- }
44
+ },
45
+ };
44
46
  }
45
47
 
46
- export default connect(mapStateToProps, mapDispatchToProps)(AlertModal);
48
+ export default connect(mapStateToProps, mapDispatchToProps)(AlertModal);
@@ -1 +1 @@
1
- export {default} from './AlertModalContainer';
1
+ export { default } from './AlertModalContainer';