Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions api/tasks/tasks.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export const TasksApi = {

updateTask: {
key: ['tasksApi.updateTask'],
fn: async ({ id, ...task }: UpdateTaskDto): Promise<void> => {
await apiClient.patch<TTask>(`/v1/tasks/${id}/update`, task)
fn: async ({ id, ...task }: UpdateTaskDto): Promise<TTask> => {
const { data } = await apiClient.patch<TTask>(`/v1/tasks/${id}/update`, task)
return data
},
},

Expand Down
9 changes: 8 additions & 1 deletion components/edit-task-button.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { USER_TYPE_ENUM } from '@/api/common/common-enum'
import { TasksApi } from '@/api/tasks/tasks.api'
import { TTask } from '@/api/tasks/tasks.types'
import { TodoUtil } from '@/lib/todo-util'
Expand All @@ -21,8 +22,14 @@ export const EditTodoButton = ({ todo }: EditTodoButtonProps) => {

const updateTaskMutation = useMutation({
mutationFn: TasksApi.updateTask.fn,
onSuccess: () => {
onSuccess: (res) => {
void queryClient.invalidateQueries({ queryKey: TasksApi.getTasks.key() })

if (res.assignee?.user_type === USER_TYPE_ENUM.TEAM) {
void queryClient.invalidateQueries({
queryKey: TasksApi.getTasks.key(res.assignee.assignee_id),
})
}
toast.success('Todo updated successfully')
setShowEditTaskForm(false)
},
Expand Down
2 changes: 1 addition & 1 deletion components/reassign-user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const ReassignUserModal = ({
onSuccess: () => {
toast.success(`Task assigned to ${selectedUser?.name}`)
void queryClient.invalidateQueries({ queryKey: TasksApi.getTasks.key(teamId) })
void queryClient.invalidateQueries({ queryKey: TasksApi.getTasks.key() })
onOpenChange(false)
setSelectedUser(null)
},
Expand All @@ -52,7 +53,6 @@ const ReassignUserModal = ({
const handleReassign = () => {
if (!selectedUser) return

debugger
reassignTaskMutation.mutate({
task_id: taskId,
executor_id: selectedUser.id,
Expand Down
11 changes: 9 additions & 2 deletions modules/dashboard/components/create-todo-button.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { USER_TYPE_ENUM } from '@/api/common/common-enum'
import { TasksApi } from '@/api/tasks/tasks.api'
import { CreateEditTodoDialog } from '@/components/create-edit-todo-dialog'
import { Button } from '@/components/ui/button'
Expand All @@ -12,9 +13,15 @@ export const CreateTodoButton = () => {

const createTaskMutation = useMutation({
mutationFn: TasksApi.createTask.fn,
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: TasksApi.getTasks.key() })
onSuccess: (res) => {
void queryClient.invalidateQueries({ queryKey: TasksApi.getTasks.key() })

if (res.assignee?.user_type === USER_TYPE_ENUM.TEAM) {
void queryClient.invalidateQueries({
queryKey: TasksApi.getTasks.key(res.assignee.assignee_id),
})
}

toast.success('Todo created successfully')
setShowCreateTaskForm(false)
},
Expand Down