feat(11-02): add useReorderCandidates hook, candidateViewMode, and CandidateListItem component
- Add useReorderCandidates mutation hook with apiPatch to /candidates/reorder endpoint - Add candidateViewMode (list|grid) state and setCandidateViewMode to uiStore - Create CandidateListItem component with drag handle, rank badge, horizontal layout - Export RankBadge helper (gold/silver/bronze medal icons for top 3) - Add style prop support to LucideIcon component - Add pros/cons fields to CandidateWithCategory in useThreads.ts
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import type { CreateCandidate, UpdateCandidate } from "../../shared/types";
|
||||
import { apiDelete, apiPost, apiPut } from "../lib/api";
|
||||
import { apiDelete, apiPatch, apiPost, apiPut } from "../lib/api";
|
||||
|
||||
interface CandidateResponse {
|
||||
id: number;
|
||||
@@ -62,3 +62,17 @@ export function useDeleteCandidate(threadId: number) {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useReorderCandidates(threadId: number) {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (data: { orderedIds: number[] }) =>
|
||||
apiPatch<{ success: boolean }>(
|
||||
`/api/threads/${threadId}/candidates/reorder`,
|
||||
data,
|
||||
),
|
||||
onSettled: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["threads", threadId] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user