2023-08-28 07:55:47 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
|
|
|
// ui
|
2023-10-16 14:57:22 +00:00
|
|
|
import { Tooltip, ContrastIcon } from "@plane/ui";
|
2023-08-28 07:55:47 +00:00
|
|
|
// helpers
|
2023-12-29 09:54:07 +00:00
|
|
|
import { renderShortDate } from "helpers/date-time.helper";
|
2023-08-28 07:55:47 +00:00
|
|
|
// types
|
|
|
|
import { ICycle } from "types";
|
|
|
|
|
|
|
|
export const CycleGanttBlock = ({ data }: { data: ICycle }) => {
|
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug } = router.query;
|
|
|
|
|
2023-12-29 09:54:07 +00:00
|
|
|
const cycleStatus = data.status.toLocaleLowerCase();
|
2023-08-28 07:55:47 +00:00
|
|
|
return (
|
|
|
|
<div
|
2023-12-10 10:18:10 +00:00
|
|
|
className="relative flex h-full w-full items-center rounded"
|
2023-08-28 07:55:47 +00:00
|
|
|
style={{
|
|
|
|
backgroundColor:
|
|
|
|
cycleStatus === "current"
|
|
|
|
? "#09a953"
|
|
|
|
: cycleStatus === "upcoming"
|
2023-12-29 09:54:07 +00:00
|
|
|
? "#f7ae59"
|
|
|
|
: cycleStatus === "completed"
|
|
|
|
? "#3f76ff"
|
|
|
|
: cycleStatus === "draft"
|
|
|
|
? "rgb(var(--color-text-200))"
|
|
|
|
: "",
|
2023-08-28 07:55:47 +00:00
|
|
|
}}
|
|
|
|
onClick={() => router.push(`/${workspaceSlug}/projects/${data?.project}/cycles/${data?.id}`)}
|
|
|
|
>
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="absolute left-0 top-0 h-full w-full bg-custom-background-100/50" />
|
2023-08-28 07:55:47 +00:00
|
|
|
<Tooltip
|
|
|
|
tooltipContent={
|
|
|
|
<div className="space-y-1">
|
|
|
|
<h5>{data?.name}</h5>
|
|
|
|
<div>
|
|
|
|
{renderShortDate(data?.start_date ?? "")} to {renderShortDate(data?.end_date ?? "")}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
position="top-left"
|
|
|
|
>
|
2023-12-10 10:18:10 +00:00
|
|
|
<div className="relative w-full truncate px-2.5 py-1 text-sm text-custom-text-100">{data?.name}</div>
|
2023-08-28 07:55:47 +00:00
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const CycleGanttSidebarBlock = ({ data }: { data: ICycle }) => {
|
|
|
|
const router = useRouter();
|
|
|
|
const { workspaceSlug } = router.query;
|
|
|
|
|
2023-12-29 09:54:07 +00:00
|
|
|
const cycleStatus = data.status.toLocaleLowerCase();
|
2023-08-28 07:55:47 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2023-12-10 10:18:10 +00:00
|
|
|
className="relative flex h-full w-full items-center gap-2"
|
2023-08-28 07:55:47 +00:00
|
|
|
onClick={() => router.push(`/${workspaceSlug}/projects/${data?.project}/cycles/${data?.id}`)}
|
|
|
|
>
|
|
|
|
<ContrastIcon
|
|
|
|
className="h-5 w-5 flex-shrink-0"
|
|
|
|
color={`${
|
|
|
|
cycleStatus === "current"
|
|
|
|
? "#09a953"
|
|
|
|
: cycleStatus === "upcoming"
|
2023-12-29 09:54:07 +00:00
|
|
|
? "#f7ae59"
|
|
|
|
: cycleStatus === "completed"
|
|
|
|
? "#3f76ff"
|
|
|
|
: cycleStatus === "draft"
|
|
|
|
? "rgb(var(--color-text-200))"
|
|
|
|
: ""
|
2023-08-28 07:55:47 +00:00
|
|
|
}`}
|
|
|
|
/>
|
2023-12-10 10:18:10 +00:00
|
|
|
<h6 className="flex-grow truncate text-sm font-medium">{data?.name}</h6>
|
2023-08-28 07:55:47 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|