Fix task and shift self-assignment features
This commit is contained in:
@@ -16,6 +16,7 @@ export interface ShiftListItemDto {
|
||||
endTime: string;
|
||||
capacity: number;
|
||||
currentSignups: number;
|
||||
isSignedUp: boolean;
|
||||
}
|
||||
|
||||
export interface ShiftDetailDto {
|
||||
@@ -31,6 +32,7 @@ export interface ShiftDetailDto {
|
||||
createdById: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
isSignedUp: boolean;
|
||||
}
|
||||
|
||||
export interface ShiftSignupDto {
|
||||
|
||||
@@ -11,10 +11,9 @@ export interface TaskListDto {
|
||||
|
||||
export interface TaskListItemDto {
|
||||
id: string;
|
||||
title: string;
|
||||
status: string;
|
||||
assigneeId: string | null;
|
||||
createdAt: string;
|
||||
isAssignedToMe: boolean;
|
||||
}
|
||||
|
||||
export interface TaskDetailDto {
|
||||
@@ -28,6 +27,7 @@ export interface TaskDetailDto {
|
||||
dueDate: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
isAssignedToMe: boolean;
|
||||
}
|
||||
|
||||
export interface CreateTaskRequest {
|
||||
@@ -120,3 +120,41 @@ export function useUpdateTask() {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useAssignTask() {
|
||||
const queryClient = useQueryClient();
|
||||
const { activeClubId } = useTenant();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
const res = await apiClient(`/api/tasks/${id}/assign`, {
|
||||
method: 'POST',
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to assign task');
|
||||
return res;
|
||||
},
|
||||
onSuccess: (_, id) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['tasks', activeClubId] });
|
||||
queryClient.invalidateQueries({ queryKey: ['tasks', activeClubId, id] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useUnassignTask() {
|
||||
const queryClient = useQueryClient();
|
||||
const { activeClubId } = useTenant();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (id: string) => {
|
||||
const res = await apiClient(`/api/tasks/${id}/assign`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to unassign task');
|
||||
return res;
|
||||
},
|
||||
onSuccess: (_, id) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['tasks', activeClubId] });
|
||||
queryClient.invalidateQueries({ queryKey: ['tasks', activeClubId, id] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user