@aarhus-university/au-lib-react-components 10.19.0 → 10.19.1
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/package.json +3 -3
- package/src/components/AUButtonComponent.tsx +3 -1
- package/src/components/AUSubmitButtonContainerComponent.tsx +12 -14
- package/src/components/AUToastComponent.tsx +8 -7
- package/src/lib/helpers.ts +1 -1
- package/src/components/profile/AUProfileActions.js +0 -128
- package/src/components/profile/AUProfileAvatarComponent.js +0 -83
- package/src/components/profile/AUProfileAvatarV2Component.js +0 -91
- package/src/components/profile/AUProfileAvatarV3Component.tsx +0 -42
- package/src/components/profile/AUProfileContainerComponent.js +0 -283
- package/src/components/profile/AUProfileHooks.js +0 -30
- package/src/components/profile/AUProfileItemComponent.js +0 -54
- package/src/components/profile/AUProfileLanguageComponent.js +0 -131
- package/src/components/profile/AUProfileLoginComponent.tsx +0 -26
- package/src/components/profile/AUProfileMailComponent.js +0 -307
- package/src/components/profile/AUProfileMobileComponent.js +0 -164
- package/src/components/profile/AUProfileNameComponent.js +0 -253
- package/src/components/profile/AUProfileNextOfKinComponent.js +0 -216
- package/src/components/profile/AUProfileReducer.js +0 -230
- package/src/components/profile/AUProfileWidgetComponent.js +0 -95
- package/src/components/profile/AUProfileWidgetV2Component.js +0 -116
- package/src/components/profile/AUProfileWidgetV3Component.tsx +0 -122
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
import React, { useEffect } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { BrowserRouter as Router, Route, Link } from 'react-router-dom';
|
|
5
|
-
import AUModalComponent from '../delphinus/AUModalComponent';
|
|
6
|
-
import AUProfileItemComponent from './AUProfileItemComponent';
|
|
7
|
-
import AUProfileNameComponent from './AUProfileNameComponent';
|
|
8
|
-
import AUProfileMailComponent from './AUProfileMailComponent';
|
|
9
|
-
import AUProfileMobileComponent from './AUProfileMobileComponent';
|
|
10
|
-
import AUProfileLanguageComponent from './AUProfileLanguageComponent';
|
|
11
|
-
import AUProfileNextOfKinComponent from './AUProfileNextOfKinComponent';
|
|
12
|
-
import AUSpinnerComponent from '../delphinus/AUSpinnerComponent';
|
|
13
|
-
import { prettyPrintPhone, scrollTo } from '../../lib/helpers';
|
|
14
|
-
import { profileLabels, countryCodes } from '../../lib/i18n';
|
|
15
|
-
|
|
16
|
-
const getLinkElement = (path, language) => <Link className="settings-list__item__action button button--small" to={path}>{profileLabels[language].edit}</Link>;
|
|
17
|
-
const langPath = '/(da|en)';
|
|
18
|
-
|
|
19
|
-
const AUProfileContainerComponent = ({
|
|
20
|
-
user: {
|
|
21
|
-
firstNames,
|
|
22
|
-
lastName,
|
|
23
|
-
hasChosenName,
|
|
24
|
-
chosenFirstNames,
|
|
25
|
-
chosenLastName,
|
|
26
|
-
preferredLanguage,
|
|
27
|
-
privateMobileNumber,
|
|
28
|
-
privateMailAddress,
|
|
29
|
-
nextOfKinName,
|
|
30
|
-
nextOfKinPhoneNumber,
|
|
31
|
-
isStudentAdGroupMember,
|
|
32
|
-
studentMailAddress,
|
|
33
|
-
studentChosenMailAddress,
|
|
34
|
-
workMailAddress,
|
|
35
|
-
workMailDomain,
|
|
36
|
-
saving,
|
|
37
|
-
saved,
|
|
38
|
-
loaded,
|
|
39
|
-
},
|
|
40
|
-
path,
|
|
41
|
-
onSaveName,
|
|
42
|
-
onSaveMail,
|
|
43
|
-
onSaveMobile,
|
|
44
|
-
onSaveLanguage,
|
|
45
|
-
onSaveNextOfKin,
|
|
46
|
-
dismissMessages,
|
|
47
|
-
clear,
|
|
48
|
-
onUserLoaded,
|
|
49
|
-
}) => {
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
scrollTo();
|
|
52
|
-
}, []);
|
|
53
|
-
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (loaded) {
|
|
56
|
-
onUserLoaded();
|
|
57
|
-
}
|
|
58
|
-
}, [loaded]);
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<Router key="router">
|
|
62
|
-
<div className="page__content__block">
|
|
63
|
-
<Route
|
|
64
|
-
path={`${langPath}${path}`}
|
|
65
|
-
exact
|
|
66
|
-
render={() => [
|
|
67
|
-
<div key="navigator" className="list-navigator list-navigator--top-level">
|
|
68
|
-
<h1 className="list-navigator__header">{profileLabels[preferredLanguage].headerContainer}</h1>
|
|
69
|
-
</div>,
|
|
70
|
-
<AUModalComponent
|
|
71
|
-
key="modal"
|
|
72
|
-
lang={preferredLanguage}
|
|
73
|
-
>
|
|
74
|
-
<div className="modal-view__body">
|
|
75
|
-
<h2 className="modal-view__header">
|
|
76
|
-
Indholdet af en modal
|
|
77
|
-
</h2>
|
|
78
|
-
<div className="modal-view__content">
|
|
79
|
-
Indhold
|
|
80
|
-
</div>
|
|
81
|
-
</div>
|
|
82
|
-
</AUModalComponent>,
|
|
83
|
-
<ul key="links" className="settings-list links--plain">
|
|
84
|
-
<AUProfileItemComponent
|
|
85
|
-
lang={preferredLanguage}
|
|
86
|
-
header={profileLabels[preferredLanguage].headerName}
|
|
87
|
-
values={hasChosenName ? [`${chosenFirstNames} ${chosenLastName}`] : [`${firstNames} ${lastName}`]}
|
|
88
|
-
linkElement={getLinkElement(`/${preferredLanguage}${path}/name`, preferredLanguage, profileLabels)}
|
|
89
|
-
/>
|
|
90
|
-
<AUProfileItemComponent
|
|
91
|
-
lang={preferredLanguage}
|
|
92
|
-
header={profileLabels[preferredLanguage].headerMail}
|
|
93
|
-
values={[
|
|
94
|
-
workMailAddress && !workMailAddress.includes('@uni.au.dk') ? workMailAddress : '',
|
|
95
|
-
studentChosenMailAddress || studentMailAddress,
|
|
96
|
-
privateMailAddress,
|
|
97
|
-
]}
|
|
98
|
-
empty={!privateMailAddress ? [profileLabels[preferredLanguage].emptyMail] : []}
|
|
99
|
-
linkElement={getLinkElement(`/${preferredLanguage}${path}/mail`, preferredLanguage, profileLabels)}
|
|
100
|
-
/>
|
|
101
|
-
<AUProfileItemComponent
|
|
102
|
-
lang={preferredLanguage}
|
|
103
|
-
header={profileLabels[preferredLanguage].headerMobile}
|
|
104
|
-
values={[prettyPrintPhone(countryCodes, privateMobileNumber)]}
|
|
105
|
-
empty={!privateMobileNumber ? [profileLabels[preferredLanguage].emptyMobile] : []}
|
|
106
|
-
linkElement={getLinkElement(`/${preferredLanguage}${path}/mobile`, preferredLanguage, profileLabels)}
|
|
107
|
-
/>
|
|
108
|
-
<AUProfileItemComponent
|
|
109
|
-
lang={preferredLanguage}
|
|
110
|
-
header={profileLabels[preferredLanguage].headerLanguage}
|
|
111
|
-
values={[`${profileLabels[preferredLanguage].languageIn}`]}
|
|
112
|
-
linkElement={getLinkElement(`/${preferredLanguage}${path}/language`, preferredLanguage, profileLabels)}
|
|
113
|
-
/>
|
|
114
|
-
<AUProfileItemComponent
|
|
115
|
-
lang={preferredLanguage}
|
|
116
|
-
header={profileLabels[preferredLanguage].headerNextOfKin}
|
|
117
|
-
values={[nextOfKinName, prettyPrintPhone(countryCodes, nextOfKinPhoneNumber)]}
|
|
118
|
-
empty={!nextOfKinPhoneNumber ? [profileLabels[preferredLanguage].emptyNok] : []}
|
|
119
|
-
linkElement={getLinkElement(`/${preferredLanguage}${path}/nextofkin`, preferredLanguage, profileLabels)}
|
|
120
|
-
/>
|
|
121
|
-
</ul>,
|
|
122
|
-
]}
|
|
123
|
-
/>
|
|
124
|
-
<Route
|
|
125
|
-
path={`${langPath}${path}/name`}
|
|
126
|
-
render={(routeProps) => (
|
|
127
|
-
<AUSpinnerComponent
|
|
128
|
-
loaded={loaded}
|
|
129
|
-
loadingCondition={!loaded}
|
|
130
|
-
>
|
|
131
|
-
<AUProfileNameComponent
|
|
132
|
-
lang={preferredLanguage}
|
|
133
|
-
path={`/${preferredLanguage}${path}`}
|
|
134
|
-
routeProps={routeProps}
|
|
135
|
-
firstNames={firstNames}
|
|
136
|
-
lastName={lastName}
|
|
137
|
-
chosenFirstNames={chosenFirstNames}
|
|
138
|
-
chosenLastName={chosenLastName}
|
|
139
|
-
hasChosenName={hasChosenName}
|
|
140
|
-
onSave={onSaveName}
|
|
141
|
-
saving={saving}
|
|
142
|
-
saved={saved}
|
|
143
|
-
dismissMessages={dismissMessages}
|
|
144
|
-
clear={clear}
|
|
145
|
-
/>
|
|
146
|
-
</AUSpinnerComponent>
|
|
147
|
-
)}
|
|
148
|
-
/>
|
|
149
|
-
<Route
|
|
150
|
-
path={`${langPath}${path}/mail`}
|
|
151
|
-
render={(routeProps) => (
|
|
152
|
-
<AUSpinnerComponent
|
|
153
|
-
loaded={loaded}
|
|
154
|
-
loadingCondition={!loaded}
|
|
155
|
-
>
|
|
156
|
-
<AUProfileMailComponent
|
|
157
|
-
lang={preferredLanguage}
|
|
158
|
-
path={`/${preferredLanguage}${path}`}
|
|
159
|
-
routeProps={routeProps}
|
|
160
|
-
isStudentAdGroupMember={isStudentAdGroupMember}
|
|
161
|
-
studentMailAddress={studentMailAddress}
|
|
162
|
-
studentChosenMailAddress={studentChosenMailAddress || studentMailAddress || ''}
|
|
163
|
-
workMailAddress={workMailAddress}
|
|
164
|
-
workMailDomain={workMailDomain}
|
|
165
|
-
privateMailAddress={privateMailAddress || ''}
|
|
166
|
-
onSave={onSaveMail}
|
|
167
|
-
saving={saving}
|
|
168
|
-
saved={saved}
|
|
169
|
-
dismissMessages={dismissMessages}
|
|
170
|
-
clear={clear}
|
|
171
|
-
/>
|
|
172
|
-
</AUSpinnerComponent>
|
|
173
|
-
)}
|
|
174
|
-
/>
|
|
175
|
-
<Route
|
|
176
|
-
path={`${langPath}${path}/mobile`}
|
|
177
|
-
render={(routeProps) => (
|
|
178
|
-
<AUSpinnerComponent
|
|
179
|
-
loaded={loaded}
|
|
180
|
-
loadingCondition={!loaded}
|
|
181
|
-
>
|
|
182
|
-
<AUProfileMobileComponent
|
|
183
|
-
lang={preferredLanguage}
|
|
184
|
-
path={`/${preferredLanguage}${path}`}
|
|
185
|
-
routeProps={routeProps}
|
|
186
|
-
countryCodes={countryCodes}
|
|
187
|
-
privateMobileNumber={privateMobileNumber || ''}
|
|
188
|
-
onSave={onSaveMobile}
|
|
189
|
-
saving={saving}
|
|
190
|
-
saved={saved}
|
|
191
|
-
dismissMessages={dismissMessages}
|
|
192
|
-
clear={clear}
|
|
193
|
-
/>
|
|
194
|
-
</AUSpinnerComponent>
|
|
195
|
-
)}
|
|
196
|
-
/>
|
|
197
|
-
<Route
|
|
198
|
-
path={`${langPath}${path}/language`}
|
|
199
|
-
render={(routeProps) => (
|
|
200
|
-
<AUSpinnerComponent
|
|
201
|
-
loaded={loaded}
|
|
202
|
-
loadingCondition={!loaded}
|
|
203
|
-
>
|
|
204
|
-
<AUProfileLanguageComponent
|
|
205
|
-
lang={preferredLanguage}
|
|
206
|
-
path={`/${preferredLanguage}${path}`}
|
|
207
|
-
routeProps={routeProps}
|
|
208
|
-
preferredLanguage={preferredLanguage}
|
|
209
|
-
onSave={onSaveLanguage}
|
|
210
|
-
saving={saving}
|
|
211
|
-
saved={saved}
|
|
212
|
-
dismissMessages={dismissMessages}
|
|
213
|
-
clear={clear}
|
|
214
|
-
/>
|
|
215
|
-
</AUSpinnerComponent>
|
|
216
|
-
)}
|
|
217
|
-
/>
|
|
218
|
-
<Route
|
|
219
|
-
path={`${langPath}${path}/nextofkin`}
|
|
220
|
-
render={(routeProps) => (
|
|
221
|
-
<AUSpinnerComponent
|
|
222
|
-
loaded={loaded}
|
|
223
|
-
loadingCondition={!loaded}
|
|
224
|
-
>
|
|
225
|
-
<AUProfileNextOfKinComponent
|
|
226
|
-
lang={preferredLanguage}
|
|
227
|
-
path={`/${preferredLanguage}${path}`}
|
|
228
|
-
routeProps={routeProps}
|
|
229
|
-
countryCodes={countryCodes}
|
|
230
|
-
nextOfKinName={nextOfKinName || ''}
|
|
231
|
-
nextOfKinPhoneNumber={nextOfKinPhoneNumber || ''}
|
|
232
|
-
onSave={onSaveNextOfKin}
|
|
233
|
-
saving={saving}
|
|
234
|
-
saved={saved}
|
|
235
|
-
dismissMessages={dismissMessages}
|
|
236
|
-
clear={clear}
|
|
237
|
-
/>
|
|
238
|
-
</AUSpinnerComponent>
|
|
239
|
-
)}
|
|
240
|
-
/>
|
|
241
|
-
</div>
|
|
242
|
-
</Router>
|
|
243
|
-
);
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
AUProfileContainerComponent.defaultProps = {
|
|
247
|
-
onUserLoaded: () => { },
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
AUProfileContainerComponent.propTypes = {
|
|
251
|
-
user: PropTypes.shape({
|
|
252
|
-
firstNames: PropTypes.string.isRequired,
|
|
253
|
-
lastName: PropTypes.string.isRequired,
|
|
254
|
-
hasChosenName: PropTypes.bool.isRequired,
|
|
255
|
-
chosenFirstNames: PropTypes.string.isRequired,
|
|
256
|
-
chosenLastName: PropTypes.string.isRequired,
|
|
257
|
-
preferredLanguage: PropTypes.string.isRequired,
|
|
258
|
-
privateMobileNumber: PropTypes.string.isRequired,
|
|
259
|
-
privateMailAddress: PropTypes.string.isRequired,
|
|
260
|
-
nextOfKinName: PropTypes.string.isRequired,
|
|
261
|
-
nextOfKinPhoneNumber: PropTypes.string.isRequired,
|
|
262
|
-
isStudentAdGroupMember: PropTypes.bool.isRequired,
|
|
263
|
-
studentMailAddress: PropTypes.string.isRequired,
|
|
264
|
-
studentChosenMailAddress: PropTypes.string.isRequired,
|
|
265
|
-
workMailAddress: PropTypes.string.isRequired,
|
|
266
|
-
workMailDomain: PropTypes.string.isRequired,
|
|
267
|
-
saving: PropTypes.bool.isRequired,
|
|
268
|
-
saved: PropTypes.bool.isRequired,
|
|
269
|
-
loaded: PropTypes.bool.isRequired,
|
|
270
|
-
}).isRequired,
|
|
271
|
-
path: PropTypes.string.isRequired,
|
|
272
|
-
onSaveName: PropTypes.func.isRequired,
|
|
273
|
-
onSaveMail: PropTypes.func.isRequired,
|
|
274
|
-
onSaveMobile: PropTypes.func.isRequired,
|
|
275
|
-
onSaveLanguage: PropTypes.func.isRequired,
|
|
276
|
-
onSaveNextOfKin: PropTypes.func.isRequired,
|
|
277
|
-
dismissMessages: PropTypes.func.isRequired,
|
|
278
|
-
clear: PropTypes.func.isRequired,
|
|
279
|
-
onUserLoaded: PropTypes.func,
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
AUProfileContainerComponent.displayName = 'AUProfileContainerComponent';
|
|
283
|
-
export default AUProfileContainerComponent;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
3
|
-
|
|
4
|
-
const useProfileForm = (saved, history, lang, callback = () => { }) => {
|
|
5
|
-
const onCancel = () => {
|
|
6
|
-
history.push(`/${lang}/profile`);
|
|
7
|
-
callback();
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (saved) {
|
|
12
|
-
onCancel();
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
return [onCancel];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const useMobilePrefix = (splitPhoneNumber, countryCodes, phone) => {
|
|
20
|
-
const { prefix: p, number: n } = splitPhoneNumber(countryCodes, phone);
|
|
21
|
-
const [prefix, setPrefix] = useState(p);
|
|
22
|
-
const [mobile, setMobile] = useState(n);
|
|
23
|
-
|
|
24
|
-
return [prefix, mobile, setPrefix, setMobile];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export {
|
|
28
|
-
useProfileForm,
|
|
29
|
-
useMobilePrefix,
|
|
30
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/* eslint-disable react/no-array-index-key */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
const AUProfileItemComponent = ({
|
|
6
|
-
header,
|
|
7
|
-
values,
|
|
8
|
-
empty,
|
|
9
|
-
linkElement,
|
|
10
|
-
appendix,
|
|
11
|
-
}) => {
|
|
12
|
-
const renderValues = values.map((value, i) => <div key={`${value}-${i}`} className="settings-list__item__value">{value}</div>);
|
|
13
|
-
const renderEmpty = empty.map((e) => <div key={e} className="settings-list__item__value settings-list__item__value--empty">{e}</div>);
|
|
14
|
-
return (
|
|
15
|
-
<li className="settings-list__item">
|
|
16
|
-
{(() => {
|
|
17
|
-
if (appendix) {
|
|
18
|
-
return (
|
|
19
|
-
<div className="settings-list__item__label settings-list__item__label--with-appendix">
|
|
20
|
-
<span>{header}</span>
|
|
21
|
-
{appendix}
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
return (
|
|
26
|
-
<div className="settings-list__item__label">
|
|
27
|
-
{header}
|
|
28
|
-
</div>
|
|
29
|
-
);
|
|
30
|
-
})()}
|
|
31
|
-
<div className="settings-list__item__values">
|
|
32
|
-
{renderValues}
|
|
33
|
-
{renderEmpty}
|
|
34
|
-
</div>
|
|
35
|
-
{linkElement}
|
|
36
|
-
</li>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
AUProfileItemComponent.defaultProps = {
|
|
41
|
-
empty: [],
|
|
42
|
-
appendix: null,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
AUProfileItemComponent.propTypes = {
|
|
46
|
-
header: PropTypes.string.isRequired,
|
|
47
|
-
values: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
48
|
-
empty: PropTypes.arrayOf(PropTypes.string),
|
|
49
|
-
linkElement: PropTypes.element.isRequired,
|
|
50
|
-
appendix: PropTypes.element,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
AUProfileItemComponent.displayName = 'AUProfileItemComponent';
|
|
54
|
-
export default AUProfileItemComponent;
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
/* eslint-disable jsx-a11y/label-has-associated-control */
|
|
3
|
-
/* eslint-disable jsx-a11y/label-has-for */
|
|
4
|
-
/* eslint-disable max-len */
|
|
5
|
-
import React, { useState, useEffect } from 'react';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
|
-
import { Link } from 'react-router-dom';
|
|
8
|
-
import AUSubmitButtonContainerComponent from '../form/AUSubmitButtonContainerComponent';
|
|
9
|
-
import { useProfileForm } from './AUProfileHooks';
|
|
10
|
-
import { scrollTo } from '../../lib/helpers';
|
|
11
|
-
import { profileLabels } from '../../lib/i18n';
|
|
12
|
-
|
|
13
|
-
const AUProfileLanguageComponent = ({
|
|
14
|
-
lang,
|
|
15
|
-
routeProps: { history },
|
|
16
|
-
path,
|
|
17
|
-
preferredLanguage: pPreferredLanguage,
|
|
18
|
-
onSave,
|
|
19
|
-
onSaveAction,
|
|
20
|
-
saving,
|
|
21
|
-
saved,
|
|
22
|
-
dismissMessages,
|
|
23
|
-
clear,
|
|
24
|
-
}) => {
|
|
25
|
-
const [preferredLanguage, setLanguage] = useState(pPreferredLanguage);
|
|
26
|
-
const [onCancel] = useProfileForm(saved, history, lang, clear);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
scrollTo();
|
|
30
|
-
dismissMessages();
|
|
31
|
-
}, []);
|
|
32
|
-
|
|
33
|
-
return [
|
|
34
|
-
<div key="header" className="list-navigator">
|
|
35
|
-
<h1 className="list-navigator__header">{profileLabels[lang].headerLanguage}</h1>
|
|
36
|
-
<Link className="list-navigator__list-name" to={path}>{profileLabels[lang].headerContainer}</Link>
|
|
37
|
-
</div>,
|
|
38
|
-
<form key="form" className="form" noValidate="novalidate">
|
|
39
|
-
<fieldset>
|
|
40
|
-
<legend>
|
|
41
|
-
<div className="fieldset__legend-wrapper">
|
|
42
|
-
{profileLabels[lang].languageLegend}
|
|
43
|
-
<div className="form-info__hint">
|
|
44
|
-
{profileLabels[lang].legendNameHint}
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
</legend>
|
|
48
|
-
<div className="form__field form__field--horizontal">
|
|
49
|
-
<label htmlFor="language-da">
|
|
50
|
-
Dansk
|
|
51
|
-
</label>
|
|
52
|
-
<input
|
|
53
|
-
type="radio"
|
|
54
|
-
id="language-da"
|
|
55
|
-
checked={preferredLanguage === 'da'}
|
|
56
|
-
onChange={() => {
|
|
57
|
-
setLanguage('da');
|
|
58
|
-
}}
|
|
59
|
-
disabled={saving}
|
|
60
|
-
/>
|
|
61
|
-
</div>
|
|
62
|
-
<div className="form__field form__field--horizontal">
|
|
63
|
-
<label htmlFor="language-en">
|
|
64
|
-
English
|
|
65
|
-
</label>
|
|
66
|
-
<input
|
|
67
|
-
type="radio"
|
|
68
|
-
id="language-en"
|
|
69
|
-
checked={preferredLanguage === 'en'}
|
|
70
|
-
onChange={() => {
|
|
71
|
-
setLanguage('en');
|
|
72
|
-
}}
|
|
73
|
-
disabled={saving}
|
|
74
|
-
/>
|
|
75
|
-
</div>
|
|
76
|
-
</fieldset>
|
|
77
|
-
<AUSubmitButtonContainerComponent
|
|
78
|
-
lang={pPreferredLanguage}
|
|
79
|
-
disabled={saving}
|
|
80
|
-
onSubmit={(e) => {
|
|
81
|
-
e.preventDefault();
|
|
82
|
-
onSave({
|
|
83
|
-
preferredLanguage,
|
|
84
|
-
}, onSaveAction);
|
|
85
|
-
}}
|
|
86
|
-
onCancel={onCancel}
|
|
87
|
-
/>
|
|
88
|
-
</form>,
|
|
89
|
-
];
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
AUProfileLanguageComponent.defaultProps = {
|
|
93
|
-
onSaveAction: (data, callback) => {
|
|
94
|
-
const putData = async () => {
|
|
95
|
-
let url = `${window.profileApiUri}/UpdatePreferredLanguage`;
|
|
96
|
-
if (typeof window.API_AUID !== 'undefined') {
|
|
97
|
-
url = `${url}?auid=${window.API_AUID}`;
|
|
98
|
-
}
|
|
99
|
-
const response = await fetch(url, {
|
|
100
|
-
method: 'PUT',
|
|
101
|
-
credentials: 'include',
|
|
102
|
-
headers: {
|
|
103
|
-
'Content-Type': 'application/json',
|
|
104
|
-
},
|
|
105
|
-
body: JSON.stringify(data),
|
|
106
|
-
});
|
|
107
|
-
const json = await response.json();
|
|
108
|
-
callback(response.ok, response.status, json);
|
|
109
|
-
|
|
110
|
-
// clear context cache
|
|
111
|
-
window.auAuth.setUserContext(window.API_AUID || 0, 'profile-clear-cache', true, () => {}, () => {}, true, window.authenticated);
|
|
112
|
-
};
|
|
113
|
-
putData();
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
AUProfileLanguageComponent.propTypes = {
|
|
118
|
-
lang: PropTypes.string.isRequired,
|
|
119
|
-
routeProps: PropTypes.shape({}).isRequired,
|
|
120
|
-
path: PropTypes.string.isRequired,
|
|
121
|
-
preferredLanguage: PropTypes.string.isRequired,
|
|
122
|
-
onSave: PropTypes.func.isRequired,
|
|
123
|
-
onSaveAction: PropTypes.func,
|
|
124
|
-
saving: PropTypes.bool.isRequired,
|
|
125
|
-
saved: PropTypes.bool.isRequired,
|
|
126
|
-
dismissMessages: PropTypes.func.isRequired,
|
|
127
|
-
clear: PropTypes.func.isRequired,
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
AUProfileLanguageComponent.displayName = 'AUProfileLanguageComponent';
|
|
131
|
-
export default AUProfileLanguageComponent;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
import React, { FC } from 'react';
|
|
3
|
-
|
|
4
|
-
const AUProfileLoginComponent: FC<AUProfileLoginComponentProps> = ({
|
|
5
|
-
loggedIn,
|
|
6
|
-
loginUri,
|
|
7
|
-
children,
|
|
8
|
-
text,
|
|
9
|
-
}: AUProfileLoginComponentProps) => {
|
|
10
|
-
if (!loggedIn) {
|
|
11
|
-
return (
|
|
12
|
-
<a
|
|
13
|
-
className="nav__item nav__item--icon nav__item--icon--right nav__item--icon--always-show-label"
|
|
14
|
-
data-icon=""
|
|
15
|
-
href={loginUri}
|
|
16
|
-
>
|
|
17
|
-
{text}
|
|
18
|
-
</a>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return children;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
AUProfileLoginComponent.displayName = 'AUProfileLoginComponent';
|
|
26
|
-
export default AUProfileLoginComponent;
|