Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion frontend/public/locales/ar/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@
"reregisterAccount": "يرجى إعادة تسجيل حسابك.",
"resetPassword": " يرجى إعادة تعيين كلمة المرور. تم إرسال رابط لإعادة تعيين كلمة المرور الخاصة بك إلى بريدك الإلكتروني. ",
"serverError": "هناك خطأ ما.",
"wrongRole": "دور خاطئ الرجاء اختيار الدور الصحيح للحساب"
"wrongRole": "دور خاطئ الرجاء اختيار الدور الصحيح للحساب",
"roleMismatch": "This email belongs to a {{role}} account. Please log in as {{role}}.",
"profileIncomplete": "We found your {{role}} account, but your profile isn’t complete yet. Please finish your profile.",
"noAccountForRole": "No {{role}} account found for this email. Please check your role or apply."
},
"menteeApplication": {
"ageAnswer1": "عمري 18-22",
Expand Down
5 changes: 4 additions & 1 deletion frontend/public/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@
"reregisterAccount": "Please re-register your account.",
"resetPassword": "Please reset password. A link to reset your password has been sent to your email.",
"serverError": "Something went wrong.",
"wrongRole": "Wrong role please choose account right role"
"wrongRole": "Wrong role please choose account right role",
"roleMismatch": "This email belongs to a {{role}} account. Please log in as {{role}}.",
"profileIncomplete": "We found your {{role}} account, but your profile isn’t complete yet. Please finish your profile.",
"noAccountForRole": "No {{role}} account found for this email. Please check your role or apply."
},
"menteeApplication": {
"ageAnswer1": "I am 18-22",
Expand Down
5 changes: 4 additions & 1 deletion frontend/public/locales/es-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@
"reregisterAccount": "Vuelva a registrar su cuenta.",
"resetPassword": "Por favor, restablezca la contraseña. ",
"serverError": "Algo salió mal.",
"wrongRole": "Rol incorrecto, elija el rol correcto de la cuenta"
"wrongRole": "Rol incorrecto, elija el rol correcto de la cuenta",
"roleMismatch": "This email belongs to a {{role}} account. Please log in as {{role}}.",
"profileIncomplete": "We found your {{role}} account, but your profile isn’t complete yet. Please finish your profile.",
"noAccountForRole": "No {{role}} account found for this email. Please check your role or apply."
},
"menteeApplication": {
"ageAnswer1": "",
Expand Down
5 changes: 4 additions & 1 deletion frontend/public/locales/fa-AF/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@
"reregisterAccount": "لطفاً حساب خود را مجدداً ثبت کنید.",
"resetPassword": "لطفا رمز عبور خود را تغییر دهید. لینک برای تغییر رمز عبور به ایمیل شما ارسال شده است.",
"serverError": "مشکلی پیش آمد.",
"wrongRole": "نقش اشتباه؛ لطفاً نقش درست حساب را انتخاب کنید."
"wrongRole": "نقش اشتباه؛ لطفاً نقش درست حساب را انتخاب کنید.",
"roleMismatch": "This email belongs to a {{role}} account. Please log in as {{role}}.",
"profileIncomplete": "We found your {{role}} account, but your profile isn’t complete yet. Please finish your profile.",
"noAccountForRole": "No {{role}} account found for this email. Please check your role or apply."
},
"menteeApplication": {
"ageAnswer1": "",
Expand Down
5 changes: 4 additions & 1 deletion frontend/public/locales/pa-AR/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@
"reregisterAccount": "مهربانی وکړی خپل اکونت بیا راجستر کړی",
"resetPassword": "مهربانی وکړی خپل پاسورد بیا جوړ کړی. د پاسورد بیا جوړولو لپاره لنک ستاسو بریښنالیک ته درولیږل شوو.",
"serverError": "څه ناسم دی",
"wrongRole": "ناسمه ونده مهربانی وکړی سمه ونده وټاکی"
"wrongRole": "ناسمه ونده مهربانی وکړی سمه ونده وټاکی",
"roleMismatch": "This email belongs to a {{role}} account. Please log in as {{role}}.",
"profileIncomplete": "We found your {{role}} account, but your profile isn’t complete yet. Please finish your profile.",
"noAccountForRole": "No {{role}} account found for this email. Please check your role or apply."
},
"menteeApplication": {
"ageAnswer1": "زه د ۱۸ - ۲۲ یم",
Expand Down
5 changes: 4 additions & 1 deletion frontend/public/locales/pt-BR/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@
"reregisterAccount": "Por favor, registre sua conta novamente.",
"resetPassword": "Por favor, redefina a senha. Um link de redefinição de senha foi enviado para o seu e-mail.",
"serverError": "Algo deu errado.",
"wrongRole": "Por favor, selecione corretamente o tipo de conta."
"wrongRole": "Por favor, selecione corretamente o tipo de conta.",
"roleMismatch": "This email belongs to a {{role}} account. Please log in as {{role}}.",
"profileIncomplete": "We found your {{role}} account, but your profile isn’t complete yet. Please finish your profile.",
"noAccountForRole": "No {{role}} account found for this email. Please check your role or apply."
},
"menteeApplication": {
"ageAnswer1": "Eu tenho entre 18 e 22 anos",
Expand Down
35 changes: 27 additions & 8 deletions frontend/src/components/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function LoginForm({ role, defaultEmail, n50_flag, location }) {
const [loading, setLoading] = useState(false);
const [messageApi, contextHolder] = message.useMessage();
const [form] = Form.useForm();
const roleLabel = t(`common.${ACCOUNT_TYPE_LABELS[role]}`);

const onFinish = async ({ email, password }) => {
if (role == null) return;
Expand All @@ -43,10 +44,12 @@ function LoginForm({ role, defaultEmail, n50_flag, location }) {
);
if (rightRole && parseInt(rightRole) !== role) {
messageApi.error({
content: t("loginErrors.wrongRole"),
content: t("loginErrors.roleMismatch", {
role: t(`common.${ACCOUNT_TYPE_LABELS[parseInt(rightRole)]}`),
}),
duration: 0,
key: "loginErrors.wrongRole",
onClick: () => messageApi.destroy("loginErrors.wrongRole"),
key: "loginErrors.roleMismatch",
onClick: () => messageApi.destroy("loginErrors.roleMismatch"),
});
setLoading(false);
return;
Expand All @@ -55,16 +58,24 @@ function LoginForm({ role, defaultEmail, n50_flag, location }) {
const { inFirebase } = await checkStatusByEmail(email, role);
if (profileExists === false && inFirebase === true) {
//redirect to apply with role and email passed
messageApi.info({
content: t("loginErrors.profileIncomplete", { role: roleLabel }),
duration: 0,
key: "loginErrors.profileIncomplete",
onClick: () => messageApi.destroy("loginErrors.profileIncomplete"),
});
history.push({
pathname: "/application-page",
pathname: n50_flag ? "/n50/build-profile" : "/build-profile",
state: { email, role },
});
setLoading(false);
return;
} else if (profileExists === false && inFirebase === false) {
messageApi.error({
content: t("loginErrors.incorrectCredentials"),
content: t("loginErrors.noAccountForRole", { role: roleLabel }),
duration: 0,
key: "loginErrors.incorrectCredentials",
onClick: () => messageApi.destroy("loginErrors.incorrectCredentials"),
key: "loginErrors.noAccountForRole",
onClick: () => messageApi.destroy("loginErrors.noAccountForRole"),
});
setLoading(false);
return;
Expand All @@ -86,6 +97,14 @@ function LoginForm({ role, defaultEmail, n50_flag, location }) {
onClick: () => messageApi.destroy("loginErrors.existingEmail"),
});
setLoading(false);
} else if (res?.data?.message) {
messageApi.error({
content: res.data.message,
duration: 0,
key: "loginErrors.serverMessage",
onClick: () => messageApi.destroy("loginErrors.serverMessage"),
});
setLoading(false);
} else {
messageApi.error({
content: t("loginErrors.incorrectCredentials"),
Expand All @@ -111,7 +130,7 @@ function LoginForm({ role, defaultEmail, n50_flag, location }) {
key: "loginErrors.reregisterAccount",
onClick: () => messageApi.destroy("loginErrors.reregisterAccount"),
});
history.push("/application-page");
history.push("/apply");
}
const unsubscribe = fireauth.auth().onAuthStateChanged(async (user) => {
unsubscribe();
Expand Down
Loading