@aarhus-university/au-lib-react-components 10.6.0 → 10.7.0
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/.eslintrc.js +34 -34
- package/.storybook/main.js +20 -7
- package/.storybook/preview.js +10 -10
- package/README.md +19 -19
- package/__tests__/jest/AUButtonComponent.test.tsx +165 -163
- package/__tests__/jest/AUModalComponent.test.tsx +116 -0
- package/__tests__/jest/AUSpinnerComponent.test.tsx +57 -57
- package/__tests__/jest/AUToolbarComponent.test.tsx +46 -0
- package/__tests__/jest/helpers.test.ts +15 -15
- package/__tests__/jest/setupTests.ts +2 -2
- package/babel.config.js +8 -8
- package/build/umd/all.css +2 -2
- package/build/umd/all.js +1 -1
- package/build/umd/alphabox.js +1 -1
- package/build/umd/databox.js +1 -1
- package/build/umd/diagramme.js +1 -1
- package/build/umd/flowbox.js +1 -1
- package/build/umd/universe.js +1 -1
- package/package.json +107 -107
- package/src/components/AUAlertComponent.tsx +70 -70
- package/src/components/AUAutoSuggestComponent.js +158 -158
- package/src/components/AUButtonComponent.tsx +83 -77
- package/src/components/AUCalendarComponent.tsx +493 -493
- package/src/components/AUContentToggleComponent.tsx +33 -33
- package/src/components/AUDatepickerComponent.tsx +117 -117
- package/src/components/AUMobilePrefixComponent.tsx +15 -15
- package/src/components/AUModalComponent.tsx +64 -80
- package/src/components/AUReceiptComponent.tsx +33 -33
- package/src/components/AUSpinnerComponent.tsx +33 -33
- package/src/components/AUSubNavComponent.tsx +48 -48
- package/src/components/AUSubmitButtonContainerComponent.tsx +31 -31
- package/src/components/AUTabbedContentComponent.tsx +145 -145
- package/src/components/AUTableComponent.tsx +24 -24
- package/src/components/AUToastComponent.tsx +103 -103
- package/src/components/AUToolbarComponent.tsx +52 -45
- package/src/components/profile/AUProfileActions.js +128 -128
- package/src/components/profile/AUProfileAvatarComponent.js +83 -83
- package/src/components/profile/AUProfileAvatarV2Component.js +91 -91
- package/src/components/profile/AUProfileAvatarV3Component.tsx +42 -42
- package/src/components/profile/AUProfileContainerComponent.js +283 -283
- package/src/components/profile/AUProfileHooks.js +30 -30
- package/src/components/profile/AUProfileItemComponent.js +54 -54
- package/src/components/profile/AUProfileLanguageComponent.js +131 -131
- package/src/components/profile/AUProfileLoginComponent.tsx +26 -26
- package/src/components/profile/AUProfileMailComponent.js +307 -307
- package/src/components/profile/AUProfileMobileComponent.js +164 -164
- package/src/components/profile/AUProfileNameComponent.js +253 -253
- package/src/components/profile/AUProfileNextOfKinComponent.js +216 -216
- package/src/components/profile/AUProfileReducer.js +230 -230
- package/src/components/profile/AUProfileWidgetComponent.js +95 -95
- package/src/components/profile/AUProfileWidgetV2Component.js +116 -116
- package/src/components/profile/AUProfileWidgetV3Component.tsx +122 -122
- package/src/components/wrapping/AUEmbedComponent.js +47 -47
- package/src/layout-2016/components/alphabox/AlphaBoxComponent.js +143 -143
- package/src/layout-2016/components/alphabox/AlphaBoxContentComponent.js +136 -136
- package/src/layout-2016/components/common/AUCollapsibleComponent.js +152 -152
- package/src/layout-2016/components/common/AUSpinnerComponent.js +103 -103
- package/src/layout-2016/components/databox/DataBoxAlphabetComponent.js +144 -144
- package/src/layout-2016/components/databox/DataBoxAssociationComponent.js +122 -122
- package/src/layout-2016/components/databox/DataBoxButtonComponent.js +157 -157
- package/src/layout-2016/components/databox/DataBoxComponent.js +297 -297
- package/src/layout-2016/components/databox/DataBoxGroupingComponent.js +64 -64
- package/src/layout-2016/components/databox/DataBoxSearchResultComponent.js +36 -36
- package/src/layout-2016/components/databox/DataBoxStackedAssociationComponent.js +54 -54
- package/src/layout-2016/components/databox/DataBoxSuggestionComponent.js +39 -39
- package/src/layout-2016/components/diagramme/AUDiagrammeComponent.js +309 -309
- package/src/layout-2016/components/flowbox/FlowBoxComponent.js +126 -126
- package/src/layout-2016/components/flowbox/FlowBoxPhoneComponent.js +104 -104
- package/src/layout-2016/components/profile/AUProfileAvatar2016Component.js +103 -103
- package/src/layout-2016/components/universe/StaffTopComponent.js +363 -363
- package/src/layout-2016/components/universe/StudentTopComponent.js +137 -137
- package/src/layout-2016/components/universe/UniverseContainerComponent.js +65 -65
- package/src/layout-2016/lib/all.js +3 -3
- package/src/layout-2016/lib/au-alphabox.js +100 -100
- package/src/layout-2016/lib/au-databox.js +400 -400
- package/src/layout-2016/lib/au-diagramme.js +85 -85
- package/src/layout-2016/lib/au-flowbox.js +93 -93
- package/src/layout-2016/lib/universe.js +9 -9
- package/src/lib/helpers.ts +194 -194
- package/src/lib/hooks.ts +37 -33
- package/src/lib/i18n.ts +600 -600
- package/src/lib/tracking.ts +69 -69
- package/src/lib/wrapping.ts +21 -21
- package/src/styles/_settings.scss +10 -10
- package/src/styles/alphabox.scss +222 -222
- package/src/styles/app.scss +7 -7
- package/src/styles/autosuggest.scss +57 -57
- package/src/styles/databox.scss +563 -563
- package/src/styles/diagramme.scss +119 -119
- package/src/styles/flowbox.scss +72 -72
- package/src/styles/maps.scss +395 -395
- package/stories/AUButtonComponent.stories.tsx +85 -85
- package/stories/AUModalComponent.stories.tsx +92 -0
- package/stories/AUSpinnerComponent.stories.tsx +41 -41
- package/stories/AUToolbarComponent.stories.tsx +96 -0
- package/tsconfig.json +46 -46
- package/webpack.config.js +89 -89
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
import React, {
|
|
3
|
-
useEffect, useLayoutEffect, useRef, FC,
|
|
4
|
-
} from 'react';
|
|
5
|
-
|
|
6
|
-
const dismissTimeout = 5000;
|
|
7
|
-
let timeoutId: NodeJS.Timeout | null = null;
|
|
8
|
-
|
|
9
|
-
const AUToastComponent: FC<AUToastComponentProps> = ({
|
|
10
|
-
message: pMessage,
|
|
11
|
-
buttonText,
|
|
12
|
-
dismiss,
|
|
13
|
-
onOpen,
|
|
14
|
-
}: AUToastComponentProps) => {
|
|
15
|
-
const { type, message, header } = pMessage;
|
|
16
|
-
const toastRef = useRef<HTMLDivElement>(null);
|
|
17
|
-
const persistent = type !== 'confirm';
|
|
18
|
-
|
|
19
|
-
const moveOut = (element: HTMLElement): void => {
|
|
20
|
-
const moveOutClass = 'toast-notification--move-out';
|
|
21
|
-
element.classList.add(moveOutClass);
|
|
22
|
-
const moveOutElement = document.querySelector(`.${moveOutClass}`);
|
|
23
|
-
if (moveOutElement && typeof dismiss === 'function') {
|
|
24
|
-
moveOutElement.addEventListener('animationend', () => {
|
|
25
|
-
dismiss();
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (typeof onOpen === 'function') {
|
|
32
|
-
onOpen();
|
|
33
|
-
}
|
|
34
|
-
}, []);
|
|
35
|
-
|
|
36
|
-
useLayoutEffect(() => {
|
|
37
|
-
const element = toastRef.current;
|
|
38
|
-
if (!persistent) {
|
|
39
|
-
if (element) {
|
|
40
|
-
element.addEventListener('animationend', () => {
|
|
41
|
-
timeoutId = setTimeout(() => {
|
|
42
|
-
moveOut(element);
|
|
43
|
-
}, dismissTimeout);
|
|
44
|
-
});
|
|
45
|
-
element.addEventListener('mouseenter', () => {
|
|
46
|
-
if (timeoutId) {
|
|
47
|
-
clearTimeout(timeoutId);
|
|
48
|
-
element.addEventListener('mouseleave', () => {
|
|
49
|
-
moveOut(element);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
element?.querySelector('button')?.focus();
|
|
56
|
-
}
|
|
57
|
-
}, []);
|
|
58
|
-
|
|
59
|
-
let className = `toast-notification toast-notification--${type}`;
|
|
60
|
-
if (persistent) {
|
|
61
|
-
className = `${className} toast-notification--persistent`;
|
|
62
|
-
}
|
|
63
|
-
return (
|
|
64
|
-
<div ref={toastRef} className={className}>
|
|
65
|
-
<div className="toast-notification__content">
|
|
66
|
-
{
|
|
67
|
-
header && (
|
|
68
|
-
<h2 className="toast-notification__header">
|
|
69
|
-
{header}
|
|
70
|
-
</h2>
|
|
71
|
-
)
|
|
72
|
-
}
|
|
73
|
-
<p dangerouslySetInnerHTML={{ __html: message }} />
|
|
74
|
-
</div>
|
|
75
|
-
{
|
|
76
|
-
persistent && (
|
|
77
|
-
<button
|
|
78
|
-
type="button"
|
|
79
|
-
className="button"
|
|
80
|
-
onClick={() => {
|
|
81
|
-
if (toastRef.current) {
|
|
82
|
-
moveOut(toastRef.current);
|
|
83
|
-
}
|
|
84
|
-
}}
|
|
85
|
-
>
|
|
86
|
-
{buttonText}
|
|
87
|
-
</button>
|
|
88
|
-
)
|
|
89
|
-
}
|
|
90
|
-
</div>
|
|
91
|
-
);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
AUToastComponent.defaultProps = {
|
|
95
|
-
buttonText: 'OK',
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
97
|
-
dismiss: () => { },
|
|
98
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
99
|
-
onOpen: () => { },
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
AUToastComponent.displayName = 'AUToastComponent';
|
|
103
|
-
export default AUToastComponent;
|
|
1
|
+
/* eslint-env browser */
|
|
2
|
+
import React, {
|
|
3
|
+
useEffect, useLayoutEffect, useRef, FC,
|
|
4
|
+
} from 'react';
|
|
5
|
+
|
|
6
|
+
const dismissTimeout = 5000;
|
|
7
|
+
let timeoutId: NodeJS.Timeout | null = null;
|
|
8
|
+
|
|
9
|
+
const AUToastComponent: FC<AUToastComponentProps> = ({
|
|
10
|
+
message: pMessage,
|
|
11
|
+
buttonText,
|
|
12
|
+
dismiss,
|
|
13
|
+
onOpen,
|
|
14
|
+
}: AUToastComponentProps) => {
|
|
15
|
+
const { type, message, header } = pMessage;
|
|
16
|
+
const toastRef = useRef<HTMLDivElement>(null);
|
|
17
|
+
const persistent = type !== 'confirm';
|
|
18
|
+
|
|
19
|
+
const moveOut = (element: HTMLElement): void => {
|
|
20
|
+
const moveOutClass = 'toast-notification--move-out';
|
|
21
|
+
element.classList.add(moveOutClass);
|
|
22
|
+
const moveOutElement = document.querySelector(`.${moveOutClass}`);
|
|
23
|
+
if (moveOutElement && typeof dismiss === 'function') {
|
|
24
|
+
moveOutElement.addEventListener('animationend', () => {
|
|
25
|
+
dismiss();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (typeof onOpen === 'function') {
|
|
32
|
+
onOpen();
|
|
33
|
+
}
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
36
|
+
useLayoutEffect(() => {
|
|
37
|
+
const element = toastRef.current;
|
|
38
|
+
if (!persistent) {
|
|
39
|
+
if (element) {
|
|
40
|
+
element.addEventListener('animationend', () => {
|
|
41
|
+
timeoutId = setTimeout(() => {
|
|
42
|
+
moveOut(element);
|
|
43
|
+
}, dismissTimeout);
|
|
44
|
+
});
|
|
45
|
+
element.addEventListener('mouseenter', () => {
|
|
46
|
+
if (timeoutId) {
|
|
47
|
+
clearTimeout(timeoutId);
|
|
48
|
+
element.addEventListener('mouseleave', () => {
|
|
49
|
+
moveOut(element);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
element?.querySelector('button')?.focus();
|
|
56
|
+
}
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
let className = `toast-notification toast-notification--${type}`;
|
|
60
|
+
if (persistent) {
|
|
61
|
+
className = `${className} toast-notification--persistent`;
|
|
62
|
+
}
|
|
63
|
+
return (
|
|
64
|
+
<div ref={toastRef} className={className}>
|
|
65
|
+
<div className="toast-notification__content">
|
|
66
|
+
{
|
|
67
|
+
header && (
|
|
68
|
+
<h2 className="toast-notification__header">
|
|
69
|
+
{header}
|
|
70
|
+
</h2>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
<p dangerouslySetInnerHTML={{ __html: message }} />
|
|
74
|
+
</div>
|
|
75
|
+
{
|
|
76
|
+
persistent && (
|
|
77
|
+
<button
|
|
78
|
+
type="button"
|
|
79
|
+
className="button"
|
|
80
|
+
onClick={() => {
|
|
81
|
+
if (toastRef.current) {
|
|
82
|
+
moveOut(toastRef.current);
|
|
83
|
+
}
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
{buttonText}
|
|
87
|
+
</button>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
AUToastComponent.defaultProps = {
|
|
95
|
+
buttonText: 'OK',
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
97
|
+
dismiss: () => { },
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
99
|
+
onOpen: () => { },
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
AUToastComponent.displayName = 'AUToastComponent';
|
|
103
|
+
export default AUToastComponent;
|
|
@@ -1,45 +1,52 @@
|
|
|
1
|
-
/* eslint-disable react/no-array-index-key */
|
|
2
|
-
/* eslint-env browser */
|
|
3
|
-
import React, { useEffect, FC } from 'react';
|
|
4
|
-
import { setToolbars, setToolbarToggle } from '@aarhus-university/au-designsystem-delphinus/source/js/components/toolbar';
|
|
5
|
-
|
|
6
|
-
let windowInnerWidth = 0;
|
|
7
|
-
|
|
8
|
-
const AUToolbarComponent: FC<AUToolbarComponentProps> = ({
|
|
9
|
-
lang,
|
|
10
|
-
elements,
|
|
11
|
-
}: AUToolbarComponentProps) => {
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
setToolbars();
|
|
14
|
-
setToolbarToggle();
|
|
15
|
-
windowInnerWidth = window.innerWidth;
|
|
16
|
-
window.addEventListener('resize', () => {
|
|
17
|
-
if (windowInnerWidth > 0 && window.innerWidth !== windowInnerWidth) {
|
|
18
|
-
windowInnerWidth = window.innerWidth;
|
|
19
|
-
setToolbars();
|
|
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
|
-
|
|
1
|
+
/* eslint-disable react/no-array-index-key */
|
|
2
|
+
/* eslint-env browser */
|
|
3
|
+
import React, { useEffect, FC } from 'react';
|
|
4
|
+
import { setToolbars, setToolbarToggle } from '@aarhus-university/au-designsystem-delphinus/source/js/components/toolbar';
|
|
5
|
+
|
|
6
|
+
let windowInnerWidth = 0;
|
|
7
|
+
|
|
8
|
+
const AUToolbarComponent: FC<AUToolbarComponentProps> = ({
|
|
9
|
+
lang,
|
|
10
|
+
elements,
|
|
11
|
+
}: AUToolbarComponentProps) => {
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
setToolbars();
|
|
14
|
+
const cleanUp: CleanUpPair[] = setToolbarToggle();
|
|
15
|
+
windowInnerWidth = window.innerWidth;
|
|
16
|
+
window.addEventListener('resize', () => {
|
|
17
|
+
if (windowInnerWidth > 0 && window.innerWidth !== windowInnerWidth) {
|
|
18
|
+
windowInnerWidth = window.innerWidth;
|
|
19
|
+
setToolbars();
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Runs on unmounting
|
|
24
|
+
return () => {
|
|
25
|
+
cleanUp.forEach((pair: CleanUpPair) => {
|
|
26
|
+
pair.element.removeEventListener('click', pair.clickEvent);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
|
|
31
|
+
const renderElements = elements.map((e, i) => <React.Fragment key={i}>{e}</React.Fragment>);
|
|
32
|
+
const label = lang === 'da' ? 'Muligheder' : 'Options';
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className="toolbar">
|
|
36
|
+
<div className="toolbar__items">
|
|
37
|
+
{renderElements}
|
|
38
|
+
</div>
|
|
39
|
+
<button
|
|
40
|
+
type="button"
|
|
41
|
+
className="toolbar__toggle"
|
|
42
|
+
title={label}
|
|
43
|
+
aria-haspopup="true"
|
|
44
|
+
>
|
|
45
|
+
{label}
|
|
46
|
+
</button>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
AUToolbarComponent.displayName = 'AUToolbarComponent';
|
|
52
|
+
export default AUToolbarComponent;
|
|
@@ -1,128 +1,128 @@
|
|
|
1
|
-
/* eslint-disable import/prefer-default-export */
|
|
2
|
-
export const GET_BASIC_USER = 'GET_BASIC_USER';
|
|
3
|
-
export const SAVING_USER = 'SAVING_USER';
|
|
4
|
-
export const PATCH_NAME = 'PATCH_NAME';
|
|
5
|
-
export const PATCH_MAIL = 'PATCH_MAIL';
|
|
6
|
-
export const PATCH_MOBILE = 'PATCH_MOBILE';
|
|
7
|
-
export const PATCH_LANGUAGE = 'PATCH_LANGUAGE';
|
|
8
|
-
export const PATCH_NEXTOFKIN = 'PATCH_NEXTOFKIN';
|
|
9
|
-
export const DISMISS_MESSAGES = 'DISMISS_MESSAGES';
|
|
10
|
-
export const SET_SAVED = 'SET_SAVED';
|
|
11
|
-
export const GET_WORKMAIL_DOMAIN = 'GET_WORKMAIL_DOMAIN';
|
|
12
|
-
|
|
13
|
-
export const getActionCreators = () => {
|
|
14
|
-
const actionCreators = {
|
|
15
|
-
getBasicUser: (callback) => async (dispatch) => { // Tror simpelthen ikke det her er i brug...
|
|
16
|
-
callback((ok, status, json) => {
|
|
17
|
-
const result = {};
|
|
18
|
-
result[ok ? 'user' : 'error'] = json;
|
|
19
|
-
result.status = status;
|
|
20
|
-
dispatch({
|
|
21
|
-
type: GET_BASIC_USER,
|
|
22
|
-
result,
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
},
|
|
26
|
-
getWorkMailDomain: () => async (dispatch) => {
|
|
27
|
-
const url = '/v1/person/getworkmaildomain';
|
|
28
|
-
const response = await fetch(url);
|
|
29
|
-
const json = await response.json();
|
|
30
|
-
const result = {};
|
|
31
|
-
result[response.ok ? 'user' : 'error'] = response.ok ? {
|
|
32
|
-
workMailDomain: json
|
|
33
|
-
} : json;
|
|
34
|
-
result.status = response.status;
|
|
35
|
-
dispatch({
|
|
36
|
-
type: GET_WORKMAIL_DOMAIN,
|
|
37
|
-
result,
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
clear: () => (dispatch) => {
|
|
41
|
-
dispatch({
|
|
42
|
-
type: SET_SAVED,
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
dismissMessages: () => (dispatch) => {
|
|
46
|
-
dispatch({
|
|
47
|
-
type: DISMISS_MESSAGES,
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
patchName: (data, callback) => async (dispatch) => {
|
|
51
|
-
dispatch({
|
|
52
|
-
type: SAVING_USER,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
callback(data, (ok, status, json) => {
|
|
56
|
-
const result = {};
|
|
57
|
-
result[ok ? 'user' : 'error'] = json;
|
|
58
|
-
result.status = status;
|
|
59
|
-
dispatch({
|
|
60
|
-
type: PATCH_NAME,
|
|
61
|
-
result,
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
patchMail: (data, callback) => async (dispatch) => {
|
|
66
|
-
dispatch({
|
|
67
|
-
type: SAVING_USER,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
callback(data, (ok, status, json) => {
|
|
71
|
-
const result = {};
|
|
72
|
-
result[ok ? 'user' : 'error'] = json;
|
|
73
|
-
result.status = status;
|
|
74
|
-
dispatch({
|
|
75
|
-
type: PATCH_MAIL,
|
|
76
|
-
result,
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
patchMobile: (data, callback) => async (dispatch) => {
|
|
81
|
-
dispatch({
|
|
82
|
-
type: SAVING_USER,
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
callback(data, (ok, status, json) => {
|
|
86
|
-
const result = {};
|
|
87
|
-
result[ok ? 'user' : 'error'] = json;
|
|
88
|
-
result.status = status;
|
|
89
|
-
dispatch({
|
|
90
|
-
type: PATCH_MOBILE,
|
|
91
|
-
result,
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
},
|
|
95
|
-
patchLanguage: (data, callback) => async (dispatch) => {
|
|
96
|
-
dispatch({
|
|
97
|
-
type: SAVING_USER,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
callback(data, (ok, status, json) => {
|
|
101
|
-
const result = {};
|
|
102
|
-
result[ok ? 'user' : 'error'] = json;
|
|
103
|
-
result.status = status;
|
|
104
|
-
dispatch({
|
|
105
|
-
type: PATCH_LANGUAGE,
|
|
106
|
-
result,
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
patchNextOfKin: (data, callback) => async (dispatch) => {
|
|
111
|
-
dispatch({
|
|
112
|
-
type: SAVING_USER,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
callback(data, (ok, status, json) => {
|
|
116
|
-
const result = {};
|
|
117
|
-
result[ok ? 'user' : 'error'] = json;
|
|
118
|
-
result.status = status;
|
|
119
|
-
dispatch({
|
|
120
|
-
type: PATCH_NEXTOFKIN,
|
|
121
|
-
result,
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
},
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
return actionCreators;
|
|
128
|
-
};
|
|
1
|
+
/* eslint-disable import/prefer-default-export */
|
|
2
|
+
export const GET_BASIC_USER = 'GET_BASIC_USER';
|
|
3
|
+
export const SAVING_USER = 'SAVING_USER';
|
|
4
|
+
export const PATCH_NAME = 'PATCH_NAME';
|
|
5
|
+
export const PATCH_MAIL = 'PATCH_MAIL';
|
|
6
|
+
export const PATCH_MOBILE = 'PATCH_MOBILE';
|
|
7
|
+
export const PATCH_LANGUAGE = 'PATCH_LANGUAGE';
|
|
8
|
+
export const PATCH_NEXTOFKIN = 'PATCH_NEXTOFKIN';
|
|
9
|
+
export const DISMISS_MESSAGES = 'DISMISS_MESSAGES';
|
|
10
|
+
export const SET_SAVED = 'SET_SAVED';
|
|
11
|
+
export const GET_WORKMAIL_DOMAIN = 'GET_WORKMAIL_DOMAIN';
|
|
12
|
+
|
|
13
|
+
export const getActionCreators = () => {
|
|
14
|
+
const actionCreators = {
|
|
15
|
+
getBasicUser: (callback) => async (dispatch) => { // Tror simpelthen ikke det her er i brug...
|
|
16
|
+
callback((ok, status, json) => {
|
|
17
|
+
const result = {};
|
|
18
|
+
result[ok ? 'user' : 'error'] = json;
|
|
19
|
+
result.status = status;
|
|
20
|
+
dispatch({
|
|
21
|
+
type: GET_BASIC_USER,
|
|
22
|
+
result,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
getWorkMailDomain: () => async (dispatch) => {
|
|
27
|
+
const url = '/v1/person/getworkmaildomain';
|
|
28
|
+
const response = await fetch(url);
|
|
29
|
+
const json = await response.json();
|
|
30
|
+
const result = {};
|
|
31
|
+
result[response.ok ? 'user' : 'error'] = response.ok ? {
|
|
32
|
+
workMailDomain: json
|
|
33
|
+
} : json;
|
|
34
|
+
result.status = response.status;
|
|
35
|
+
dispatch({
|
|
36
|
+
type: GET_WORKMAIL_DOMAIN,
|
|
37
|
+
result,
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
clear: () => (dispatch) => {
|
|
41
|
+
dispatch({
|
|
42
|
+
type: SET_SAVED,
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
dismissMessages: () => (dispatch) => {
|
|
46
|
+
dispatch({
|
|
47
|
+
type: DISMISS_MESSAGES,
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
patchName: (data, callback) => async (dispatch) => {
|
|
51
|
+
dispatch({
|
|
52
|
+
type: SAVING_USER,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
callback(data, (ok, status, json) => {
|
|
56
|
+
const result = {};
|
|
57
|
+
result[ok ? 'user' : 'error'] = json;
|
|
58
|
+
result.status = status;
|
|
59
|
+
dispatch({
|
|
60
|
+
type: PATCH_NAME,
|
|
61
|
+
result,
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
patchMail: (data, callback) => async (dispatch) => {
|
|
66
|
+
dispatch({
|
|
67
|
+
type: SAVING_USER,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
callback(data, (ok, status, json) => {
|
|
71
|
+
const result = {};
|
|
72
|
+
result[ok ? 'user' : 'error'] = json;
|
|
73
|
+
result.status = status;
|
|
74
|
+
dispatch({
|
|
75
|
+
type: PATCH_MAIL,
|
|
76
|
+
result,
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
patchMobile: (data, callback) => async (dispatch) => {
|
|
81
|
+
dispatch({
|
|
82
|
+
type: SAVING_USER,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
callback(data, (ok, status, json) => {
|
|
86
|
+
const result = {};
|
|
87
|
+
result[ok ? 'user' : 'error'] = json;
|
|
88
|
+
result.status = status;
|
|
89
|
+
dispatch({
|
|
90
|
+
type: PATCH_MOBILE,
|
|
91
|
+
result,
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
patchLanguage: (data, callback) => async (dispatch) => {
|
|
96
|
+
dispatch({
|
|
97
|
+
type: SAVING_USER,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
callback(data, (ok, status, json) => {
|
|
101
|
+
const result = {};
|
|
102
|
+
result[ok ? 'user' : 'error'] = json;
|
|
103
|
+
result.status = status;
|
|
104
|
+
dispatch({
|
|
105
|
+
type: PATCH_LANGUAGE,
|
|
106
|
+
result,
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
patchNextOfKin: (data, callback) => async (dispatch) => {
|
|
111
|
+
dispatch({
|
|
112
|
+
type: SAVING_USER,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
callback(data, (ok, status, json) => {
|
|
116
|
+
const result = {};
|
|
117
|
+
result[ok ? 'user' : 'error'] = json;
|
|
118
|
+
result.status = status;
|
|
119
|
+
dispatch({
|
|
120
|
+
type: PATCH_NEXTOFKIN,
|
|
121
|
+
result,
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
return actionCreators;
|
|
128
|
+
};
|