From 66e4137f005f65dbcdf5690663f6706f953a4a99 Mon Sep 17 00:00:00 2001 From: Kshitij Todkar Date: Sun, 7 Jan 2024 18:29:50 +0530 Subject: [PATCH] feat:Removed requests screen from superadmin panel --- public/locales/en.json | 23 - public/locales/fr.json | 22 - public/locales/hi.json | 22 - public/locales/sp.json | 22 - public/locales/zh.json | 22 - src/App.tsx | 2 - src/assets/svgs/requests.svg | 10 - src/components/LeftDrawer/LeftDrawer.test.tsx | 51 -- src/components/LeftDrawer/LeftDrawer.tsx | 24 - src/screens/Requests/Requests.module.css | 95 ---- src/screens/Requests/Requests.test.tsx | 242 --------- src/screens/Requests/Requests.tsx | 475 ------------------ src/screens/Requests/RequestsMocks.ts | 312 ------------ 13 files changed, 1322 deletions(-) delete mode 100644 src/assets/svgs/requests.svg delete mode 100644 src/screens/Requests/Requests.module.css delete mode 100644 src/screens/Requests/Requests.test.tsx delete mode 100644 src/screens/Requests/Requests.tsx delete mode 100644 src/screens/Requests/RequestsMocks.ts diff --git a/public/locales/en.json b/public/locales/en.json index 8abb05c409..c1a6c1a7e2 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -88,7 +88,6 @@ "talawaAdminPortal": "Talawa Admin Portal", "menu": "Menu", "my organizations": "My Organizations", - "requests": "Requests", "users": "Users", "logout": "Logout" }, @@ -192,28 +191,6 @@ "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too.", "cancel": "Cancel" }, - "requests": { - "title": "Talawa Requests", - "searchByName": "Search By Name", - "requests": "Requests", - "name": "Name", - "email": "Email", - "accept": "Accept", - "reject": "Reject", - "enterName": "Enter Name", - "endOfResults": "End of results", - "loadingRequests": "Loading Requests...", - "noRequestFound": "No Request Found", - "sort": "Sort", - "filter": "Filter", - "Oldest": "Oldest First", - "Latest": "Latest First", - "noOrgError": "Organizations not found, please create an organization through dashboard", - "userApproved": "User Approved", - "userRejected": "User Rejected", - "noResultsFoundFor": "No results found for ", - "talawaApiUnavailable": "Talawa-API service is unavailable. Is it running? Check your network connectivity too." - }, "dashboard": { "title": "Dashboard", "location": "Location", diff --git a/public/locales/fr.json b/public/locales/fr.json index 7d60cda1fb..2adb370627 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -88,7 +88,6 @@ "talawaAdminPortal": "Portail d'administration Talawa", "menu": "Menu", "my organizations": "Mes Organisations", - "requests": "Demandes", "users": "Utilisateurs", "logout": "Déconnexion" }, @@ -187,27 +186,6 @@ "talawaApiUnavailable": "Le service Talawa-API n'est pas disponible. Est-il en cours d'exécution ? Vérifiez également votre connectivité réseau.", "cancel": "Annuler" }, - "requests": { - "title": "Demandes Talawa", - "searchByName": "Recherche par nom", - "requests": "Demandes", - "name": "Nom", - "email": "E-mail", - "accept": "Accepter", - "reject": "Rejeter", - "enterName": "Entrez le nom", - "endOfResults": "Fin des résultats", - "loadingRequests": "Chargement des demandes...", - "noRequestFound": "Aucune demande trouvée", - "sort": "Trier", - "filter": "Filtre", - "Oldest": "Les plus anciennes d'abord", - "Latest": "Les plus récentes d'abord", - "userApproved": "Approuvé par l'utilisateur", - "userRejected": "Utilisateur rejeté", - "noResultsFoundFor": "Aucun résultat trouvé pour ", - "talawaApiUnavailable": "Le service Talawa-API n'est pas disponible. Est-il en cours d'exécution ? Vérifiez également votre connectivité réseau." - }, "dashboard": { "title": "Tableau de bord", "location": "Emplacement", diff --git a/public/locales/hi.json b/public/locales/hi.json index f23ed585f2..b44fc76e59 100644 --- a/public/locales/hi.json +++ b/public/locales/hi.json @@ -88,7 +88,6 @@ "talawaAdminPortal": "तलावा व्यवस्थापक पोर्टल", "menu": "मेन्यू", "my organizations": "मेरे संगठन", - "requests": "अनुरोध", "users": "उपयोगकर्ता", "logout": "लॉग आउट" }, @@ -186,27 +185,6 @@ "talawaApiUnavailable": "तलवा-एपीआई सेवा उपलब्ध नहीं है। क्या यह चल रहा है? अपनी नेटवर्क कनेक्टिविटी भी जांचें।", "cancel": "रद्द करें" }, - "requests": { - "title": "तलवा अनुरोध", - "searchByName": "नाम से खोजें", - "requests": "अनुरोध", - "name": "नाम", - "email": "ईमेल", - "accept": "स्वीकार करना", - "reject": "अस्वीकार", - "enterName": "नाम दर्ज करें", - "endOfResults": "परिणामों का अंत", - "loadingRequests": "अनुरोध लोड हो रहा है ...", - "noRequestFound": "कोई अनुरोध नहीं मिला।", - "sort": "छांटें", - "filter": "फ़िल्टर", - "Oldest": "सबसे पुराना पहले", - "Latest": "सबसे नवीनतम पहले", - "userApproved": "उपयोगकर्ता स्वीकृत", - "userRejected": "उपयोगकर्ता अस्वीकृत", - "noResultsFoundFor": "के लिए कोई परिणाम नहीं मिला ", - "talawaApiUnavailable": "तलवा-एपीआई सेवा उपलब्ध नहीं है। क्या यह चल रहा है? अपनी नेटवर्क कनेक्टिविटी भी जांचें।" - }, "dashboard": { "title": "डैशबोर्ड", "location": "स्थान", diff --git a/public/locales/sp.json b/public/locales/sp.json index b36852e85d..5f10f3c6be 100644 --- a/public/locales/sp.json +++ b/public/locales/sp.json @@ -88,7 +88,6 @@ "talawaAdminPortal": "Portal de administración de Talawa", "menu": "Menú", "my organizations": "Mis Organizaciones", - "requests": "Solicitudes", "users": "Usuarios", "logout": "Cerrar sesión" }, @@ -186,27 +185,6 @@ "talawaApiUnavailable": "El servicio Talawa-API no está disponible. ¿Está funcionando? Compruebe también la conectividad de su red.", "cancel": "Cancelar" }, - "requests": { - "title": "Solicitudes Talawa", - "searchByName": "Buscar por nombre", - "requests": "Peticiones", - "name": "Nombre", - "email": "Correo electrónico", - "accept": "Aceptar", - "reject": "Rechazar", - "enterName": "Ingrese su nombre", - "endOfResults": "Fin de los resultados", - "loadingRequests": "Cargando solicitudes ...", - "noRequestFound": "No se encontró ninguna solicitud.", - "sort": "Ordenar", - "filter": "Filtrar", - "Oldest": "Más Antiguas Primero", - "Latest": "Más Recientes Primero", - "userApproved": "Aprobado por el usuario", - "userRejected": "Usuario rechazado", - "noResultsFoundFor": "No se encontraron resultados para ", - "talawaApiUnavailable": "El servicio Talawa-API no está disponible. ¿Está funcionando? Compruebe también la conectividad de su red." - }, "dashboard": { "title": "Panel de", "location": "Ubicación", diff --git a/public/locales/zh.json b/public/locales/zh.json index 60f0ec3ed2..68d43b4248 100644 --- a/public/locales/zh.json +++ b/public/locales/zh.json @@ -88,7 +88,6 @@ "talawaAdminPortal": "塔拉瓦管理门户", "menu": "菜单", "my organizations": "我的组织", - "requests": "请求", "users": "用户", "logout": "退出登录" }, @@ -186,27 +185,6 @@ "talawaApiUnavailable": "服務不可用。它在運行嗎?還要檢查您的網絡連接。", "cancel": "取消" }, - "requests": { - "title": "塔拉瓦請求", - "searchByName": "按名稱搜索", - "requests": "要求", - "name": "姓名", - "email": "電子郵件", - "accept": "接受", - "reject": "拒絕", - "enterName": "输入名字", - "endOfResults": "結果結束", - "loadingRequests": "正在加載請求...", - "noRequestFound": "找不到請求。", - "sort": "排序", - "filter": "過濾", - "Oldest": "最旧的优先", - "Latest": "最新的优先", - "userApproved": "用戶批准", - "userRejected": "用戶被拒絕", - "noResultsFoundFor": "未找到结果 ", - "talawaApiUnavailable": "服務不可用。它在運行嗎?還要檢查您的網絡連接。" - }, "dashboard": { "title": "儀表板", "location": "地點", diff --git a/src/App.tsx b/src/App.tsx index 3daf57b09c..9ab6b07791 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -17,7 +17,6 @@ import PageNotFound from 'screens/PageNotFound/PageNotFound'; import AddOnStore from 'components/AddOn/core/AddOnStore/AddOnStore'; import ForgotPassword from 'screens/ForgotPassword/ForgotPassword'; import Users from 'screens/Users/Users'; -import Requests from 'screens/Requests/Requests'; import BlockUser from 'screens/BlockUser/BlockUser'; import EventDashboard from 'screens/EventDashboard/EventDashboard'; import MemberDetail from 'screens/MemberDetail/MemberDetail'; @@ -111,7 +110,6 @@ function app(): JSX.Element { - {extraRoutes} diff --git a/src/assets/svgs/requests.svg b/src/assets/svgs/requests.svg deleted file mode 100644 index 8873bce1d7..0000000000 --- a/src/assets/svgs/requests.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/components/LeftDrawer/LeftDrawer.test.tsx b/src/components/LeftDrawer/LeftDrawer.test.tsx index dc370da8cc..c0ae94a010 100644 --- a/src/components/LeftDrawer/LeftDrawer.test.tsx +++ b/src/components/LeftDrawer/LeftDrawer.test.tsx @@ -21,11 +21,6 @@ const propsOrg: InterfaceLeftDrawerProps = { ...props, screenName: 'My Organizations', }; -const propsReq: InterfaceLeftDrawerProps = { - ...props, - hideDrawer: false, - screenName: 'Requests', -}; const propsUsers: InterfaceLeftDrawerProps = { ...props, hideDrawer: null, @@ -80,7 +75,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { ); expect(screen.getByText('My Organizations')).toBeInTheDocument(); - expect(screen.getByText('Requests')).toBeInTheDocument(); expect(screen.getByText('Users')).toBeInTheDocument(); expect(screen.getByText('Talawa Admin Portal')).toBeInTheDocument(); @@ -89,15 +83,11 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { expect(screen.getByAltText(/dummy picture/i)).toBeInTheDocument(); const orgsBtn = screen.getByTestId(/orgsBtn/i); - const requestsBtn = screen.getByTestId(/requestsBtn/i); const rolesBtn = screen.getByTestId(/rolesBtn/i); expect( orgsBtn.className.includes('text-white btn btn-success') ).toBeTruthy(); - expect( - requestsBtn.className.includes('text-secondary btn btn-light') - ).toBeTruthy(); expect( rolesBtn.className.includes('text-secondary btn btn-light') ).toBeTruthy(); @@ -110,25 +100,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { expect(global.window.location.pathname).toContain('/users'); }); - test('Testing in requests screen', () => { - localStorage.setItem('UserType', 'SUPERADMIN'); - render( - - - - - - - - ); - - const orgsBtn = screen.getByTestId(/orgsBtn/i); - - // Send to organizations screen - userEvent.click(orgsBtn); - expect(global.window.location.pathname).toContain('/orglist'); - }); - test('Testing in roles screen', () => { localStorage.setItem('UserType', 'SUPERADMIN'); render( @@ -142,22 +113,14 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { ); const orgsBtn = screen.getByTestId(/orgsBtn/i); - const requestsBtn = screen.getByTestId(/requestsBtn/i); const rolesBtn = screen.getByTestId(/rolesBtn/i); expect( orgsBtn.className.includes('text-secondary btn btn-light') ).toBeTruthy(); - expect( - requestsBtn.className.includes('text-secondary btn btn-light') - ).toBeTruthy(); expect( rolesBtn.className.includes('text-white btn btn-success') ).toBeTruthy(); - - // Send to requests screen - userEvent.click(requestsBtn); - expect(global.window.location.pathname).toContain('/requests'); }); test('Testing Drawer open close functionality', () => { @@ -188,19 +151,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { ); }); - test('Testing Drawer when hideDrawer is true', () => { - localStorage.setItem('UserType', 'SUPERADMIN'); - render( - - - - - - - - ); - }); - test('Testing logout functionality', async () => { localStorage.setItem('UserType', 'SUPERADMIN'); render( @@ -246,7 +196,6 @@ describe('Testing Left Drawer component for ADMIN', () => { // These screens arent meant for admins so they should not be present expect(screen.queryByTestId(/rolesBtn/i)).toBeNull(); - expect(screen.queryByTestId(/requestsBtn/i)).toBeNull(); // Coming soon userEvent.click(screen.getByTestId(/profileBtn/i)); diff --git a/src/components/LeftDrawer/LeftDrawer.tsx b/src/components/LeftDrawer/LeftDrawer.tsx index 94cbbf0367..1a4343d342 100644 --- a/src/components/LeftDrawer/LeftDrawer.tsx +++ b/src/components/LeftDrawer/LeftDrawer.tsx @@ -5,7 +5,6 @@ import { useHistory } from 'react-router-dom'; import { ReactComponent as AngleRightIcon } from 'assets/svgs/angleRight.svg'; import { ReactComponent as LogoutIcon } from 'assets/svgs/logout.svg'; import { ReactComponent as OrganizationsIcon } from 'assets/svgs/organizations.svg'; -import { ReactComponent as RequestsIcon } from 'assets/svgs/requests.svg'; import { ReactComponent as RolesIcon } from 'assets/svgs/roles.svg'; import { ReactComponent as TalawaLogo } from 'assets/svgs/talawa.svg'; import styles from './LeftDrawer.module.css'; @@ -89,29 +88,6 @@ const leftDrawer = ({ {t('my organizations')} - {userType === 'SUPERADMIN' && ( - - )} {userType === 'SUPERADMIN' && ( - - -
-
- - -
-
- - {isLoading == false && - usersData?.users.length === 0 && - searchByName.length > 0 ? ( -
-

- {t('noResultsFoundFor')} "{searchByName}" -

-
- ) : isLoading == false && usersData?.users.length === 0 ? ( -
-

{t('noRequestFound')}

-
- ) : isLoading ? ( - - ) : ( - - } - hasMore={hasMore} - className={styles.listBox} - data-testid="organizations-list" - endMessage={ -
-
{t('endOfResults')}
-
- } - > - - - - {headerTitles.map((title: string, index: number) => { - return ( - - ); - })} - - - - {displayedUsers && - displayedUsers.length > 0 && - displayedUsers.map((user, index) => { - return ( - - - - - - - - - ); - })} - -
- {title} -
{index + 1}{`${user.firstName} ${user.lastName}`}{user.email} - - - - {dayjs(user.createdAt).fromNow()}
-
- )} - - - ); -}; - -export default Requests; diff --git a/src/screens/Requests/RequestsMocks.ts b/src/screens/Requests/RequestsMocks.ts deleted file mode 100644 index ec3444b3b5..0000000000 --- a/src/screens/Requests/RequestsMocks.ts +++ /dev/null @@ -1,312 +0,0 @@ -import { - ACCEPT_ADMIN_MUTATION, - REJECT_ADMIN_MUTATION, -} from 'GraphQl/Mutations/mutations'; -import { - ORGANIZATION_CONNECTION_LIST, - USER_LIST_REQUEST, - USER_ORGANIZATION_LIST, -} from 'GraphQl/Queries/Queries'; - -export const MOCKS = [ - { - request: { - query: USER_ORGANIZATION_LIST, - variables: { id: localStorage.getItem('id') }, - }, - result: { - data: { - user: { - _id: '123', - userType: 'SUPERADMIN', - firstName: 'John', - lastName: 'Doe', - image: '', - email: 'John_Does_Palasidoes@gmail.com', - adminFor: { - _id: 1, - name: 'Akatsuki', - image: '', - }, - }, - }, - }, - }, - { - request: { - query: USER_LIST_REQUEST, - variables: { - adminApproved: false, - first: 12, - firstName_contains: '', - lastName_contains: '', - skip: 0, - userType: 'ADMIN', - }, - notifyOnNetworkStatusChange: true, - }, - result: { - data: { - users: [ - { - _id: '123', - firstName: 'John', - lastName: 'Doe', - image: 'dummyImage', - email: 'johndoe@gmail.com', - userType: 'SUPERADMIN', - adminApproved: true, - createdAt: '20/06/2022', - organizationsBlockedBy: [ - { - _id: '256', - name: 'ABC', - }, - ], - joinedOrganizations: [ - { - __typename: 'Organization', - _id: '6401ff65ce8e8406b8f07af1', - }, - ], - }, - { - _id: '456', - firstName: 'Sam', - lastName: 'Smith', - image: 'dummyImage', - email: 'samsmith@gmail.com', - userType: 'ADMIN', - adminApproved: false, - createdAt: '20/06/2022', - organizationsBlockedBy: [ - { - _id: '256', - name: 'ABC', - }, - ], - joinedOrganizations: [ - { - __typename: 'Organization', - _id: '6401ff65ce8e8406b8f07af2', - }, - ], - }, - { - _id: '789', - firstName: 'Peter', - lastName: 'Parker', - image: 'dummyImage', - email: 'peterparker@gmail.com', - userType: 'USER', - adminApproved: true, - createdAt: '20/06/2022', - organizationsBlockedBy: [ - { - _id: '256', - name: 'ABC', - }, - ], - joinedOrganizations: [ - { - __typename: 'Organization', - _id: '6401ff65ce8e8406b8f07af3', - }, - ], - }, - ], - }, - }, - }, - { - request: { - query: ACCEPT_ADMIN_MUTATION, - variables: { - id: '123', - userType: 'ADMIN', - }, - }, - result: { - data: { - acceptAdmin: true, - }, - }, - }, - { - request: { - query: REJECT_ADMIN_MUTATION, - variables: { - id: '123', - userType: 'ADMIN', - }, - }, - result: { - data: { - rejectAdmin: true, - }, - }, - }, -]; - -export const EMPTY_REQUEST_MOCKS = [ - { - request: { - query: USER_ORGANIZATION_LIST, - variables: { id: localStorage.getItem('id') }, - }, - result: { - data: { - user: { - _id: '123', - userType: 'SUPERADMIN', - firstName: 'John', - lastName: 'Doe', - image: '', - email: 'John_Does_Palasidoes@gmail.com', - adminFor: { - _id: 1, - name: 'Akatsuki', - image: '', - }, - }, - }, - }, - }, - { - request: { - query: USER_LIST_REQUEST, - variables: { - adminApproved: false, - first: 12, - firstName_contains: '', - lastName_contains: '', - skip: 0, - userType: 'ADMIN', - }, - notifyOnNetworkStatusChange: true, - }, - result: { - data: { - users: [], - }, - }, - }, - { - request: { - query: USER_LIST_REQUEST, - variables: { - adminApproved: false, - first: 12, - firstName_contains: 'l', - lastName_contains: '', - skip: 0, - userType: 'ADMIN', - }, - notifyOnNetworkStatusChange: true, - }, - result: { - data: { - users: [], - }, - }, - }, - { - request: { - query: ACCEPT_ADMIN_MUTATION, - variables: { - id: '123', - userType: 'ADMIN', - }, - }, - result: { - data: { - acceptAdmin: true, - }, - }, - }, - { - request: { - query: REJECT_ADMIN_MUTATION, - variables: { - id: '123', - userType: 'ADMIN', - }, - }, - result: { - data: { - rejectAdmin: true, - }, - }, - }, -]; - -export const EMPTY_ORG_MOCKS = [ - { - request: { - query: ACCEPT_ADMIN_MUTATION, - variables: { - id: '123', - userType: 'ADMIN', - }, - }, - result: { - data: undefined, - }, - }, - { - request: { - query: REJECT_ADMIN_MUTATION, - variables: { - id: '123', - userType: 'ADMIN', - }, - }, - result: { - data: undefined, - }, - }, - { - request: { - query: ORGANIZATION_CONNECTION_LIST, - }, - result: { - data: { - organizationsConnection: [], - }, - }, - }, -]; - -export const ORG_LIST_MOCK = [ - ...MOCKS, - { - request: { - query: ORGANIZATION_CONNECTION_LIST, - }, - result: { - data: { - organizationsConnection: [ - { - _id: 1, - image: '', - name: 'Akatsuki', - creator: { - firstName: 'John', - lastName: 'Doe', - }, - admins: [ - { - _id: '123', - }, - ], - members: { - _id: '234', - }, - createdAt: '02/02/2022', - location: 'Washington DC', - }, - ], - }, - }, - }, -];