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

Fix assignment status update #2925

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
25 changes: 0 additions & 25 deletions app/types/user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ interface AccessibleFeature {
featureType: 'general_access' | 'experimental' | 'early_access';
}

interface ProjectElement {
id: number;
title: string;
isPrivate: boolean;
}

export interface User {
userId: number;
username: string;
Expand All @@ -26,22 +20,3 @@ export interface UserMini {
email: string;
displayName: string;
}

export interface Assignment {
id: number;
createdAt: string;
projectDetails: ProjectElement;
createdByDetails: {
id: number;
displayName: string;
email: string;
};
contentObjectDetails?: {
id: number;
title: string;
lead?: string;
entry?: string;
} | undefined;
isDone: boolean;
contentObjectType: 'lead' | 'entryreviewcomment' | 'entrycomment';
}
47 changes: 24 additions & 23 deletions app/views/Home/Assignment/AssignmentItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import {
DateOutput,
} from '@the-deep/deep-ui';

import { Assignment } from '#types';
import generateString from '#utils/string';
import routes from '#base/configs/routes';

import { Assignment } from '..';
import styles from './styles.css';

interface AssignmentItemProps extends Assignment {
handleClick: (id: number) => void;
handleClick: (id: string) => void;
markAsDonePending: boolean;
}

Expand All @@ -24,10 +24,9 @@ function AssignmentItem(props: AssignmentItemProps) {
id,
handleClick: handleClickFromProps,
markAsDonePending,
createdByDetails,
contentObjectDetails,
contentObjectType,
projectDetails,
createdBy,
contentData,
project,
createdAt,
} = props;

Expand All @@ -36,26 +35,30 @@ function AssignmentItem(props: AssignmentItemProps) {
}, [id, handleClickFromProps]);

const contentLink = useMemo(() => {
if (contentObjectType === 'lead') {
if (contentData?.contentType === 'LEAD') {
return (generateString(
'source {link}',
{
link: (contentObjectDetails?.id && projectDetails?.id && (
link: (contentData?.lead?.id && project?.id && (
<Link
to={generatePath(routes.entryEdit.path, {
projectId: projectDetails.id,
leadId: contentObjectDetails.id,
projectId: project?.id,
leadId: contentData?.lead?.id,
})}
className={styles.link}
>
{contentObjectDetails.title}
{contentData?.lead?.title}
</Link>
)),
},
));
}
if (contentObjectType === 'entryreviewcomment' || contentObjectType === 'entrycomment') {
if (!contentObjectDetails || !projectDetails?.id || !contentObjectDetails?.lead) {
if (contentData?.contentType === 'ENTRY_REVIEW_COMMENT') {
if (
!contentData?.entryReviewComment
|| !project?.id
|| !contentData?.entryReviewComment?.entryId
) {
return (
<span>
an entry
Expand All @@ -64,12 +67,11 @@ function AssignmentItem(props: AssignmentItemProps) {
}
const editEntryLink = {
pathname: (generatePath(routes.entryEdit.path, {
projectId: projectDetails.id,
leadId: contentObjectDetails.lead,
projectId: project.id,
leadId: contentData?.entryReviewComment?.leadId,
})),
state: {
// NOTE: Replace this later to clientId
entryServerId: contentObjectDetails.entry,
entryServerId: contentData?.entryReviewComment?.entryId,
activePage: 'primary',
},
hash: '#/primary-tagging',
Expand All @@ -85,9 +87,8 @@ function AssignmentItem(props: AssignmentItemProps) {
}
return null;
}, [
contentObjectType,
contentObjectDetails,
projectDetails,
contentData,
project,
]);

return (
Expand All @@ -111,17 +112,17 @@ function AssignmentItem(props: AssignmentItemProps) {
{generateString(
'{createdByName} assigned you to {linkToItem} in {project}.',
{
createdByName: createdByDetails.displayName,
createdByName: createdBy?.displayName,
linkToItem: contentLink,
project: (
<Link
to={generatePath(
routes.tagging.path,
{ projectId: projectDetails?.id },
{ projectId: project?.id },
)}
className={styles.link}
>
{projectDetails?.title}
{project?.title}
</Link>
),
},
Expand Down
Loading
Loading