Skip to content

Commit

Permalink
Fix repeating code and falling tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
skbhagat0502 authored Nov 5, 2023
1 parent f01e37b commit b2a41dd
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/screens/OrganizationDashboard/OrganizationDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,15 @@ import { toast } from 'react-toastify';
import { useHistory } from 'react-router-dom';
import CardItemLoading from 'components/OrganizationDashCards/CardItemLoading';
import DashboardCardLoading from 'components/OrganizationDashCards/DashboardCardLoading';
import getOrganizationId from 'utils/getOrganizationId';

function organizationDashboard(): JSX.Element {
const { t } = useTranslation('translation', { keyPrefix: 'dashboard' });
document.title = t('title');
const currentUrl = window.location.href.split('=')[1];
const organizationId = getOrganizationId(window.location.href);
const peopleLink = `/orgpeople/id=${organizationId}`;
const postsLink = `/orgpost/id=${organizationId}`;
const eventsLink = `/orgevents/id=${organizationId}`;
const blockUserLink = `/blockuser/id=${organizationId}`;
const peopleLink = `/orgpeople/id=${currentUrl}`;
const postsLink = `/orgpost/id=${currentUrl}`;
const eventsLink = `/orgevents/id=${currentUrl}`;
const blockUserLink = `/blockuser/id=${currentUrl}`;
const requestLink = '/requests';

const history = useHistory();
Expand Down Expand Up @@ -231,9 +229,7 @@ function organizationDashboard(): JSX.Element {
size="sm"
variant="light"
data-testid="viewAllEvents"
onClick={(): void =>
history.push(`/orgevents/id=${currentUrl}`)
}
onClick={(): void => history.push(eventsLink)}
>
{t('viewAll')}
</Button>
Expand Down Expand Up @@ -270,9 +266,7 @@ function organizationDashboard(): JSX.Element {
size="sm"
variant="light"
data-testid="viewAllPosts"
onClick={(): void =>
history.push(`/orgpost/id=${currentUrl}`)
}
onClick={(): void => history.push(postsLink)}
>
{t('viewAll')}
</Button>
Expand Down

0 comments on commit b2a41dd

Please sign in to comment.