Skip to content

Commit e66d274

Browse files
committed
[fix] Fixes by @coderabbitai
1 parent b0e2467 commit e66d274

10 files changed

Lines changed: 149 additions & 18 deletions

File tree

client/components/complete-signup/complete-signup.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@ import upgradePlan from "../../utils/upgrade-plan";
1717
import updateRegistrationMethod from "../../utils/update-registration-method";
1818
import Contact from "../contact-box";
1919

20-
const handleFlowError = (error) => {
20+
const handleFlowError = (error, setErrorsState) => {
2121
const errorText = error.response
2222
? getErrorText(error, t`ERR_OCCUR`)
2323
: t`ERR_OCCUR`;
2424
logError(error, errorText);
2525
toast.error(errorText);
26+
if (setErrorsState) {
27+
setErrorsState({nonfield: [errorText]});
28+
}
2629
};
2730

2831
export default class CompleteSignup extends React.Component {
@@ -35,6 +38,8 @@ export default class CompleteSignup extends React.Component {
3538
plansFetched: false,
3639
plansError: null,
3740
selectedPlan: null,
41+
message: null,
42+
submitting: false,
3843
};
3944
}
4045

@@ -74,7 +79,7 @@ export default class CompleteSignup extends React.Component {
7479

7580
if (!plans || plans.length === 0) {
7681
// Empty plans array (200 OK) means org has disabled registration
77-
message = t`Registration is currently disabled for this organization`;
82+
message = t`ORG_REGISTRATION_DISABLED`;
7883
}
7984
this.setStateSafe({plans, plansFetched: true, plansError, message});
8085
setLoading(false);
@@ -89,10 +94,10 @@ export default class CompleteSignup extends React.Component {
8994
this.setStateSafe({
9095
plans: [],
9196
plansFetched: true,
92-
plansError: t`Failed to load plans`,
97+
plansError: t`PLANS_FETCH_ERR`,
9398
});
9499
setLoading(false);
95-
toast.error(t`Failed to load plans`);
100+
toast.error(t`PLANS_FETCH_ERR`);
96101
};
97102

98103
finalOperations = (nextUserData, route) => {
@@ -141,7 +146,7 @@ export default class CompleteSignup extends React.Component {
141146
this.finalOperations(nextUserData, `/${orgSlug}/status`);
142147
} catch (error) {
143148
if (this.isComponentMounted) {
144-
handleFlowError(error);
149+
handleFlowError(error, (errors) => this.setStateSafe({errors}));
145150
setLoading(false);
146151
}
147152
}
@@ -169,20 +174,20 @@ export default class CompleteSignup extends React.Component {
169174
const {setLoading} = this.context;
170175
const {orgSlug, userData, setUserData, navigate, settings, language} =
171176
this.props;
172-
const {plans} = this.state;
177+
const {plans, submitting} = this.state;
173178
const selectedPlan = plans[planIndex];
174-
if (!selectedPlan) {
179+
if (!selectedPlan || submitting) {
175180
return;
176181
}
177182

178183
const requiresPayment = selectedPlan.requires_payment === true;
179-
this.setStateSafe({errors: {}});
184+
this.setStateSafe({errors: {}, submitting: true});
180185
setLoading(true);
181186

182187
try {
183188
// Upgrade to selected plan
184189
let paymentUrl = null;
185-
if (selectedPlan && selectedPlan.id) {
190+
if (selectedPlan.id) {
186191
const response = await upgradePlan(
187192
orgSlug,
188193
selectedPlan.id,
@@ -243,7 +248,9 @@ export default class CompleteSignup extends React.Component {
243248
this.finalOperations(nextUserData, `/${orgSlug}/status`);
244249
} catch (error) {
245250
if (this.isComponentMounted) {
246-
handleFlowError(error);
251+
handleFlowError(error, (errors) =>
252+
this.setStateSafe({errors, submitting: false}),
253+
);
247254
setLoading(false);
248255
}
249256
}
@@ -264,7 +271,7 @@ export default class CompleteSignup extends React.Component {
264271
const {orgSlug, language} = this.props;
265272
const {setLoading} = this.context;
266273
setLoading(true);
267-
this.setStateSafe({plansError: null, message: null}, () => {
274+
this.setStateSafe({errors: {}, plansError: null, message: null}, () => {
268275
getPlans(
269276
orgSlug,
270277
language,
@@ -285,7 +292,7 @@ export default class CompleteSignup extends React.Component {
285292
<div className="inner">
286293
<h2 className="row">{t`REGISTRATION_TITLE`}</h2>
287294
<div className="row">
288-
{t`Please complete your registration to ${orgName}.`}
295+
{t`REGISTRATION_COMPLETE_PROMPT`} {orgName}.
289296
</div>
290297
{getError(errors)}
291298
{/* HTTP error state - show error with retry button */}
@@ -297,7 +304,7 @@ export default class CompleteSignup extends React.Component {
297304
className="btn btn-primary"
298305
onClick={this.handlePlansRetry}
299306
>
300-
{t`Retry`}
307+
{t`RETRY`}
301308
</button>
302309
</div>
303310
)}

client/components/complete-signup/complete-signup.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ describe("<CompleteSignup />", () => {
185185
});
186186

187187
it("renders generic copy with organization name", () => {
188-
expect(wrapper.text()).toContain("Please complete your registration to");
188+
expect(wrapper.text()).toContain(t`REGISTRATION_COMPLETE_PROMPTt`);
189189
expect(wrapper.text()).toContain("Default");
190190
});
191191

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
export const userPendingVerification = (user = {}) =>
22
user.method === "pending_verification" && user.is_verified === false;
33

4-
export const getVerificationRoute = (orgSlug, method) =>
5-
method === "bank_card"
6-
? `/${orgSlug}/payment/draft`
7-
: `/${orgSlug}/mobile-phone-verification`;
4+
export const getVerificationRoute = (orgSlug, method) => {
5+
if (method === "bank_card") {
6+
return `/${orgSlug}/payment/draft`;
7+
}
8+
if (method === "mobile_phone") {
9+
return `/${orgSlug}/mobile-phone-verification`;
10+
}
11+
throw new Error(`Unknown verification method: ${method}`);
12+
};

i18n/de.po

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,3 +678,20 @@ msgstr "Die gesuchte Seite konnte leider nicht gefunden werden."
678678
#: client/components/404/404.js:37
679679
msgid "HOME_PG_LINK_TXT"
680680
msgstr "Zurück zur ersten Seite"
681+
682+
#: client/components/complete-signup/complete-signup.js:77
683+
msgid "ORG_REGISTRATION_DISABLED"
684+
msgstr "Die Registrierung ist für diese Organisation derzeit deaktiviert"
685+
686+
#: client/components/complete-signup/complete-signup.js:92
687+
#: client/components/complete-signup/complete-signup.js:95
688+
msgid "PLANS_FETCH_ERR"
689+
msgstr "Pläne konnten nicht geladen werden"
690+
691+
#: client/components/complete-signup/complete-signup.js:288
692+
msgid "REGISTRATION_COMPLETE_PROMPT"
693+
msgstr "Bitte schließen Sie Ihre Registrierung ab bei"
694+
695+
#: client/components/complete-signup/complete-signup.js:300
696+
msgid "RETRY"
697+
msgstr "Erneut versuchen"

i18n/en.po

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,3 +673,20 @@ msgstr "Sorry, we couldn't find the page you were looking for."
673673
#: client/components/404/404.js:37
674674
msgid "HOME_PG_LINK_TXT"
675675
msgstr "Go back to homepage"
676+
677+
#: client/components/complete-signup/complete-signup.js:77
678+
msgid "ORG_REGISTRATION_DISABLED"
679+
msgstr "Registration is currently disabled for this organization"
680+
681+
#: client/components/complete-signup/complete-signup.js:92
682+
#: client/components/complete-signup/complete-signup.js:95
683+
msgid "PLANS_FETCH_ERR"
684+
msgstr "Failed to load plans"
685+
686+
#: client/components/complete-signup/complete-signup.js:288
687+
msgid "REGISTRATION_COMPLETE_PROMPT"
688+
msgstr "Please complete your registration to"
689+
690+
#: client/components/complete-signup/complete-signup.js:300
691+
msgid "RETRY"
692+
msgstr "Retry"

i18n/es.po

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,3 +685,20 @@ msgstr "Lo sentimos, no pudimos encontrar la página que estabas buscando."
685685
#: client/components/404/404.js:37
686686
msgid "HOME_PG_LINK_TXT"
687687
msgstr "Volver a la página de inicio"
688+
689+
#: client/components/complete-signup/complete-signup.js:77
690+
msgid "ORG_REGISTRATION_DISABLED"
691+
msgstr "El registro está actualmente deshabilitado para esta organización"
692+
693+
#: client/components/complete-signup/complete-signup.js:92
694+
#: client/components/complete-signup/complete-signup.js:95
695+
msgid "PLANS_FETCH_ERR"
696+
msgstr "No se pudieron cargar los planes"
697+
698+
#: client/components/complete-signup/complete-signup.js:288
699+
msgid "REGISTRATION_COMPLETE_PROMPT"
700+
msgstr "Por favor, complete su registro a"
701+
702+
#: client/components/complete-signup/complete-signup.js:300
703+
msgid "RETRY"
704+
msgstr "Reintentar"

i18n/fur.po

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,3 +676,20 @@ msgstr "O domandìn scuse, la pagjine cirude no je stade cjatade."
676676
#: client/components/404/404.js:37
677677
msgid "HOME_PG_LINK_TXT"
678678
msgstr "Torne ae prime pagjine"
679+
680+
#: client/components/complete-signup/complete-signup.js:77
681+
msgid "ORG_REGISTRATION_DISABLED"
682+
msgstr "La registrazion e je disabilitade par cheste organizazion"
683+
684+
#: client/components/complete-signup/complete-signup.js:92
685+
#: client/components/complete-signup/complete-signup.js:95
686+
msgid "PLANS_FETCH_ERR"
687+
msgstr "Nol è pussibil cjamâ i plans"
688+
689+
#: client/components/complete-signup/complete-signup.js:288
690+
msgid "REGISTRATION_COMPLETE_PROMPT"
691+
msgstr "Par favôr, complete la vuestre registrazion a"
692+
693+
#: client/components/complete-signup/complete-signup.js:300
694+
msgid "RETRY"
695+
msgstr "Torne"

i18n/it.po

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,3 +680,20 @@ msgstr "Ci scusiamo, la pagina cercata non è stata trovata."
680680
#: client/components/404/404.js:37
681681
msgid "HOME_PG_LINK_TXT"
682682
msgstr "Torna alla prima pagina"
683+
684+
#: client/components/complete-signup/complete-signup.js:77
685+
msgid "ORG_REGISTRATION_DISABLED"
686+
msgstr "La registrazione è attualmente disabilitata per questa organizzazione"
687+
688+
#: client/components/complete-signup/complete-signup.js:92
689+
#: client/components/complete-signup/complete-signup.js:95
690+
msgid "PLANS_FETCH_ERR"
691+
msgstr "Impossibile caricare i piani"
692+
693+
#: client/components/complete-signup/complete-signup.js:288
694+
msgid "REGISTRATION_COMPLETE_PROMPT"
695+
msgstr "Si prega di completare la registrazione a"
696+
697+
#: client/components/complete-signup/complete-signup.js:300
698+
msgid "RETRY"
699+
msgstr "Riprova"

i18n/ru.po

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,3 +672,20 @@ msgstr "404 Страница не найдена.."
672672
#: client/components/404/404.js:37
673673
msgid "HOME_PG_LINK_TXT"
674674
msgstr "Вернись на первую страницу"
675+
676+
#: client/components/complete-signup/complete-signup.js:77
677+
msgid "ORG_REGISTRATION_DISABLED"
678+
msgstr "Регистрация в настоящее время отключена для этой организации"
679+
680+
#: client/components/complete-signup/complete-signup.js:92
681+
#: client/components/complete-signup/complete-signup.js:95
682+
msgid "PLANS_FETCH_ERR"
683+
msgstr "Не удалось загрузить планы"
684+
685+
#: client/components/complete-signup/complete-signup.js:288
686+
msgid "REGISTRATION_COMPLETE_PROMPT"
687+
msgstr "Пожалуйста, завершите регистрацию в"
688+
689+
#: client/components/complete-signup/complete-signup.js:300
690+
msgid "RETRY"
691+
msgstr "Повторить попытку"

i18n/sl.po

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,3 +664,20 @@ msgstr "Oprostite, iskane strani ni bilo mogoče najti."
664664
#: client/components/404/404.js:37
665665
msgid "HOME_PG_LINK_TXT"
666666
msgstr "Nazaj na domačo stran"
667+
668+
#: client/components/complete-signup/complete-signup.js:77
669+
msgid "ORG_REGISTRATION_DISABLED"
670+
msgstr "Registracija je trenutno onemogočena za to organizacijo"
671+
672+
#: client/components/complete-signup/complete-signup.js:92
673+
#: client/components/complete-signup/complete-signup.js:95
674+
msgid "PLANS_FETCH_ERR"
675+
msgstr "Ni bilo mogoče naložiti načrte"
676+
677+
#: client/components/complete-signup/complete-signup.js:288
678+
msgid "REGISTRATION_COMPLETE_PROMPT"
679+
msgstr "Prosimo, dokončajte svojo registracijo za"
680+
681+
#: client/components/complete-signup/complete-signup.js:300
682+
msgid "RETRY"
683+
msgstr "Poskusi znova"

0 commit comments

Comments
 (0)