Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
meetulr committed Aug 21, 2024
1 parent 72f9271 commit 14d883d
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 107 deletions.
6 changes: 4 additions & 2 deletions src/screens/ManageTag/ManageTag.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,11 @@ describe('Organisation Tags Page', () => {
await wait();

await waitFor(() => {
expect(screen.getAllByTestId('goToManageTag')[0]).toBeInTheDocument();
expect(
screen.getAllByTestId('redirectToManageTag')[0],
).toBeInTheDocument();
});
userEvent.click(screen.getAllByTestId('goToManageTag')[0]);
userEvent.click(screen.getAllByTestId('redirectToManageTag')[0]);

await waitFor(() => {
expect(screen.getByTestId('addPeopleToTagBtn')).toBeInTheDocument();
Expand Down
43 changes: 11 additions & 32 deletions src/screens/ManageTag/ManageTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { toast } from 'react-toastify';
import type { InterfaceQueryUserTagsAssignedMembers } from 'utils/interfaces';
import styles from './ManageTag.module.css';
import { DataGrid } from '@mui/x-data-grid';
import { dataGridStyle } from 'utils/organizationTagsUtils';
import type { GridCellParams, GridColDef } from '@mui/x-data-grid';
import { Stack } from '@mui/material';
import { UNASSIGN_USER_TAG } from 'GraphQl/Mutations/TagMutations';
Expand All @@ -23,27 +24,6 @@ import {
USER_TAGS_ASSIGNED_MEMBERS,
} from 'GraphQl/Queries/userTagQueries';

const dataGridStyle = {
'&.MuiDataGrid-root .MuiDataGrid-cell:focus-within': {
outline: 'none !important',
},
'&.MuiDataGrid-root .MuiDataGrid-columnHeader:focus-within': {
outline: 'none',
},
'& .MuiDataGrid-row:hover': {
backgroundColor: 'transparent',
},
'& .MuiDataGrid-row.Mui-hovered': {
backgroundColor: 'transparent',
},
'& .MuiDataGrid-root': {
borderRadius: '0.1rem',
},
'& .MuiDataGrid-main': {
borderRadius: '0.1rem',
},
};

function ManageTag(): JSX.Element {
const { t } = useTranslation('translation', {
keyPrefix: 'manageTag',
Expand All @@ -54,7 +34,7 @@ function ManageTag(): JSX.Element {
useState(false);
const [unassignTagModalIsOpen, setUnassignTagModalIsOpen] = useState(false);

const { orgId: currentUrl, tagId: currentTagId } = useParams();
const { orgId, tagId: currentTagId } = useParams();
const navigate = useNavigate();
const [after, setAfter] = useState<string | null | undefined>(null);
const [before, setBefore] = useState<string | null | undefined>(null);
Expand Down Expand Up @@ -131,7 +111,6 @@ function ManageTag(): JSX.Element {
/* istanbul ignore next */
if (error instanceof Error) {
toast.error(error.message);
console.log(error.message);
}
}
};
Expand Down Expand Up @@ -165,12 +144,12 @@ function ManageTag(): JSX.Element {

const orgUserTagAncestors = orgUserTagAncestorsData?.getUserTagAncestors;

const goToSubTags = (tagId: string): void => {
navigate(`/orgtags/${currentUrl}/subTags/${tagId}`);
const redirectToSubTags = (tagId: string): void => {
navigate(`/orgtags/${orgId}/subTags/${tagId}`);
};

const goToManageTag = (tagId: string): void => {
navigate(`/orgtags/${currentUrl}/managetag/${tagId}`);
const redirectToManageTag = (tagId: string): void => {
navigate(`/orgtags/${orgId}/managetag/${tagId}`);
};

const handleNextPage = (): void => {
Expand Down Expand Up @@ -239,7 +218,7 @@ function ManageTag(): JSX.Element {
return (
<div className="d-flex justify-content-center align-items-center">
<Link
to={`/member/${currentUrl}`}
to={`/member/${orgId}`}
state={{ id: params.row._id }}
className={styles.membername}
data-testid="viewProfileBtn"
Expand Down Expand Up @@ -313,7 +292,7 @@ function ManageTag(): JSX.Element {

<Button
variant="success"
onClick={() => goToSubTags(currentTagId as string)}
onClick={() => redirectToSubTags(currentTagId as string)}
className="mx-4"
data-testid="subTagsBtn"
>
Expand All @@ -340,7 +319,7 @@ function ManageTag(): JSX.Element {
</div>

<div
onClick={() => navigate(`/orgtags/${currentUrl}`)}
onClick={() => navigate(`/orgtags/${orgId}`)}
className={`fs-6 ms-3 my-1 ${styles.tagsBreadCrumbs}`}
data-testid="allTagsBtn"
>
Expand All @@ -352,8 +331,8 @@ function ManageTag(): JSX.Element {
<div
key={index}
className={`ms-2 my-1 ${tag._id === currentTagId ? `fs-4 fw-semibold text-secondary` : `${styles.tagsBreadCrumbs} fs-6`}`}
onClick={() => goToManageTag(tag._id as string)}
data-testid="goToManageTag"
onClick={() => redirectToManageTag(tag._id as string)}
data-testid="redirectToManageTag"
>
{tag.name}

Expand Down
46 changes: 12 additions & 34 deletions src/screens/OrganizationTags/OrganizationTags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { toast } from 'react-toastify';
import type { InterfaceQueryOrganizationUserTags } from 'utils/interfaces';
import styles from './OrganizationTags.module.css';
import { DataGrid } from '@mui/x-data-grid';
import { dataGridStyle } from 'utils/organizationTagsUtils';
import type { GridCellParams, GridColDef } from '@mui/x-data-grid';
import { Stack } from '@mui/material';
import { ORGANIZATION_USER_TAGS_LIST } from 'GraphQl/Queries/OrganizationQueries';
Expand All @@ -24,27 +25,6 @@ import {
REMOVE_USER_TAG,
} from 'GraphQl/Mutations/TagMutations';

const dataGridStyle = {
'&.MuiDataGrid-root .MuiDataGrid-cell:focus-within': {
outline: 'none !important',
},
'&.MuiDataGrid-root .MuiDataGrid-columnHeader:focus-within': {
outline: 'none',
},
'& .MuiDataGrid-row:hover': {
backgroundColor: 'transparent',
},
'& .MuiDataGrid-row.Mui-hovered': {
backgroundColor: 'transparent',
},
'& .MuiDataGrid-root': {
borderRadius: '0.1rem',
},
'& .MuiDataGrid-main': {
borderRadius: '0.1rem',
},
};

function OrganizationTags(): JSX.Element {
const { t } = useTranslation('translation', {
keyPrefix: 'organizationTags',
Expand All @@ -53,7 +33,7 @@ function OrganizationTags(): JSX.Element {

const [createTagModalIsOpen, setCreateTagModalIsOpen] = useState(false);

const { orgId: currentUrl } = useParams();
const { orgId } = useParams();
const navigate = useNavigate();
const [after, setAfter] = useState<string | null | undefined>(null);
const [before, setBefore] = useState<string | null | undefined>(null);
Expand Down Expand Up @@ -89,7 +69,7 @@ function OrganizationTags(): JSX.Element {
refetch: () => void;
} = useQuery(ORGANIZATION_USER_TAGS_LIST, {
variables: {
id: currentUrl,
id: orgId,
after: after,
before: before,
first: first,
Expand All @@ -107,7 +87,7 @@ function OrganizationTags(): JSX.Element {
const { data } = await create({
variables: {
name: tagName,
organizationId: currentUrl,
organizationId: orgId,
},
});

Expand All @@ -121,7 +101,6 @@ function OrganizationTags(): JSX.Element {
/* istanbul ignore next */
if (error instanceof Error) {
toast.error(error.message);
console.log(error.message);
}
}
};
Expand All @@ -142,7 +121,6 @@ function OrganizationTags(): JSX.Element {
/* istanbul ignore next */
if (error instanceof Error) {
toast.error(error.message);
console.log(error.message);
}
}
};
Expand Down Expand Up @@ -185,12 +163,12 @@ function OrganizationTags(): JSX.Element {
(edge) => edge.node,
);

const goToManageTag = (tagId: string): void => {
navigate(`/orgtags/${currentUrl}/managetag/${tagId}`);
const redirectToManageTag = (tagId: string): void => {
navigate(`/orgtags/${orgId}/managetag/${tagId}`);
};

const goToSubTags = (tagId: string): void => {
navigate(`/orgtags/${currentUrl}/subTags/${tagId}`);
const redirectToSubTags = (tagId: string): void => {
navigate(`/orgtags/${orgId}/subTags/${tagId}`);
};

const toggleRemoveUserTagModal = (): void => {
Expand Down Expand Up @@ -223,7 +201,7 @@ function OrganizationTags(): JSX.Element {
<div
className={styles.subTagsLink}
data-testid="tagName"
onClick={() => goToSubTags(params.row._id)}
onClick={() => redirectToSubTags(params.row._id)}
>
{params.row.name}

Expand All @@ -245,7 +223,7 @@ function OrganizationTags(): JSX.Element {
return (
<Link
className="text-secondary"
to={`/orgtags/${currentUrl}/orgtagchildtags/${params.row._id}`}
to={`/orgtags/${orgId}/orgtagchildtags/${params.row._id}`}
>
{params.row.childTags.totalCount}
</Link>
Expand All @@ -265,7 +243,7 @@ function OrganizationTags(): JSX.Element {
return (
<Link
className="text-secondary"
to={`/orgtags/${currentUrl}/orgtagdetails/${params.row._id}`}
to={`/orgtags/${orgId}/orgtagdetails/${params.row._id}`}
>
{params.row.usersAssignedTo.totalCount}
</Link>
Expand All @@ -287,7 +265,7 @@ function OrganizationTags(): JSX.Element {
<Button
size="sm"
className="btn btn-primary rounded mt-3"
onClick={() => goToManageTag(params.row._id)}
onClick={() => redirectToManageTag(params.row._id)}
data-testid="manageTagBtn"
>
{t('manageTag')}
Expand Down
4 changes: 2 additions & 2 deletions src/screens/SubTags/SubTags.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ describe('Organisation Tags Page', () => {
await wait();

await waitFor(() => {
expect(screen.getAllByTestId('goToSubTags')[0]).toBeInTheDocument();
expect(screen.getAllByTestId('redirectToSubTags')[0]).toBeInTheDocument();
});
userEvent.click(screen.getAllByTestId('goToSubTags')[0]);
userEvent.click(screen.getAllByTestId('redirectToSubTags')[0]);

await waitFor(() => {
expect(screen.getByTestId('addSubTagBtn')).toBeInTheDocument();
Expand Down
Loading

0 comments on commit 14d883d

Please sign in to comment.