From c284e071422e2620afe38ee0a1720bbd02c0548c Mon Sep 17 00:00:00 2001 From: Glen Dsouza Date: Sat, 2 Mar 2024 14:55:43 +0530 Subject: [PATCH] Fixes Organization Not Found in Left Drawer (#1592) * Fixed Organization Not Found in Left Drawer * Fix State update when MemberDetail is unmounted * Shifted UseEffect to be called from top level function * Shift useEffect to be called form top-level * Add Test Coverage for images in MemberDetail * Fixed Linting issues & removed unrelated code to current PR from LoginPage * prettier update * Fix improper testcase in MemberDetail.test * State Update on Unmount Resolved in Testing * Added dicebear url constants * Revert changes in Readme & package-lock.json * Added tests for LeftDrawer & MemberDetail for full coverage * Refactor OrganizationScreen & SuperAdminScreen * Remove commented line * Modified tests in OrganizationScreen & SuperAdminScreen * Revert README.md --------- Co-authored-by: Peter Harrison <16875803+palisadoes@users.noreply.github.com> --- .../LeftDrawer/LeftDrawer.module.css | 2 +- src/components/LeftDrawer/LeftDrawer.test.tsx | 11 +- src/components/LeftDrawer/LeftDrawer.tsx | 146 +++--- .../LeftDrawerOrg/LeftDrawerOrg.module.css | 2 +- .../LeftDrawerOrg/LeftDrawerOrg.test.tsx | 55 ++- .../LeftDrawerOrg/LeftDrawerOrg.tsx | 255 +++++------ .../OrganizationScreen.test.tsx | 44 +- .../OrganizationScreen/OrganizationScreen.tsx | 46 +- .../SuperAdminScreen.test.tsx | 44 +- .../SuperAdminScreen/SuperAdminScreen.tsx | 46 +- .../MemberDetail/MemberDetail.test.tsx | 71 ++- src/screens/MemberDetail/MemberDetail.tsx | 432 +++++++++--------- 12 files changed, 616 insertions(+), 538 deletions(-) diff --git a/src/components/LeftDrawer/LeftDrawer.module.css b/src/components/LeftDrawer/LeftDrawer.module.css index b52a1fae2b..27130a4e3b 100644 --- a/src/components/LeftDrawer/LeftDrawer.module.css +++ b/src/components/LeftDrawer/LeftDrawer.module.css @@ -60,9 +60,9 @@ .leftDrawer .profileContainer { border: none; width: 100%; + padding: 2.1rem 0.5rem; height: 52px; border-radius: 8px; - background-color: var(--bs-white); display: flex; align-items: center; } diff --git a/src/components/LeftDrawer/LeftDrawer.test.tsx b/src/components/LeftDrawer/LeftDrawer.test.tsx index 85f6a83b27..40efc0186b 100644 --- a/src/components/LeftDrawer/LeftDrawer.test.tsx +++ b/src/components/LeftDrawer/LeftDrawer.test.tsx @@ -64,9 +64,11 @@ afterEach(() => { }); describe('Testing Left Drawer component for SUPERADMIN', () => { + beforeEach(() => { + setItem('UserType', 'SUPERADMIN'); + }); test('Component should be rendered properly', () => { setItem('UserImage', ''); - setItem('UserType', 'SUPERADMIN'); render( @@ -104,7 +106,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { }); test('Testing in roles screen', () => { - setItem('UserType', 'SUPERADMIN'); render( @@ -127,7 +128,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { }); test('Testing Drawer when hideDrawer is null', () => { - setItem('UserType', 'SUPERADMIN'); render( @@ -140,7 +140,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { }); test('Testing logout functionality', async () => { - setItem('UserType', 'SUPERADMIN'); render( @@ -157,8 +156,10 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { }); describe('Testing Left Drawer component for ADMIN', () => { - test('Components should be rendered properly', () => { + beforeEach(() => { setItem('UserType', 'ADMIN'); + }); + test('Components should be rendered properly', () => { render( diff --git a/src/components/LeftDrawer/LeftDrawer.tsx b/src/components/LeftDrawer/LeftDrawer.tsx index 51e51f61f5..eaef30008c 100644 --- a/src/components/LeftDrawer/LeftDrawer.tsx +++ b/src/components/LeftDrawer/LeftDrawer.tsx @@ -1,7 +1,7 @@ import React from 'react'; import Button from 'react-bootstrap/Button'; import { useTranslation } from 'react-i18next'; -import { useHistory } from 'react-router-dom'; +import { useHistory, Link } 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'; @@ -42,75 +42,77 @@ const leftDrawer = ({ }; return ( - <> -
- -

{t('talawaAdminPortal')}

-
{t('menu')}
-
+
+ +

{t('talawaAdminPortal')}

+
{t('menu')}
+
+ + {userType === 'SUPERADMIN' && ( - {userType === 'SUPERADMIN' && ( - - )} -
-
- - - -
+ + +
- +
); }; diff --git a/src/components/LeftDrawerOrg/LeftDrawerOrg.module.css b/src/components/LeftDrawerOrg/LeftDrawerOrg.module.css index aa04d88a02..c169189422 100644 --- a/src/components/LeftDrawerOrg/LeftDrawerOrg.module.css +++ b/src/components/LeftDrawerOrg/LeftDrawerOrg.module.css @@ -87,9 +87,9 @@ border: none; width: 100%; margin-top: 5rem; + padding: 2.1rem 0.5rem; height: 52px; border-radius: 8px; - background-color: var(--bs-white); display: flex; align-items: center; } diff --git a/src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx b/src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx index 0ebf3cc42c..0d0efe11d3 100644 --- a/src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx +++ b/src/components/LeftDrawerOrg/LeftDrawerOrg.test.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { render, screen } from '@testing-library/react'; +import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import 'jest-localstorage-mock'; import { I18nextProvider } from 'react-i18next'; @@ -71,7 +71,11 @@ const MOCKS = [ request: { query: REVOKE_REFRESH_TOKEN, }, - result: {}, + result: { + data: { + revokeRefreshTokenForUser: true, + }, + }, }, { request: { @@ -196,6 +200,7 @@ const MOCKS_WITH_IMAGE = [ }, }, ]; + const MOCKS_EMPTY = [ { request: { @@ -254,10 +259,39 @@ const link = new StaticMockLink(MOCKS, true); const linkImage = new StaticMockLink(MOCKS_WITH_IMAGE, true); const linkEmpty = new StaticMockLink(MOCKS_EMPTY, true); -describe('Testing Left Drawer component for SUPERADMIN', () => { +describe('Testing LeftDrawerOrg component for SUPERADMIN', () => { + beforeEach(() => { + setItem('UserType', 'SUPERADMIN'); + }); + + test('Testing Profile button & its styling when screenName is Profile', async () => { + render( + + + + + + + + + , + ); + await wait(); + + const profileButton = screen.getByTestId('profileBtn'); + const userTypeSpan = screen.getByText(/Superadmin/i); + + expect(profileButton).toHaveClass('btn-success'); + expect(profileButton).not.toHaveClass('btn-light'); + expect(userTypeSpan).toHaveClass('text-white'); + }); + test('Component should be rendered properly', async () => { setItem('UserImage', ''); - setItem('UserType', 'SUPERADMIN'); render( @@ -279,7 +313,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { }); test('Testing Profile Page & Organization Detail Modal', async () => { - setItem('UserType', 'SUPERADMIN'); render( @@ -297,7 +330,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { }); test('Testing Menu Buttons', async () => { - setItem('UserType', 'SUPERADMIN'); render( @@ -315,7 +347,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { }); test('Testing when image is present for Organization', async () => { - setItem('UserType', 'SUPERADMIN'); render( @@ -331,7 +362,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { }); test('Testing when Organization does not exists', async () => { - setItem('UserType', 'SUPERADMIN'); render( @@ -350,7 +380,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { }); test('Testing Drawer when hideDrawer is null', () => { - setItem('UserType', 'SUPERADMIN'); render( @@ -365,7 +394,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { }); test('Testing Drawer when hideDrawer is true', () => { - setItem('UserType', 'SUPERADMIN'); render( @@ -380,7 +408,6 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { }); test('Testing logout functionality', async () => { - setItem('UserType', 'SUPERADMIN'); render( @@ -393,7 +420,9 @@ describe('Testing Left Drawer component for SUPERADMIN', () => { , ); userEvent.click(screen.getByTestId('logoutBtn')); - expect(localStorage.clear).toHaveBeenCalled(); - expect(global.window.location.pathname).toBe('/'); + await waitFor(() => { + expect(localStorage.clear).toHaveBeenCalled(); + expect(global.window.location.pathname).toBe('/'); + }); }); }); diff --git a/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx b/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx index 60b5c44871..c9fa021987 100644 --- a/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx +++ b/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx @@ -3,10 +3,10 @@ import { WarningAmberOutlined } from '@mui/icons-material'; import { ORGANIZATIONS_LIST } from 'GraphQl/Queries/Queries'; import CollapsibleDropdown from 'components/CollapsibleDropdown/CollapsibleDropdown'; import IconComponent from 'components/IconComponent/IconComponent'; -import React, { useEffect, useState } from 'react'; +import React from 'react'; import Button from 'react-bootstrap/Button'; import { useTranslation } from 'react-i18next'; -import { useHistory } from 'react-router-dom'; +import { useHistory, Link } from 'react-router-dom'; import type { TargetsType } from 'state/reducers/routesReducer'; import type { InterfaceQueryOrganizationsListObject } from 'utils/interfaces'; import { ReactComponent as AngleRightIcon } from 'assets/svgs/angleRight.svg'; @@ -32,8 +32,7 @@ const leftDrawerOrg = ({ hideDrawer, }: InterfaceLeftDrawerProps): JSX.Element => { const { t } = useTranslation('translation', { keyPrefix: 'leftDrawerOrg' }); - const [organization, setOrganization] = - useState(); + const { data, loading, @@ -46,6 +45,7 @@ const leftDrawerOrg = ({ variables: { id: orgId }, }); + const organization = data?.organizations[0]; const [revokeRefreshToken] = useMutation(REVOKE_REFRESH_TOKEN); const { getItem } = useLocalStorage(); @@ -57,17 +57,6 @@ const leftDrawerOrg = ({ const userId = getItem('id'); const history = useHistory(); - // Set organization data - useEffect(() => { - let isMounted = true; - if (data && isMounted) { - setOrganization(data?.organizations[0]); - } - return () => { - isMounted = false; - }; - }, [data]); - const logout = (): void => { revokeRefreshToken(); localStorage.clear(); @@ -75,114 +64,116 @@ const leftDrawerOrg = ({ }; return ( - <> -
- {/* Branding Section */} -
- - {t('talawaAdminPortal')} -
+
+ {/* Branding Section */} +
+ + {t('talawaAdminPortal')} +
- {/* Organization Section */} -
- {loading ? ( - <> - - - ) : ( - - )} -
+ + ) : ( + + )} +
- {/* Options List */} -
-
{t('menu')}
- {targets.map(({ name, url }, index) => { - return url ? ( - - ) : ( - - ); - })} -
+ {/* Options List */} +
+
{t('menu')}
+ {targets.map(({ name, url }, index) => { + return url ? ( + + ) : ( + + ); + })} +
- {/* Profile Section & Logout Btn */} -
- - -
+ +
- +
); }; diff --git a/src/components/OrganizationScreen/OrganizationScreen.test.tsx b/src/components/OrganizationScreen/OrganizationScreen.test.tsx index ce19b8c91b..d0931e7bae 100644 --- a/src/components/OrganizationScreen/OrganizationScreen.test.tsx +++ b/src/components/OrganizationScreen/OrganizationScreen.test.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { MockedProvider } from '@apollo/react-testing'; -import { fireEvent, render, screen, waitFor } from '@testing-library/react'; +import { fireEvent, render, screen } from '@testing-library/react'; import { I18nextProvider } from 'react-i18next'; import 'jest-location-mock'; import { Provider } from 'react-redux'; @@ -54,6 +54,15 @@ const MOCKS = [ ]; const link = new StaticMockLink(MOCKS, true); +const resizeWindow = (width: number): void => { + window.innerWidth = width; + fireEvent(window, new Event('resize')); +}; + +const clickToggleMenuBtn = (toggleButton: HTMLElement): void => { + fireEvent.click(toggleButton); +}; + describe('Testing LeftDrawer in OrganizationScreen', () => { test('Testing LeftDrawer in page functionality', async () => { setItem('UserType', 'SUPERADMIN'); @@ -69,31 +78,20 @@ describe('Testing LeftDrawer in OrganizationScreen', () => {
, ); - // Resize window to trigger handleResize - window.innerWidth = 800; // Set a width less than or equal to 820 - fireEvent(window, new Event('resize')); - - await waitFor(() => { - fireEvent.click(screen.getByTestId('openMenu') as HTMLElement); - }); - - // sets hideDrawer to true - await waitFor(() => { - fireEvent.click(screen.getByTestId('menuBtn') as HTMLElement); - }); + const toggleButton = screen.getByTestId('toggleMenuBtn') as HTMLElement; + const icon = toggleButton.querySelector('i'); + // Resize window to a smaller width + resizeWindow(800); + clickToggleMenuBtn(toggleButton); + expect(icon).toHaveClass('fa fa-angle-double-right'); // Resize window back to a larger width - window.innerWidth = 1000; // Set a larger width - fireEvent(window, new Event('resize')); - // sets hideDrawer to false - await waitFor(() => { - fireEvent.click(screen.getByTestId('openMenu') as HTMLElement); - }); + resizeWindow(1000); + clickToggleMenuBtn(toggleButton); + expect(icon).toHaveClass('fa fa-angle-double-left'); - // sets hideDrawer to true - await waitFor(() => { - fireEvent.click(screen.getByTestId('menuBtn') as HTMLElement); - }); + clickToggleMenuBtn(toggleButton); + expect(icon).toHaveClass('fa fa-angle-double-right'); }); }); diff --git a/src/components/OrganizationScreen/OrganizationScreen.tsx b/src/components/OrganizationScreen/OrganizationScreen.tsx index fcdf0ccd99..23c933f8e0 100644 --- a/src/components/OrganizationScreen/OrganizationScreen.tsx +++ b/src/components/OrganizationScreen/OrganizationScreen.tsx @@ -25,41 +25,39 @@ const organizationScreen = ({ const { targets, configUrl } = appRoutes; const handleResize = (): void => { - if (window.innerWidth <= 820) { - setHideDrawer(!hideDrawer); + if (window.innerWidth <= 820 && !hideDrawer) { + setHideDrawer(true); } }; + + const toggleDrawer = (): void => { + setHideDrawer(!hideDrawer); + }; + useEffect(() => { handleResize(); window.addEventListener('resize', handleResize); return () => { window.removeEventListener('resize', handleResize); }; - }, []); + }, [hideDrawer]); return ( <> - {hideDrawer ? ( - - ) : ( - - )} +
Testing ...
, }; +const resizeWindow = (width: number): void => { + window.innerWidth = width; + fireEvent(window, new Event('resize')); +}; + +const clickToggleMenuBtn = (toggleButton: HTMLElement): void => { + fireEvent.click(toggleButton); +}; + describe('Testing LeftDrawer in SuperAdminScreen', () => { test('Testing LeftDrawer in page functionality', async () => { setItem('UserType', 'SUPERADMIN'); @@ -35,31 +44,20 @@ describe('Testing LeftDrawer in SuperAdminScreen', () => {
, ); - // Resize window to trigger handleResize - window.innerWidth = 800; // Set a width less than or equal to 820 - fireEvent(window, new Event('resize')); - - await waitFor(() => { - fireEvent.click(screen.getByTestId('openMenu') as HTMLElement); - }); + const toggleButton = screen.getByTestId('toggleMenuBtn') as HTMLElement; + const icon = toggleButton.querySelector('i'); - // sets hideDrawer to true - await waitFor(() => { - fireEvent.click(screen.getByTestId('menuBtn') as HTMLElement); - }); + // Resize window to a smaller width + resizeWindow(800); + clickToggleMenuBtn(toggleButton); + expect(icon).toHaveClass('fa fa-angle-double-right'); // Resize window back to a larger width - window.innerWidth = 1000; // Set a larger width - fireEvent(window, new Event('resize')); - - // sets hideDrawer to false - await waitFor(() => { - fireEvent.click(screen.getByTestId('openMenu') as HTMLElement); - }); + resizeWindow(1000); + clickToggleMenuBtn(toggleButton); + expect(icon).toHaveClass('fa fa-angle-double-left'); - // sets hideDrawer to true - await waitFor(() => { - fireEvent.click(screen.getByTestId('menuBtn') as HTMLElement); - }); + clickToggleMenuBtn(toggleButton); + expect(icon).toHaveClass('fa fa-angle-double-right'); }); }); diff --git a/src/components/SuperAdminScreen/SuperAdminScreen.tsx b/src/components/SuperAdminScreen/SuperAdminScreen.tsx index 989f1eecfa..9aeb10bec7 100644 --- a/src/components/SuperAdminScreen/SuperAdminScreen.tsx +++ b/src/components/SuperAdminScreen/SuperAdminScreen.tsx @@ -16,41 +16,39 @@ const superAdminScreen = ({ const [hideDrawer, setHideDrawer] = useState(null); const handleResize = (): void => { - if (window.innerWidth <= 820) { - setHideDrawer(!hideDrawer); + if (window.innerWidth <= 820 && !hideDrawer) { + setHideDrawer(true); } }; + + const toggleDrawer = (): void => { + setHideDrawer(!hideDrawer); + }; + useEffect(() => { handleResize(); window.addEventListener('resize', handleResize); return () => { window.removeEventListener('resize', handleResize); }; - }, []); + }, [hideDrawer]); return ( <> - {hideDrawer ? ( - - ) : ( - - )} + { test('should render the elements', async () => { const props = { id: 'rishav-jha-mech', + from: 'orglist', }; render( @@ -218,6 +219,7 @@ describe('MemberDetail', () => { test('Should display dicebear image if image is null', async () => { const props = { id: 'rishav-jha-mech', + from: 'orglist', }; render( @@ -231,24 +233,19 @@ describe('MemberDetail', () => {
, ); - expect(screen.queryByText('Loading data...')).not.toBeInTheDocument(); - const user = MOCKS1[0].result.data.user; + const dicebearUrl = `mocked-data-uri`; - waitFor(() => - expect(screen.getByTestId('userImageAbsent')).toBeInTheDocument(), - ); - waitFor(() => - expect(screen.getByTestId('userImageAbsent').getAttribute('src')).toBe( - `https://api.dicebear.com/5.x/initials/svg?seed=${user?.firstName} ${user?.lastName}`, - ), - ); + const userImage = await screen.findByTestId('userImageAbsent'); + expect(userImage).toBeInTheDocument(); + expect(userImage.getAttribute('src')).toBe(dicebearUrl); }); test('Should display image if image is present', async () => { const props = { id: 'rishav-jha-mech', + from: 'orglist', }; render( @@ -266,15 +263,57 @@ describe('MemberDetail', () => { expect(screen.queryByText('Loading data...')).not.toBeInTheDocument(); const user = MOCKS2[0].result.data.user; + const userImage = await screen.findByTestId('userImagePresent'); + expect(userImage).toBeInTheDocument(); + expect(userImage.getAttribute('src')).toBe(user?.image); + }); - waitFor(() => - expect(screen.getByTestId('userImagePresent')).toBeInTheDocument(), + test('should render LeftDrawer from SuperAdminScreen when member details is called from home page', async () => { + const props = { + id: 'rishav-jha-mech', + from: 'orglist', + }; + + render( + + + + + + + + + , ); - waitFor(() => - expect(screen.getByTestId('userImagePresent').getAttribute('src')).toBe( - user?.image, - ), + + expect(screen.queryByText('Loading data...')).not.toBeInTheDocument(); + await waitFor(() => { + expect(screen.getByTestId('orgsBtn')).toBeInTheDocument(); + }); + }); + + test('should not render LeftDrawer from SuperAdminScreen when member details is called from Organization Dashboard', async () => { + const props = { + id: 'rishav-jha-mech', + from: 'orgdash', + }; + + render( + + + + + + + + + , ); + + expect(screen.queryByText('Loading data...')).not.toBeInTheDocument(); + await waitFor(() => { + expect(screen.queryByTestId('orgsBtn')).not.toBeInTheDocument(); + }); }); test('should call setState with 2 when button is clicked', async () => { diff --git a/src/screens/MemberDetail/MemberDetail.tsx b/src/screens/MemberDetail/MemberDetail.tsx index fb9708fbd0..6b3b61f7df 100644 --- a/src/screens/MemberDetail/MemberDetail.tsx +++ b/src/screens/MemberDetail/MemberDetail.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { useMutation, useQuery } from '@apollo/client'; import Col from 'react-bootstrap/Col'; import Row from 'react-bootstrap/Row'; @@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next'; import { useLocation } from 'react-router-dom'; import UserUpdate from 'components/UserUpdate/UserUpdate'; import OrganizationScreen from 'components/OrganizationScreen/OrganizationScreen'; +import SuperAdminScreen from 'components/SuperAdminScreen/SuperAdminScreen'; import { USER_DETAILS } from 'GraphQl/Queries/Queries'; import styles from './MemberDetail.module.css'; import { languages } from 'utils/languages'; @@ -20,28 +21,40 @@ import Loader from 'components/Loader/Loader'; import useLocalStorage from 'utils/useLocalstorage'; import Avatar from 'components/Avatar/Avatar'; -const { getItem } = useLocalStorage(); - type MemberDetailProps = { id: string; // This is the userId + from?: string; }; -const MemberDetail: React.FC = ({ id }): JSX.Element => { +const MemberDetail: React.FC = ({ + id, + from, +}): JSX.Element => { const { t } = useTranslation('translation', { keyPrefix: 'memberDetail', }); const [state, setState] = useState(1); const [isAdmin, setIsAdmin] = useState(false); + const isMounted = useRef(true); + const { getItem } = useLocalStorage(); const location = useLocation(); const currentUrl = location.state?.id || getItem('id') || id; const orgId = window.location.href.split('=')[1]; + const calledFrom = location.state?.from || from; document.title = t('title'); const [adda] = useMutation(ADD_ADMIN_MUTATION); const [updateUserType] = useMutation(UPDATE_USERTYPE_MUTATION); + useEffect(() => { + // check component is mounted or not + return () => { + isMounted.current = false; + }; + }, []); + const { data: userData, loading: loading, @@ -101,7 +114,7 @@ const MemberDetail: React.FC = ({ id }): JSX.Element => { userData.user.userType === 'ADMIN' || userData.user.userType === 'SUPERADMIN' ) { - setIsAdmin(true); + if (isMounted.current) setIsAdmin(true); toast.error(t('alreadyIsAdmin')); } else { errorHandler(t, error); @@ -109,213 +122,216 @@ const MemberDetail: React.FC = ({ id }): JSX.Element => { } }; - return ( - <> - - - - {state == 1 ? ( -
- -

- {t('title')} -

-
- + const memberDetails = ( + + + {state == 1 ? ( +
+ +

+ {t('title')} +

+
+ - + +
+
+ + +
+ {userData?.user?.image ? ( + + ) : ( + + )} +
+ + + {/* User section */} +
+

+ + {userData?.user?.firstName} {userData?.user?.lastName} + +

+

+ {t('role')} :{' '} + {userData?.user?.userType} +

+

+ {t('email')} :{' '} + {userData?.user?.email} +

+

+ {t('createdOn')} :{' '} + {prettyDate(userData?.user?.createdAt)} +

+
+ +
+
+
+
+ {/* Main Section And Activity section */} +
+ + {/* Main Section */} + +
+
+
+ {t('main')} +
+
+
+ + {t('firstName')} + {userData?.user?.firstName} + + + {t('lastName')} + {userData?.user?.lastName} + + + {t('role')} + {userData?.user?.userType} + + + {t('language')} + + {getLanguageName(userData?.user?.appLanguageCode)} + + + + {t('adminApproved')} + + {userData?.user?.adminApproved ? 'Yes' : 'No'} + + + + {t('pluginCreationAllowed')} + + {userData?.user?.pluginCreationAllowed ? 'Yes' : 'No'} + + + + {t('createdOn')} + + {prettyDate(userData?.user?.createdAt)} + + +
-
- - -
- {userData?.user?.image ? ( - - ) : ( - - )} + + {/* Activity Section */} + + {/* Organizations */} +
+
+
+ {t('organizations')} +
- - - {/* User section */} -
-

- - {userData?.user?.firstName} {userData?.user?.lastName} - -

-

- {t('role')} :{' '} - {userData?.user?.userType} -

-

- {t('email')} :{' '} - {userData?.user?.email} -

-

- {t('createdOn')} :{' '} - {prettyDate(userData?.user?.createdAt)} -

+
+ + {t('created')} + + {userData?.user?.createdOrganizations?.length} + + + + {t('joined')} + + {userData?.user?.joinedOrganizations?.length} + + + + {t('adminForOrganizations')} + {userData?.user?.adminFor?.length} + + + {t('membershipRequests')} + + {userData?.user?.membershipRequests?.length} + +
- - -
-
-
- {/* Main Section And Activity section */} -
- - {/* Main Section */} - -
-
-
- {t('main')} -
-
-
- - {t('firstName')} - {userData?.user?.firstName} - - - {t('lastName')} - {userData?.user?.lastName} - - - {t('role')} - {userData?.user?.userType} - - - {t('language')} - - {getLanguageName(userData?.user?.appLanguageCode)} - - - - {t('adminApproved')} - - {userData?.user?.adminApproved ? 'Yes' : 'No'} - - - - {t('pluginCreationAllowed')} - - {userData?.user?.pluginCreationAllowed - ? 'Yes' - : 'No'} - - - - {t('createdOn')} - - {prettyDate(userData?.user?.createdAt)} - - -
-
- - {/* Activity Section */} - - {/* Organizations */} -
-
-
- {t('organizations')} -
-
-
- - {t('created')} - - {userData?.user?.createdOrganizations?.length} - - - - {t('joined')} - - {userData?.user?.joinedOrganizations?.length} - - - - {t('adminForOrganizations')} - {userData?.user?.adminFor?.length} - - - {t('membershipRequests')} - - {userData?.user?.membershipRequests?.length} - - -
-
- {/* Events */} -
-
-
- {t('events')} -
-
-
- - {t('created')} - - {userData?.user?.createdEvents?.length} - - - - {t('joined')} - - {userData?.user?.registeredEvents?.length} - - - - {t('adminForEvents')} - - {userData?.user?.eventAdmin?.length} - - -
-
- -
-
-
- ) : ( - - )} - - - +
+ {/* Events */} +
+
+
+ {t('events')} +
+
+
+ + {t('created')} + + {userData?.user?.createdEvents?.length} + + + + {t('joined')} + + {userData?.user?.registeredEvents?.length} + + + + {t('adminForEvents')} + {userData?.user?.eventAdmin?.length} + +
+
+ + +
+
+ ) : ( + + )} + +
+ ); + + return ( + <> + {calledFrom === 'orglist' ? ( + + {memberDetails} + + ) : ( + + {memberDetails} + + )} ); };