Skip to content

Commit

Permalink
Fixed Organization Not Found in Left Drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
GlenDsza committed Feb 16, 2024
1 parent 558c475 commit 08c3fe4
Show file tree
Hide file tree
Showing 7 changed files with 311 additions and 356 deletions.
99 changes: 0 additions & 99 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/LeftDrawer/LeftDrawer.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
63 changes: 36 additions & 27 deletions src/components/LeftDrawer/LeftDrawer.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -104,34 +104,43 @@ const leftDrawer = ({
)}
</div>
<div style={{ marginTop: 'auto' }}>
<button
className={styles.profileContainer}
data-testid="profileBtn"
onClick={(): void => {
history.push(`/member/id=${userId}`);
<Link
to={{
pathname: `/member/id=${userId}`,
state: { from: 'orglist' },
}}
>
<div className={styles.imageContainer}>
{userImage && userImage !== 'null' ? (
<img src={userImage} alt={`profile picture`} />
) : (
<img
src={`https://api.dicebear.com/5.x/initials/svg?seed=${firstName}%20${lastName}`}
alt={`dummy picture`}
/>
)}
</div>
<div className={styles.profileText}>
<span className={styles.primaryText}>
{firstName} {lastName}
</span>
<span className={styles.secondaryText}>
{`${userType}`.toLowerCase()}
</span>
</div>
<AngleRightIcon fill={'var(--bs-secondary)'} />
</button>

<Button
key={'profileBtn'}
className={styles.profileContainer}
variant={screenName === 'Profile' ? 'success' : 'light'}
data-testid="profileBtn"
>
<div className={styles.imageContainer}>
{userImage && userImage !== 'null' ? (
<img src={userImage} alt={`profile picture`} />
) : (
<img
src={`https://api.dicebear.com/5.x/initials/svg?seed=${firstName}%20${lastName}`}
alt={`dummy picture`}
/>
)}
</div>
<div className={styles.profileText}>
<span className={styles.primaryText}>
{firstName} {lastName}
</span>
<span
className={`${styles.secondaryText} ${
screenName === 'Profile' && 'text-white'
}`}
>
{`${userType}`.toLowerCase()}
</span>
</div>
<AngleRightIcon fill={'var(--bs-secondary)'} />
</Button>
</Link>
<Button
variant="light"
className={`mt-4 d-flex justify-content-start px-0 w-100 bg-danger text-white ${styles.logout}`}
Expand Down
2 changes: 1 addition & 1 deletion src/components/LeftDrawerOrg/LeftDrawerOrg.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,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;
}
Expand Down
62 changes: 36 additions & 26 deletions src/components/LeftDrawerOrg/LeftDrawerOrg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import IconComponent from 'components/IconComponent/IconComponent';
import React, { useEffect, useState } 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';
Expand Down Expand Up @@ -176,33 +176,43 @@ const leftDrawerOrg = ({

{/* Profile Section & Logout Btn */}
<div style={{ marginTop: 'auto' }}>
<button
className={styles.profileContainer}
data-testid="profileBtn"
onClick={(): void => {
history.push(`/member/id=${userId}`);
<Link
to={{
pathname: `/member/id=${userId}`,
state: { from: 'orgdash' },
}}
>
<div className={styles.imageContainer}>
{userImage && userImage !== 'null' ? (
<img src={userImage} alt={`profile picture`} />
) : (
<img
src={`https://api.dicebear.com/5.x/initials/svg?seed=${firstName}%20${lastName}`}
alt={`dummy picture`}
/>
)}
</div>
<div className={styles.profileText}>
<span className={styles.primaryText}>
{firstName} {lastName}
</span>
<span className={styles.secondaryText}>
{`${userType}`.toLowerCase()}
</span>
</div>
<AngleRightIcon fill={'var(--bs-secondary)'} />
</button>
<Button
key={'profileBtn'}
variant={screenName === 'Profile' ? 'success' : 'light'}
className={styles.profileContainer}
data-testid="profileBtn"
>
<div className={styles.imageContainer}>
{userImage && userImage !== 'null' ? (
<img src={userImage} alt={`profile picture`} />
) : (
<img
src={`https://api.dicebear.com/5.x/initials/svg?seed=${firstName}%20${lastName}`}
alt={`dummy picture`}
/>
)}
</div>
<div className={styles.profileText}>
<span className={styles.primaryText}>
{firstName} {lastName}
</span>
<span
className={`${styles.secondaryText} ${
screenName === 'Profile' && 'text-white'
}`}
>
{`${userType}`.toLowerCase()}
</span>
</div>
<AngleRightIcon fill={'var(--bs-secondary)'} />
</Button>
</Link>
<Button
variant="light"
className={`mt-4 d-flex justify-content-start px-0 w-100 ${styles.logout}`}
Expand Down
26 changes: 26 additions & 0 deletions src/screens/MemberDetail/MemberDetail.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,32 @@ describe('MemberDetail', () => {
expect(getLangName('')).toBe('Unavailable');
});

test('should render OrganizationScreen if called from Organization Dashboard', async () => {
const props = {
id: 'rishav-jha-mech',
from: 'orgdash',
};

render(
<MockedProvider addTypename={false} link={link1}>
<BrowserRouter>
<Provider store={store}>
<I18nextProvider i18n={i18nForTest}>
<MemberDetail {...props} />
</I18nextProvider>
</Provider>
</BrowserRouter>
</MockedProvider>
);

expect(screen.queryByText('Loading data...')).not.toBeInTheDocument();
await wait();
expect(screen.getAllByText(/People/i)).toBeTruthy();
expect(screen.getAllByText(/Events/i)).toBeTruthy();
expect(screen.getAllByText(/Posts/i)).toBeTruthy();
expect(screen.getAllByText(/Advertisement/i)).toBeTruthy();
});

test('Should display dicebear image if image is null', async () => {
const props = {
id: 'rishav-jha-mech',
Expand Down
Loading

0 comments on commit 08c3fe4

Please sign in to comment.