Add .gitignore Removed node_modules from previous commit Fix task modes Fix task modes Fix task modes Remove node_modules Update basic task modal Add notes functionality Improve UI Setup views Add scopes Fix projects layout Restructure Fix rest of the UI issues Cleanup old views Add .env to .gitignore
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
|
|
interface TaskDueDateProps {
|
|
dueDate: string;
|
|
className?: string;
|
|
}
|
|
|
|
const TaskDueDate: React.FC<TaskDueDateProps> = ({ dueDate, className }) => {
|
|
const getDueDateClass = () => {
|
|
const today = new Date().toISOString().split('T')[0];
|
|
const tomorrow = new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString().split('T')[0];
|
|
|
|
if (dueDate === today) return 'bg-blue-700 text-white';
|
|
if (dueDate === tomorrow) return 'bg-blue-700 text-white';
|
|
if (dueDate < today) return 'bg-red-700 text-white';
|
|
return 'bg-gray-300 text-gray-700';
|
|
};
|
|
|
|
const formatDueDate = () => {
|
|
const today = new Date().toISOString().split('T')[0];
|
|
const tomorrow = new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString().split('T')[0];
|
|
const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString().split('T')[0];
|
|
|
|
if (dueDate === today) return 'TODAY';
|
|
if (dueDate === tomorrow) return 'TOMORROW';
|
|
if (dueDate === yesterday) return 'YESTERDAY';
|
|
|
|
// Format due date into a human-readable format
|
|
return new Date(dueDate).toLocaleDateString(undefined, {
|
|
year: 'numeric',
|
|
month: 'short',
|
|
day: 'numeric',
|
|
});
|
|
};
|
|
|
|
return (
|
|
<div className={`flex items-center text-xs py-1 px-2 rounded-md ${getDueDateClass()} ${className}`}>
|
|
<i className="bi bi-clock mr-1"></i>
|
|
{formatDueDate()}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default TaskDueDate;
|