Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
lilia1891 committed Oct 29, 2024
1 parent 94654ca commit b0ff0e1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions components/actions/TaskList.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ function parseTimestamp(timestamp) {
return dayjs(timestamp).format(timeFormat);
}

const isTaskLate = (task, completed) => {
return !completed && new Date(task.dueAt) < new Date();
};

const Task = (props) => {
const t = useTranslations();
const locale = useLocale();
Expand All @@ -154,7 +158,7 @@ const Task = (props) => {
getDateFormat(dateFormat)
);

const isLate = !completed && new Date(task.dueAt) < new Date();
const isLate = isTaskLate(task, completed);

return (
<TaskWrapper>
Expand Down Expand Up @@ -229,7 +233,7 @@ function TaskList(props) {
return sortedTasks
.filter((item) => item.state === state)
.map((item) => {
const isLate = !completed && new Date(item.dueAt) < new Date();
const isLate = isTaskLate(item, completed);
return (
<ListGroupItem
key={item.id}
Expand Down

0 comments on commit b0ff0e1

Please sign in to comment.