@aarhus-university/au-lib-react-components 9.11.16 → 9.11.19

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "@aarhus-university/au-lib-react-components",
4
- "version": "9.11.16",
4
+ "version": "9.11.19",
5
5
  "description": "Library for shared React components for various applications on au.dk",
6
6
  "main": "build/cjs/index.js",
7
7
  "scripts": {
@@ -12,10 +12,10 @@ const AUProfileAvatarComponent = React.memo(({
12
12
  profileLabels,
13
13
  logoutUri,
14
14
  changeLanguageUrl,
15
+ lang,
15
16
  }) => {
16
17
  const {
17
18
  auId,
18
- preferredLanguage,
19
19
  firstNames,
20
20
  lastName,
21
21
  } = user;
@@ -32,10 +32,10 @@ const AUProfileAvatarComponent = React.memo(({
32
32
  className="nav__item nav__item--icon nav__item--icon--right"
33
33
  dataIcon=""
34
34
  text={firstNames}
35
- ariaLabel={`${profileLabels[preferredLanguage].profileFor} ${firstNames} ${lastName}`}
35
+ ariaLabel={`${profileLabels[lang].profileFor} ${firstNames} ${lastName}`}
36
36
  >
37
37
  <AUProfileWidgetComponent
38
- lang={preferredLanguage}
38
+ lang={lang}
39
39
  name={`${firstNames} ${lastName}`}
40
40
  auid={auId}
41
41
  settings={settings}
@@ -73,6 +73,7 @@ AUProfileAvatarComponent.propTypes = {
73
73
  profileLabels: PropTypes.shape({}).isRequired,
74
74
  logoutUri: PropTypes.string.isRequired,
75
75
  changeLanguageUrl: PropTypes.string,
76
+ lang: PropTypes.string.isRequired,
76
77
  };
77
78
 
78
79
  AUProfileAvatarComponent.displayName = 'AUProfileAvatarComponent';
@@ -23,7 +23,8 @@ const AUProfileWidgetComponent = React.memo(({
23
23
  className={`sub-nav__item ${s.classNames}`}
24
24
  href={s.url}
25
25
  data-icon={s.icon}
26
- data-gtm={s.dataGtm}>
26
+ data-gtm={s.dataGtm}
27
+ >
27
28
  {s.text}
28
29
  </a>
29
30
  );
@@ -156,17 +156,20 @@ const splitPhoneNumber = (countryCodes, phoneNumber) => {
156
156
  ).length > 0;
157
157
 
158
158
  const findPrefix = () => {
159
- const skip = '+';
160
- let count = 1;
161
- let prefix = countryCodes.find((x) => x.important).code;
162
- while (count < phoneNumber.length) {
163
- const split = phoneNumber.substring(skip.length, skip.length + count);
164
- if (countryCodeFound(split)) {
165
- prefix = split;
159
+ if (countryCodes.length > 0) {
160
+ const skip = '';
161
+ let count = 1;
162
+ let prefix = countryCodes.find((x) => x.important).code;
163
+ while (count < phoneNumber.length) {
164
+ const split = phoneNumber.substring(skip.length, skip.length + count);
165
+ if (countryCodeFound(split)) {
166
+ prefix = split;
167
+ }
168
+ count += 1;
166
169
  }
167
- count += 1;
170
+ return skip + prefix;
168
171
  }
169
- return skip + prefix;
172
+ return '';
170
173
  };
171
174
 
172
175
  const prefix = findPrefix();
@@ -179,7 +182,10 @@ const splitPhoneNumber = (countryCodes, phoneNumber) => {
179
182
  const prettyPrintPhone = (countryCodes, phone) => {
180
183
  if (phone) {
181
184
  const { prefix, number } = splitPhoneNumber(countryCodes, phone);
182
- return `${prefix} ${number.match(/\d{1,2}/g).join(' ')}`;
185
+ if (prefix) {
186
+ return `${prefix} ${number.match(/\d{1,2}/g).join(' ')}`;
187
+ }
188
+ return number.match(/\d{1,2}/g).join(' ');
183
189
  }
184
190
  return '';
185
191
  };