-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: highlight overdue tasks (#156)
* feat: highlight overdue tasks * remove alert overdue tasks * only display overdue color in case task is not done * clean up --------- Co-authored-by: hudy@mac-air <[email protected]>
- Loading branch information
Showing
13 changed files
with
147 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useProjectStatusStore } from "@/store/status" | ||
import { useTaskStore } from "@/store/task" | ||
import { StatusType } from "@prisma/client" | ||
import { useMemo } from "react" | ||
|
||
export const useStatusUtils = () => { | ||
|
||
const { statuses } = useProjectStatusStore() | ||
const { tasks } = useTaskStore() | ||
|
||
const doneStatus = useMemo(() => { | ||
const doneIds: string[] = [] | ||
statuses.forEach(stt => { | ||
if (stt.type === StatusType.DONE) { | ||
doneIds.push(stt.id) | ||
} | ||
}) | ||
|
||
return doneIds | ||
}, [statuses.toString()]) | ||
|
||
|
||
const isDoneStatus = (statusId: string) => { | ||
return doneStatus.includes(statusId) | ||
} | ||
|
||
const getStatusTypeByTaskId = (taskId: string) => { | ||
const found = tasks.find(t => t.id === taskId) | ||
|
||
if (!found) return StatusType.TODO | ||
|
||
const foundStatus = statuses.find(stt => stt.id === found.taskStatusId) | ||
|
||
|
||
if (!foundStatus) return StatusType.TODO | ||
|
||
return foundStatus.type | ||
} | ||
|
||
return { | ||
isDoneStatus, | ||
getStatusTypeByTaskId, | ||
} | ||
} |
Oops, something went wrong.