Skip to content

Commit

Permalink
[ Feature ] Select Organization on the Registration screen (#1904)
Browse files Browse the repository at this point in the history
* Added select org dropdown to the register form

* Added Signup logic

* Final Changes

* lint fixes

* Update package.json

* Correct merge

* Added missing translations

* Unit tests written

* Unit tests fix

* Fixed failing unit tests

* Fixed issues

* Reverted changes to package-lock.json

* Update package-lock.json
  • Loading branch information
karthxk07 authored May 3, 2024
1 parent d03f5ca commit 3c2314d
Show file tree
Hide file tree
Showing 14 changed files with 418 additions and 59 deletions.
37 changes: 36 additions & 1 deletion public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,42 @@
"lowercase_check": "Atleast one lowercase letter",
"uppercase_check": "Atleast one uppercase letter",
"numeric_value_check": "Atleaset one numeric value",
"special_char_check": "Atleast one special character"
"special_char_check": "Atleast one special character",
"loading": "Loading...",
"selectOrg": "Select an organization",
"afterRegister": "Successfully registered. Please wait for admin to approve your request."
},
"userLoginPage": {
"title": "Talawa Admin",
"fromPalisadoes": "An open source application by Palisadoes Foundation volunteers",
"talawa_portal": "Talawa Admin Portal",
"login": "Login",
"register": "Register",
"firstName": "First Name",
"lastName": "Last Name",
"email": "Email",
"password": "Password",
"atleast_8_char_long": "Atleast 8 Character long",
"Password_and_Confirm_password_mismatches.": "Password and Confirm password mismatches.",
"confirmPassword": "Confirm Password",
"forgotPassword": "Forgot Password ?",
"enterEmail": "Enter Email",
"enterPassword": "Enter Password",
"doNotOwnAnAccount": "Do not own an account?",
"talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too.",
"captchaError": "Captcha Error!",
"Please_check_the_captcha": "Please, check the captcha.",
"Something_went_wrong": "Something went wrong, Please try after sometime.",
"passwordMismatches": "Password and Confirm password mismatches.",
"fillCorrectly": "Fill all the Details Correctly.",
"notAuthorised": "Sorry! you are not Authorised!",
"notFound": "User not found!",
"successfullyRegistered": "Successfully Registered. Please wait until you will be approved.",
"userLogin": "User Login",
"afterRegister": "Successfully registered. Please wait for admin to approve your request.",
"OR": "OR",
"loading": "Loading...",
"selectOrg": "Select an organization"
},
"latestEvents": {
"eventCardTitle": "Upcoming Events",
Expand Down
35 changes: 34 additions & 1 deletion public/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,40 @@
"lowercase_check": "Au moins une lettre minuscule",
"uppercase_check": "Au moins une lettre majuscule",
"special_char_check": "Au moins un caractère spécial",
"numeric_value_check": "Au moins une valeur numérique"
"numeric_value_check": "Au moins une valeur numérique",
"afterRegister": "Inscription réussie. Veuillez attendre l'approbation de l'administrateur pour votre demande."
},
"userLoginPage": {
"title": "Administration Talawa",
"fromPalisadoes": "Une application open source par des bénévoles de la Fondation Palisadoes",
"talawa_portal": "Portail d'administration Talawa",
"login": "Connexion",
"register": "S'inscrire",
"firstName": "Prénom",
"lastName": "Nom de famille",
"email": "E-mail",
"password": "Mot de passe",
"atleast_8_char_long": "Au moins 8 caractères de long",
"Password_and_Confirm_password_mismatches.": "Les mots de passe ne correspondent pas.",
"confirmPassword": "Confirmez le mot de passe",
"forgotPassword": "Mot de passe oublié ?",
"enterEmail": "Entrez l'e-mail",
"enterPassword": "Entrez le mot de passe",
"doNotOwnAnAccount": "Vous n'avez pas de compte ?",
"talawaApiUnavailable": "Le service Talawa-API n'est pas disponible. Est-il en cours d'exécution ? Vérifiez également votre connectivité réseau.",
"captchaError": "Erreur de captcha !",
"Please_check_the_captcha": "Veuillez vérifier le captcha.",
"Something_went_wrong": "Quelque chose s'est mal passé, veuillez réessayer ultérieurement.",
"passwordMismatches": "Les mots de passe ne correspondent pas.",
"fillCorrectly": "Remplissez correctement tous les détails.",
"notAuthorised": "Désolé ! Vous n'êtes pas autorisé !",
"notFound": "Utilisateur non trouvé !",
"successfullyRegistered": "Inscription réussie. Veuillez attendre que votre demande soit approuvée.",
"userLogin": "Connexion utilisateur",
"afterRegister": "Inscription réussie. Veuillez attendre l'approbation de l'administrateur.",
"OR": "OU",
"loading": "Chargement...",
"selectOrg": "Sélectionnez une organisation"
},
"latestEvents": {
"eventCardTitle": "Événements à venir",
Expand Down
37 changes: 36 additions & 1 deletion public/locales/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,42 @@
"lowercase_check": "कम से कम एक छोटा अक्षर",
"uppercase_check": "कम से कम एक बड़ा अक्षर",
"numeric_value_check": "कम से कम एक संख्यात्मक मान",
"special_char_check": "कम से कम एक विशेष पात्र"
"special_char_check": "कम से कम एक विशेष पात्र",
"loading": "लोड हो रहा है...",
"selectOrg": "कोई संगठन चुनें",
"afterRegister": "सफलतापूर्वक पंजीकृत हो गया। कृपया व्यवस्थापक की मंजूरी का इंतजार करें।"
},
"userLoginPage": {
"title": "तलवा व्यवस्थापक",
"fromPalisadoes": "पलिसाडो के स्वयंसेवकों द्वारा एक खुला स्रोत अनुप्रयोग",
"talawa_portal": "तलावा प्रशासन पोर्टल",
"login": "लॉग इन करें",
"register": "पंजीकरण करवाना",
"firstName": "पहला नाम",
"lastName": "उपनाम",
"email": "ईमेल",
"password": "पासवर्ड",
"atleast_8_char_long": "कम से कम 8 कैरेक्टर लंबा",
"Password_and_Confirm_password_mismatches.": "पासवर्ड और पुष्टि पासवर्ड बेमेल।",
"confirmPassword": "पासवर्ड की पुष्टि कीजिये",
"forgotPassword": "पासवर्ड भूल गए ?",
"enterEmail": "ईमेल दर्ज करें",
"enterPassword": "पास वर्ड दर्ज करें",
"doNotOwnAnAccount": "क्या आपके पास खाता नहीं है?",
"talawaApiUnavailable": "तलावा-एपीआई सेवा उपलब्ध नहीं है। क्या यह चल रही है? अपनी नेटवर्क कनेक्टिविटी की भी जाँच करें।",
"captchaError": "कैप्चा त्रुटि!",
"Please_check_the_captcha": "कृपया, कैप्चा जांचें।",
"Something_went_wrong": "कुछ गलत हुआ, कृपया कुछ समय बाद प्रयास करें।",
"passwordMismatches": "पासवर्ड और पुष्टि पासवर्ड मेल नहीं खाते।",
"fillCorrectly": "सभी विवरण सही ढंग से भरें।",
"notAuthorised": "क्षमा करें! आप अधिकृत नहीं हैं!",
"notFound": "उपयोगकर्ता नहीं मिला!",
"successfullyRegistered": "सफलतापूर्वक पंजीकृत। कृपया स्वीकृत होने तक प्रतीक्षा करें।",
"afterRegister": "पंजीकरण सफलतापूर्वक हो गया है। कृपया आपके अनुरोध को स्वीकार करने के लिए व्यवस्थापक की प्रतीक्षा करें।",
"userLogin": "उपयोगकर्ता लॉगिन",
"OR": "या",
"loading": "लोड हो रहा है...",
"selectOrg": "कोई संगठन चुनें"
},
"latestEvents": {
"eventCardTitle": "आगामी घटनाएँ",
Expand Down
37 changes: 36 additions & 1 deletion public/locales/sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,42 @@
"lowercase_check": "Al menos una letra mayuscula",
"uppercase_check": "Al menos una letra minúscula",
"numeric_value_check": "Al menos un valor numérico",
"special_char_check": "Al menos un carácter especial"
"special_char_check": "Al menos un carácter especial",
"loading": "Cargando...",
"selectOrg": "Seleccione una organización",
"afterRegister": "Registro exitoso. Por favor, espere a que el administrador apruebe su solicitud."
},
"userLoginPage": {
"title": "Administrador Talawa",
"fromPalisadoes": "Una aplicación de código abierto de los voluntarios de la Fundación palisados",
"talawa_portal": "Portal De Administración Talawa",
"login": "Acceso",
"register": "Registro",
"firstName": "Primer nombre",
"lastName": "Apellido",
"email": "Correo electrónico",
"password": "Clave",
"atleast_8_char_long": "Al menos 8 caracteres de largo",
"Password_and_Confirm_password_mismatches.": "Contraseña y Confirmar contraseña no coinciden.",
"confirmPassword": "Confirmar contraseña",
"forgotPassword": "Has olvidado tu contraseña ?",
"enterEmail": "ingrese correo electrónico",
"enterPassword": "introducir la contraseña",
"doNotOwnAnAccount": "¿No tienes una cuenta?",
"talawaApiUnavailable": "El servicio Talawa-API no está disponible. ¿Está funcionando? Verifica también la conectividad de tu red.",
"captchaError": "¡Error de captcha!",
"Please_check_the_captcha": "Por favor, revisa el captcha.",
"Something_went_wrong": "Algo salió mal. Inténtalo después de un tiempo",
"passwordMismatches": "Contraseña y Confirmar contraseña no coinciden.",
"fillCorrectly": "Complete todos los detalles correctamente.",
"notAuthorised": "¡Lo siento! ¡No estás autorizado!",
"notFound": "¡Usuario no encontrado!",
"successfullyRegistered": "Registrado con éxito. Espere hasta que sea aprobado",
"userLogin": "Inicio de sesión de usuario",
"afterRegister": "Registrado exitosamente. Espere a que el administrador apruebe su solicitud.",
"OR": "O",
"loading": "Cargando...",
"selectOrg": "Seleccione una organización"
},
"latestEvents": {
"eventCardTitle": "Próximos Eventos",
Expand Down
37 changes: 36 additions & 1 deletion public/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,42 @@
"lowercase_check": "至少一個小寫字母",
"uppercase_check": "至少有一個大寫字母",
"numeric_value_check": "至少一個數值",
"special_char_check": "至少一個特殊字符"
"special_char_check": "至少一個特殊字符",
"loading": "载入中...",
"selectOrg": "选择一个组织",
"afterRegister": "注册成功。请等待管理员批准您的请求"
},
"userLoginPage": {
"title": "塔拉瓦管理員",
"fromPalisadoes": "柵欄 基金会志愿者的开源应用程序",
"talawa_portal": "塔拉瓦管理門戶",
"login": "登錄",
"register": "登記",
"firstName": "",
"lastName": "",
"email": "電子郵件",
"password": "密碼",
"atleast_8_char_long": "至少 8 個字符長",
"Password_and_Confirm_password_mismatches.": "密碼和確認密碼不匹配。",
"confirmPassword": "確認密碼",
"forgotPassword": "忘記密碼 ?",
"enterEmail": "输入电子邮件",
"enterPassword": "输入密码",
"doNotOwnAnAccount": "沒有帳戶嗎?",
"talawaApiUnavailable": "服務不可用。它正在運行嗎?還要檢查您的網絡連接。",
"captchaError": "驗證碼錯誤!",
"Please_check_the_captcha": "請檢查驗證碼。",
"Something_went_wrong": "出了點問題,請稍後再試。",
"passwordMismatches": "密碼和確認密碼不匹配。",
"fillCorrectly": "正確填寫所有細節。",
"notAuthorised": "抱歉!你沒有被授權!",
"notFound": "找不到用戶!",
"successfullyRegistered": "註冊成功,請等待審核通過。",
"userLogin": "用户登录",
"afterRegister": "註冊成功。 請等待管理員批准您的請求。",
"OR": "或者",
"loading": "载入中...",
"selectOrg": "选择一个组织"
},
"latestEvents": {
"eventCardTitle": "即将举行的活动",
Expand Down
2 changes: 1 addition & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1427,8 +1427,8 @@ input UserInput {
email: EmailAddress!
firstName: String!
lastName: String!
organizationUserBelongsToId: ID
password: String!
selectedOrganization : ID!
}

enum UserOrderByInput {
Expand Down
92 changes: 47 additions & 45 deletions src/components/LeftDrawer/LeftDrawer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ const resizeWindow = (width: number): void => {
const propsOrg: InterfaceLeftDrawerProps = {
...props,
};
const propsUsers: InterfaceLeftDrawerProps = {
...props,
hideDrawer: null,
};

const MOCKS = [
{
Expand Down Expand Up @@ -73,6 +69,10 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {
setItem('SuperAdmin', true);
setItem('FirstName', 'John');
setItem('LastName', 'Doe');
setItem('UserImage', '');
setItem('SuperAdmin', true);
setItem('FirstName', 'John');
setItem('LastName', 'Doe');
render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
Expand All @@ -86,6 +86,7 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {
expect(screen.getByText('My Organizations')).toBeInTheDocument();
expect(screen.getByText('Users')).toBeInTheDocument();
expect(screen.getByText('Community Profile')).toBeInTheDocument();
expect(screen.getByText('Community Profile')).toBeInTheDocument();
expect(screen.getByText('Talawa Admin Portal')).toBeInTheDocument();

const orgsBtn = screen.getByTestId(/orgsBtn/i);
Expand All @@ -97,6 +98,7 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {
orgsBtn.className.includes('text-white btn btn-success'),
).toBeTruthy();
expect(rolesBtn.className.includes('text-secondary btn')).toBeTruthy();
expect(rolesBtn.className.includes('text-secondary btn')).toBeTruthy();
expect(
communityProfileBtn.className.includes('text-secondary btn'),
).toBeTruthy();
Expand All @@ -108,11 +110,16 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {
});

test('Testing Drawer when hideDrawer is null', () => {
const tempProps: InterfaceLeftDrawerProps = {
...props,
hideDrawer: false,
};

render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
<I18nextProvider i18n={i18nForTest}>
<LeftDrawer {...propsUsers} />
<LeftDrawer {...tempProps} />
</I18nextProvider>
</BrowserRouter>
</MockedProvider>,
Expand All @@ -123,24 +130,18 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {
...props,
hideDrawer: false,
};
render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
<I18nextProvider i18n={i18nForTest}>
<LeftDrawer {...tempProps} />
</I18nextProvider>
</BrowserRouter>
</MockedProvider>,
);
});

test('Testing Drawer when the screen size is less than or equal to 820px', () => {
const tempProps: InterfaceLeftDrawerProps = {
...props,
hideDrawer: false,
};
resizeWindow(800);
render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
<I18nextProvider i18n={i18nForTest}>
<LeftDrawer {...propsOrg} />
<LeftDrawer {...tempProps} />
</I18nextProvider>
</BrowserRouter>
</MockedProvider>,
Expand All @@ -155,35 +156,36 @@ describe('Testing Left Drawer component for SUPERADMIN', () => {
orgsBtn.className.includes('text-white btn btn-success'),
).toBeTruthy();
});
});

describe('Testing Left Drawer component for ADMIN', () => {
test('Components should be rendered properly', () => {
render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
<I18nextProvider i18n={i18nForTest}>
<LeftDrawer {...propsOrg} />
</I18nextProvider>
</BrowserRouter>
</MockedProvider>,
);

expect(screen.getByText('My Organizations')).toBeInTheDocument();
expect(screen.getByText('Talawa Admin Portal')).toBeInTheDocument();

expect(screen.getAllByText(/admin/i)).toHaveLength(1);

const orgsBtn = screen.getByTestId(/orgsBtn/i);
orgsBtn.click();
expect(
orgsBtn.className.includes('text-white btn btn-success'),
).toBeTruthy();

// These screens arent meant for admins so they should not be present
expect(screen.queryByTestId(/rolesBtn/i)).toBeNull();

userEvent.click(orgsBtn);
expect(global.window.location.pathname).toContain('/orglist');
describe('Testing Left Drawer component for ADMIN', () => {
test('Components should be rendered properly', () => {
render(
<MockedProvider addTypename={false} link={link}>
<BrowserRouter>
<I18nextProvider i18n={i18nForTest}>
<LeftDrawer {...propsOrg} />
</I18nextProvider>
</BrowserRouter>
</MockedProvider>,
);

expect(screen.getByText('My Organizations')).toBeInTheDocument();
expect(screen.getByText('Talawa Admin Portal')).toBeInTheDocument();

expect(screen.getAllByText(/admin/i)).toHaveLength(1);
expect(screen.getAllByText(/admin/i)).toHaveLength(1);

const orgsBtn = screen.getByTestId(/orgsBtn/i);
orgsBtn.click();
expect(
orgsBtn.className.includes('text-white btn btn-success'),
).toBeTruthy();

// These screens arent meant for admins so they should not be present
expect(screen.queryByTestId(/rolesBtn/i)).toBeNull();

userEvent.click(orgsBtn);
expect(global.window.location.pathname).toContain('/orglist');
});
});
});
1 change: 0 additions & 1 deletion src/components/LeftDrawerOrg/LeftDrawerOrg.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@

.leftDrawer .optionList {
height: 100%;
overflow-y: auto;
}

.leftDrawer .optionList button {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
}

@media (max-height: 900px) {
.pageContainer {
padding: 1rem 1.5rem 0 calc(300px + 2rem);
}
.collapseSidebarButton {
height: 30px;
width: calc(300px + 1rem);
Expand Down
Loading

0 comments on commit 3c2314d

Please sign in to comment.