mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
8a95a41100
Co-authored-by: Bavisetti Narayan <72156168+NarayanBavisetti@users.noreply.github.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: Bavisetti Narayan <narayan@Bavisettis-MacBook-Pro.local> Co-authored-by: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Co-authored-by: M. Palanikannan <73993394+Palanikannan1437@users.noreply.github.com> Co-authored-by: Lakhan Baheti <94619783+1akhanBaheti@users.noreply.github.com> Co-authored-by: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Co-authored-by: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com>
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
"use client";
|
|
|
|
// helpers
|
|
import { renderFullDate } from "constants/helpers";
|
|
|
|
export const findHowManyDaysLeft = (date: string | Date) => {
|
|
const today = new Date();
|
|
const eventDate = new Date(date);
|
|
const timeDiff = Math.abs(eventDate.getTime() - today.getTime());
|
|
|
|
return Math.ceil(timeDiff / (1000 * 3600 * 24));
|
|
};
|
|
|
|
const dueDateIcon = (
|
|
date: string,
|
|
stateGroup: string
|
|
): {
|
|
iconName: string;
|
|
className: string;
|
|
} => {
|
|
let iconName = "calendar_today";
|
|
let className = "";
|
|
|
|
if (!date || ["completed", "cancelled"].includes(stateGroup)) {
|
|
iconName = "calendar_today";
|
|
className = "";
|
|
} else {
|
|
const today = new Date();
|
|
const dueDate = new Date(date);
|
|
|
|
if (dueDate < today) {
|
|
iconName = "event_busy";
|
|
className = "text-red-500";
|
|
} else if (dueDate > today) {
|
|
iconName = "calendar_today";
|
|
className = "";
|
|
} else {
|
|
iconName = "today";
|
|
className = "text-red-500";
|
|
}
|
|
}
|
|
|
|
return {
|
|
iconName,
|
|
className,
|
|
};
|
|
};
|
|
|
|
export const IssueBlockDueDate = ({ due_date, group }: { due_date: string; group: string }) => {
|
|
const iconDetails = dueDateIcon(due_date, group);
|
|
|
|
return (
|
|
<div className="rounded flex px-2.5 py-1 items-center border-[0.5px] border-custom-border-300 gap-1 text-custom-text-100 text-xs">
|
|
<span className={`material-symbols-rounded text-sm -my-0.5 ${iconDetails.className}`}>
|
|
{iconDetails.iconName}
|
|
</span>
|
|
{renderFullDate(due_date)}
|
|
</div>
|
|
);
|
|
};
|