2023-02-08 04:43:07 +00:00
|
|
|
// ui
|
2023-02-22 06:12:17 +00:00
|
|
|
import { CustomDatePicker, Tooltip } from "components/ui";
|
2023-02-08 04:43:07 +00:00
|
|
|
// helpers
|
|
|
|
import { findHowManyDaysLeft } from "helpers/date-time.helper";
|
2023-04-06 06:38:52 +00:00
|
|
|
// services
|
|
|
|
import trackEventServices from "services/track-event.service";
|
2023-02-08 04:43:07 +00:00
|
|
|
// types
|
|
|
|
import { IIssue } from "types";
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
issue: IIssue;
|
|
|
|
partialUpdateIssue: (formData: Partial<IIssue>) => void;
|
|
|
|
isNotAllowed: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const ViewDueDateSelect: React.FC<Props> = ({ issue, partialUpdateIssue, isNotAllowed }) => (
|
2023-02-22 06:12:17 +00:00
|
|
|
<Tooltip tooltipHeading="Due Date" tooltipContent={issue.target_date ?? "N/A"}>
|
|
|
|
<div
|
|
|
|
className={`group relative ${
|
|
|
|
issue.target_date === null
|
|
|
|
? ""
|
|
|
|
: issue.target_date < new Date().toISOString()
|
|
|
|
? "text-red-600"
|
|
|
|
: findHowManyDaysLeft(issue.target_date) <= 3 && "text-orange-400"
|
|
|
|
}`}
|
|
|
|
>
|
|
|
|
<CustomDatePicker
|
|
|
|
placeholder="N/A"
|
|
|
|
value={issue?.target_date}
|
2023-04-06 06:38:52 +00:00
|
|
|
onChange={(val) => {
|
2023-02-22 06:12:17 +00:00
|
|
|
partialUpdateIssue({
|
|
|
|
target_date: val,
|
2023-03-15 06:14:44 +00:00
|
|
|
priority: issue.priority,
|
|
|
|
state: issue.state,
|
2023-04-06 06:38:52 +00:00
|
|
|
});
|
|
|
|
trackEventServices.trackIssuePartialPropertyUpdateEvent(
|
|
|
|
{
|
|
|
|
workspaceSlug: issue.workspace_detail.slug,
|
|
|
|
workspaceId: issue.workspace_detail.id,
|
|
|
|
projectId: issue.project_detail.id,
|
|
|
|
projectIdentifier: issue.project_detail.identifier,
|
|
|
|
projectName: issue.project_detail.name,
|
|
|
|
issueId: issue.id,
|
|
|
|
},
|
|
|
|
"ISSUE_PROPERTY_UPDATE_DUE_DATE"
|
|
|
|
);
|
|
|
|
}}
|
2023-02-22 06:12:17 +00:00
|
|
|
className={issue?.target_date ? "w-[6.5rem]" : "w-[3rem] text-center"}
|
|
|
|
disabled={isNotAllowed}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Tooltip>
|
2023-02-08 04:43:07 +00:00
|
|
|
);
|