Skip to content

Commit 6536476

Browse files
[BUGFIX] Sur Pix App .org corriger les liens vers le support qui ne sont pas bons sur les pages de réinitialisation du mot de passe (PIX-16033)
#11065
2 parents 1d5d6ad + b513c6b commit 6536476

File tree

10 files changed

+95
-20
lines changed

10 files changed

+95
-20
lines changed

Diff for: mon-pix/app/components/authentication/password-reset-demand/password-reset-demand-form.gjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import PasswordResetDemandReceivedInfo from './password-reset-demand-received-in
1616
export default class PasswordResetDemandForm extends Component {
1717
@service errors;
1818
@service requestManager;
19+
@service url;
1920

2021
@tracked globalError = this.errors.hasErrors && this.errors.shift();
2122
@tracked isLoading = false;
@@ -114,7 +115,7 @@ export default class PasswordResetDemandForm extends Component {
114115
<section class="authentication-password-reset-demand-form__help">
115116
<h2>
116117
{{t "components.authentication.password-reset-demand-form.no-email-question"}}</h2>
117-
<a href="{{t 'components.authentication.password-reset-demand-form.contact-us-link.link-url'}}">
118+
<a href="{{this.url.supportHomeUrl}}">
118119
{{t "components.authentication.password-reset-demand-form.contact-us-link.link-text"}}
119120
</a>
120121
</section>

Diff for: mon-pix/app/services/locale.js

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export const ENGLISH_INTERNATIONAL_LOCALE = 'en';
88
export const FRENCH_FRANCE_LOCALE = 'fr-FR';
99
export const DEFAULT_LOCALE = FRENCH_INTERNATIONAL_LOCALE;
1010

11+
const SUPPORTED_LOCALES = ['en', 'es', 'fr', 'fr-BE', 'fr-FR', 'nl-BE', 'nl'];
12+
1113
const supportedLanguages = Object.keys(languages);
1214

1315
export default class LocaleService extends Service {
@@ -16,6 +18,15 @@ export default class LocaleService extends Service {
1618
@service intl;
1719
@service dayjs;
1820

21+
isSupportedLocale(locale) {
22+
try {
23+
const localeCanonicalName = Intl.getCanonicalLocales(locale)?.[0];
24+
return SUPPORTED_LOCALES.some((supportedLocale) => localeCanonicalName == supportedLocale);
25+
} catch {
26+
return false;
27+
}
28+
}
29+
1930
handleUnsupportedLanguage(language) {
2031
if (!language) return;
2132
return supportedLanguages.includes(language) ? language : DEFAULT_LOCALE;

Diff for: mon-pix/app/services/url.js

+11-10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const SPANISH_INTERNATIONAL_LOCALE = 'es';
88
export default class Url extends Service {
99
@service currentDomain;
1010
@service intl;
11+
@service locale;
1112

1213
definedHomeUrl = ENV.rootURL;
1314

@@ -108,22 +109,22 @@ export default class Url extends Service {
108109
}
109110

110111
get supportHomeUrl() {
111-
const currentLanguage = this.intl.primaryLocale;
112+
const currentLocale = this.intl.primaryLocale;
112113

113114
if (this.currentDomain.isFranceDomain) {
114115
return 'https://pix.fr/support';
115116
}
116117

117-
switch (currentLanguage) {
118-
case ENGLISH_INTERNATIONAL_LOCALE:
119-
return 'https://pix.org/en/support';
120-
case DUTCH_INTERNATIONAL_LOCALE:
121-
return 'https://pix.org/nl-be/support';
122-
case SPANISH_INTERNATIONAL_LOCALE:
123-
return 'https://pix.org/en/support';
124-
default:
125-
return 'https://pix.org/fr/support';
118+
let locale;
119+
if (currentLocale == 'nl') {
120+
locale = 'nl-BE';
121+
} else if (this.locale.isSupportedLocale(currentLocale)) {
122+
locale = currentLocale;
123+
} else {
124+
locale = ENGLISH_INTERNATIONAL_LOCALE;
126125
}
126+
127+
return `https://pix.org/${locale}/support`;
127128
}
128129

129130
get serverStatusUrl() {

Diff for: mon-pix/tests/integration/components/authentication/password-reset-demand/password-reset-demand-form-test.gjs

+12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { fillByLabel, render } from '@1024pix/ember-testing-library';
2+
import Service from '@ember/service';
23
import { click } from '@ember/test-helpers';
34
import { setLocale, t } from 'ember-intl/test-support';
45
import PasswordResetDemandForm from 'mon-pix/components/authentication/password-reset-demand/password-reset-demand-form';
@@ -30,6 +31,17 @@ module('Integration | Component | Authentication | PasswordResetDemand | passwor
3031

3132
test('it displays all elements of component successfully', async function (assert) {
3233
// given
34+
class CurrentDomainServiceStub extends Service {
35+
get isFranceDomain() {
36+
return true;
37+
}
38+
39+
getExtension() {
40+
return '.fr';
41+
}
42+
}
43+
this.owner.register('service:currentDomain', CurrentDomainServiceStub);
44+
3345
const screen = await render(<template><PasswordResetDemandForm /></template>);
3446

3547
// then

Diff for: mon-pix/tests/unit/services/locale-test.js

+54
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,60 @@ module('Unit | Services | locale', function (hooks) {
2727
sinon.stub(intlService, 'setLocale');
2828
});
2929

30+
module('#isSupportedLocale', function () {
31+
module('when locale is supported', function () {
32+
test('returns true', function (assert) {
33+
// given
34+
const locale = 'nl-BE';
35+
36+
// when
37+
const result = localeService.isSupportedLocale(locale);
38+
39+
// then
40+
assert.true(result);
41+
});
42+
});
43+
44+
module('when locale is supported but not given in canonical form', function () {
45+
test('returns true', function (assert) {
46+
// given
47+
const locale = 'nl-be';
48+
49+
// when
50+
const result = localeService.isSupportedLocale(locale);
51+
52+
// then
53+
assert.true(result);
54+
});
55+
});
56+
57+
module('when locale is valid but not supported', function () {
58+
test('returns false', function (assert) {
59+
// given
60+
const locale = 'ko';
61+
62+
// when
63+
const result = localeService.isSupportedLocale(locale);
64+
65+
// then
66+
assert.false(result);
67+
});
68+
});
69+
70+
module('when locale is invalid', function () {
71+
test('returns false', function (assert) {
72+
// given
73+
const locale = 'invalid_locale_in_bad_format';
74+
75+
// when
76+
const result = localeService.isSupportedLocale(locale);
77+
78+
// then
79+
assert.false(result);
80+
});
81+
});
82+
});
83+
3084
module('#handleUnsupportedLanguage', function () {
3185
module('when language is not supported', function () {
3286
test('returns default language', function (assert) {

Diff for: mon-pix/tests/unit/services/url-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ module('Unit | Service | url', function (hooks) {
496496
const service = this.owner.lookup('service:url');
497497
service.currentDomain = { isFranceDomain: false };
498498
service.intl = { primaryLocale: DUTCH_INTERNATIONAL_LOCALE };
499-
const expectedSupportHomeUrl = 'https://pix.org/nl-be/support';
499+
const expectedSupportHomeUrl = 'https://pix.org/nl-BE/support';
500500

501501
// when
502502
const supportHomeUrl = service.supportHomeUrl;

Diff for: mon-pix/translations/en.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@
184184
"receive-reset-button": "Receive a reset link"
185185
},
186186
"contact-us-link": {
187-
"link-text": "Contact us",
188-
"link-url": "https://pix.org/en/support"
187+
"link-text": "Contact us"
189188
},
190189
"fields": {
191190
"email": {

Diff for: mon-pix/translations/es.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@
190190
"receive-reset-button": "Reiniciar contraseña"
191191
},
192192
"contact-us-link": {
193-
"link-text": "Contáctanos.",
194-
"link-url": "https://pix.fr/support"
193+
"link-text": "Contáctanos."
195194
},
196195
"fields": {
197196
"email": {

Diff for: mon-pix/translations/fr.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@
184184
"receive-reset-button": "Recevoir un lien de réinitialisation"
185185
},
186186
"contact-us-link": {
187-
"link-text": "Contactez-nous",
188-
"link-url": "https://pix.fr/support"
187+
"link-text": "Contactez-nous"
189188
},
190189
"fields": {
191190
"email": {

Diff for: mon-pix/translations/nl.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@
190190
"receive-reset-button": "Een reset-link ontvangen"
191191
},
192192
"contact-us-link": {
193-
"link-text": "Contacteer ons",
194-
"link-url": "https://pix.fr/support"
193+
"link-text": "Contacteer ons"
195194
},
196195
"fields": {
197196
"email": {

0 commit comments

Comments
 (0)