Skip to content

Commit

Permalink
fix: select all tasks as checking on None status (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
hudy9x authored Apr 13, 2024
1 parent 55ec4fe commit a1ba6fa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useTaskFilter } from '@/features/TaskFilter/context'
import useTaskFilterContext from '@/features/TaskFilter/useTaskFilterContext'
import { useProjectStatusStore } from '@/store/status'
import { useTaskStore } from '@/store/task'
import { Form } from '@shared/ui'
import { useEffect, useMemo, useState } from 'react'
Expand All @@ -10,17 +10,30 @@ export default function TaskCheckAll({ groupId }: { groupId: string }) {
useTaskStore()
const { groupBy, isGroupbyStatus, isGroupbyAssignee, isGroupbyPriority } =
useTaskFilterContext()
const { statuses } = useProjectStatusStore()

const taskIds = useMemo(() => {
const ids: string[] = []
tasks.forEach(task => {
if (isGroupbyStatus && task.taskStatusId !== groupId) {
if (groupId === 'NONE') {
ids.push(task.id)
return
}
const projectStatusIds = statuses.map(stt => stt.id)
const getIdsByStatus = ({ statusId, taskId }: { statusId: string, taskId: string }) => {
if (statusId === groupId) {
ids.push(taskId)
return
}

return null
if (groupId === 'NONE' && !projectStatusIds.includes(statusId)) {
ids.push(taskId)
return
}
}

tasks.forEach(task => {
if (isGroupbyStatus) {
getIdsByStatus({
statusId: task.taskStatusId || '',
taskId: task.id
})
return
}

if (isGroupbyAssignee) {
Expand All @@ -37,13 +50,15 @@ export default function TaskCheckAll({ groupId }: { groupId: string }) {
return null
}

console.log(isGroupbyStatus, task.taskStatusId, groupId)
ids.push(task.id)
})

return ids
}, [groupBy, groupId, taskLoading, JSON.stringify(tasks)])
}, [groupBy, JSON.stringify(statuses), groupId, taskLoading, JSON.stringify(tasks)])

const onChecked = (checked: boolean) => {
console.log('taskids', taskIds)
toggleMultipleSelected(checked, taskIds)
}

Expand Down Expand Up @@ -77,7 +92,7 @@ export default function TaskCheckAll({ groupId }: { groupId: string }) {
setChecked(true)
}
}
}, [selected, taskIds, checked])
}, [selected, JSON.stringify(tasks), checked])

return (
<Form.Checkbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function TaskImportAction() {
// const projectId = _projectId
const title = _title
const assigneeIds = toAssigneeIds(_assigneeIds)
const dueDate = _dueDate ? new Date(_dueDate) : null
const dueDate = _dueDate ? new Date(_dueDate) : new Date()
const priority = toValidPriority(_priority)
const taskPoint = _taskPoint ? parseInt(_taskPoint, 10) : null
const taskStatusId = toValidStatusId(_taskStatusId)
Expand Down
2 changes: 0 additions & 2 deletions packages/ui-app/app/_features/TaskMultipleActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export default function TaskMultipleActions() {
setData(structuredClone({ ...defaultData }))
}

console.log('multiple select', hasSelected)

return (
<div
className={`fixed top-0 left-0 w-full py-3 border-b border-color-base bg-base shadow-lg transition-all z-40 ${hasSelected
Expand Down

0 comments on commit a1ba6fa

Please sign in to comment.