* Add next suggestions and remove console logs * Add pomodoro timer * Add pomodoro switch in settings * Fix pomodoro setting * Add timezones to settings * Fix an issue with password reset * Cleanup * Sort tags alphabetically * Clean up today's view * Add an indicator for repeatedly added to today * Refactor tags * Add due date today item * Move recurrence to the subtitle area * Fix today layout * Add a badge to Inbox items * Move inbox badge to sidebar * Add quotes and progress bar * Add translations for quotes * Fix test issues * Add helper script for docker local * Set up overdue tasks * Add linux/arm/v7 build to deploy script * Add linux/arm/v7 build to deploy script pt2 * Fix an issue with helmet and SSL * Add volume db persistence * Fix cog icon issues
64 lines
1.7 KiB
TypeScript
64 lines
1.7 KiB
TypeScript
import React from 'react';
|
|
import { CheckCircleIcon } from '@heroicons/react/24/solid';
|
|
import { CheckCircleIcon as CheckCircleOutlineIcon } from '@heroicons/react/24/outline';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
interface TaskPriorityIconProps {
|
|
priority: string | number | undefined;
|
|
status: string | number;
|
|
onToggleCompletion?: () => void;
|
|
}
|
|
|
|
const TaskPriorityIcon: React.FC<TaskPriorityIconProps> = ({ priority, status, onToggleCompletion }) => {
|
|
const { t } = useTranslation();
|
|
const getIconColor = () => {
|
|
if (status === 'done' || status === 2) return 'text-green-500';
|
|
|
|
// Handle both string and numeric priority values
|
|
let priorityStr = priority;
|
|
if (typeof priority === 'number') {
|
|
const priorityNames = ['low', 'medium', 'high'];
|
|
priorityStr = priorityNames[priority] || 'low';
|
|
}
|
|
|
|
switch (priorityStr) {
|
|
case 'high':
|
|
case 2:
|
|
return 'text-red-500';
|
|
case 'medium':
|
|
case 1:
|
|
return 'text-yellow-500';
|
|
case 'low':
|
|
case 0:
|
|
default:
|
|
return 'text-gray-300';
|
|
}
|
|
};
|
|
|
|
const colorClass = getIconColor();
|
|
|
|
const handleClick = (e: React.MouseEvent) => {
|
|
e.stopPropagation(); // Prevent triggering TaskHeader onClick
|
|
if (onToggleCompletion) {
|
|
onToggleCompletion();
|
|
}
|
|
};
|
|
|
|
if (status === 'done' || status === 2) {
|
|
return (
|
|
<CheckCircleIcon
|
|
className={`h-5 w-5 ${colorClass} cursor-pointer hover:scale-110 transition-transform`}
|
|
onClick={handleClick}
|
|
/>
|
|
);
|
|
} else {
|
|
return (
|
|
<CheckCircleOutlineIcon
|
|
className={`h-5 w-5 ${colorClass} cursor-pointer hover:scale-110 transition-transform`}
|
|
onClick={handleClick}
|
|
/>
|
|
);
|
|
}
|
|
};
|
|
|
|
export default TaskPriorityIcon;
|