Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes Organization not found error in LeftDrawerOrg #1385

Closed
Closed
Show file tree
Hide file tree
Changes from 5 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
15 changes: 9 additions & 6 deletions src/components/LeftDrawer/LeftDrawer.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,9 @@
width: 100%;
height: 52px;
border-radius: 8px;
background-color: var(--bs-white);
display: flex;
align-items: center;
}

.leftDrawer .profileContainer:focus {
outline: none;
background-color: var(--bs-gray-100);
padding: 2.5rem 1rem 2.5rem 1rem;
}

.leftDrawer .imageContainer {
Expand All @@ -92,6 +87,10 @@
font-weight: 600;
}

.leftDrawer .profileContainer .profileText .primaryText .primaryTextWhite {
color: var(--bs-white);
}

.leftDrawer .profileContainer .profileText .secondaryText {
font-size: 0.8rem;
font-weight: 400;
Expand All @@ -100,6 +99,10 @@
text-transform: capitalize;
}

.leftDrawer .profileContainer .profileText .secondaryTextWhite {
color: var(--bs-gray-100);
}

.logout {
margin-bottom: 50px;
}
Expand Down
70 changes: 44 additions & 26 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 @@ -102,33 +102,51 @@
)}
</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={'orglistBtn'}
data-testid="profileBtn"
variant={screenName === 'orglist' ? 'success' : 'light'}
className={styles.profileContainer}
>
<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} ${lastName}`}

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.
alt={`dummy picture`}
/>
)}
</div>
<div className={styles.profileText}>
<span
className={`${styles.primaryText}
${screenName === 'orglist' ? styles.primaryTextWhite : ''}`}
>
{firstName} {lastName}
</span>
<span
className={`${styles.secondaryText}
${screenName === 'orglist' ? styles.secondaryTextWhite : ''}`}
>
{`${userType}`.toLowerCase()}
</span>
</div>
<AngleRightIcon
fill={
screenName === 'orglist'
? 'var(--bs-white)'
: 'var(--bs-secondary)'
}
/>
</Button>
</Link>

<Button
variant="light"
Expand Down
2 changes: 1 addition & 1 deletion src/components/LeftDrawerEvent/LeftDrawerEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const leftDrawerEvent = ({
<img src={userImage} alt={`Profile Picture`} />
) : (
<img
src={`https://api.dicebear.com/5.x/initials/svg?seed=${firstName}%20${lastName}`}
src={`https://api.dicebear.com/5.x/initials/svg?seed=${firstName} ${lastName}`}

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.
alt={`Dummy User Picture`}
/>
)}
Expand Down
14 changes: 8 additions & 6 deletions src/components/LeftDrawerOrg/LeftDrawerOrg.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,9 @@
margin-top: 5rem;
height: 52px;
border-radius: 8px;
background-color: var(--bs-white);
display: flex;
align-items: center;
}

.leftDrawer .profileContainer:focus {
outline: none;
background-color: var(--bs-gray-100);
padding: 2.5rem 1rem 2.5rem 1rem;
}

.leftDrawer .imageContainer {
Expand All @@ -135,6 +130,9 @@
font-size: 1.1rem;
font-weight: 600;
}
.leftDrawer .profileContainer .profileText .primaryText .primaryTextWhite {
color: var(--bs-white);
}

.leftDrawer .profileContainer .profileText .secondaryText {
font-size: 0.8rem;
Expand All @@ -144,6 +142,10 @@
text-transform: capitalize;
}

.leftDrawer .profileContainer .profileText .secondaryTextWhite {
color: var(--bs-gray-100);
}

.logout {
margin-bottom: 50px;
}
Expand Down
70 changes: 44 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 React, { useEffect, useState } from 'react';
import Button from 'react-bootstrap/Button';
import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
import { Link, useHistory } 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 @@ -170,33 +170,51 @@

{/* 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={'orgdashBtn'}
variant={screenName === 'orgdash' ? '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}`}

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.
DOM text
is reinterpreted as HTML without escaping meta-characters.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this security vulnterability

alt={`dummy picture`}
/>
)}
</div>
<div className={styles.profileText}>
<span
className={`${styles.primaryText}
${screenName === 'orgdash' ? styles.primaryTextWhite : ''}`}
>
{firstName} {lastName}
</span>
<span
className={`${styles.secondaryText}
${screenName === 'orgdash' ? styles.secondaryTextWhite : ''}`}
>
{`${userType}`.toLowerCase()}
</span>
</div>
<AngleRightIcon
fill={
screenName === 'orgdash'
? 'var(--bs-white)'
: '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 @@ -172,6 +172,32 @@ describe('MemberDetail', () => {
userEvent.click(screen.getByTestId('stateBtn'));
});

test('should render OrganizationScreen if from is from is orgdash', 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('prettyDate function should work properly', () => {
// If the date is provided
const datePretty = jest.fn(prettyDate);
Expand Down
Loading
Loading