Skip to content

Commit

Permalink
fix(goal): show an inaccurate progress percentage (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
hudy9x authored Jun 25, 2024
1 parent cec4d48 commit 9139e1f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/ui-app/app/_features/Project/Vision/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import VisionContainer from './VisionContainer'
import './style.css'
import { Vision } from '@prisma/client'
import { useTaskStore } from '@/store/task'
import { useProjectStatusStore } from '@/store/status'
// import { useProjectStatusStore } from '@/store/status'
import { useStatusFuncs } from '@/hooks/useStatusUtils'

const useVisionByDates = (visions: VisionField[]) => {
const visionByDays: VisionByDays = {}
Expand All @@ -34,7 +35,8 @@ const useVisionByDates = (visions: VisionField[]) => {

const useVisionProgress = ({ visions }: { visions: VisionField[] }) => {
const { tasks } = useTaskStore()
const { statusDoneId } = useProjectStatusStore()
// const { statusDoneId } = useProjectStatusStore()
const { isDoneStatus } = useStatusFuncs()
//
const visionProgress: {
[key: string]: { total: number; done: number; assigneeIds: string[] }
Expand All @@ -60,7 +62,8 @@ const useVisionProgress = ({ visions }: { visions: VisionField[] }) => {
})
}

if (taskStatusId === statusDoneId) {
// if (taskStatusId === statusDoneId) {
if (isDoneStatus(taskStatusId || '')) {
visionProgress[visionId].done += 1
taskDone += 1
}
Expand Down
26 changes: 26 additions & 0 deletions packages/ui-app/app/_hooks/useStatusUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,29 @@ export const useStatusUtils = () => {
getStatusTypeByTaskId,
}
}


export const useStatusFuncs = () => {

const { statuses } = useProjectStatusStore()

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)
}


return {
isDoneStatus,
}
}

0 comments on commit 9139e1f

Please sign in to comment.