feat: F015 shortlist management
3-panel Shortlists page with left list, center detail, right decision brief panel. AddToShortlistDialog wired into result feed cards and match detail. Full DRAFT→REVIEW_READY→FINALIZED workflow, AI-generated decision brief draft, duplicate prevention, and compare-view integration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { shortlistService } from '../services/shortlistService'
|
||||
import type { CreateShortlistInput, UpdateShortlistInput, ShortlistItemInput } from '../domain/shortlist'
|
||||
|
||||
export function useShortlists() {
|
||||
return useQuery({
|
||||
queryKey: ['shortlists'],
|
||||
queryFn: () => shortlistService.getAll(),
|
||||
select: (res) => res.data ?? [],
|
||||
})
|
||||
}
|
||||
|
||||
export function useShortlist(id: string) {
|
||||
return useQuery({
|
||||
queryKey: ['shortlist', id],
|
||||
queryFn: () => shortlistService.getById(id),
|
||||
enabled: !!id,
|
||||
select: (res) => res.data ?? null,
|
||||
})
|
||||
}
|
||||
|
||||
export function useCreateShortlist() {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: (input: CreateShortlistInput) => shortlistService.create(input),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ['shortlists'] })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function useAddToShortlist() {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: ({ shortlistId, item }: { shortlistId: string; item: ShortlistItemInput }) =>
|
||||
shortlistService.addItem(shortlistId, item),
|
||||
onSuccess: (_data, { shortlistId }) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['shortlists'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['shortlist', shortlistId] })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function useRemoveFromShortlist() {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: ({ shortlistId, resultId }: { shortlistId: string; resultId: string }) =>
|
||||
shortlistService.removeItem(shortlistId, resultId),
|
||||
onSuccess: (_data, { shortlistId }) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['shortlists'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['shortlist', shortlistId] })
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function useUpdateShortlist() {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: ({ id, data }: { id: string; data: UpdateShortlistInput }) =>
|
||||
shortlistService.update(id, data),
|
||||
onSuccess: (_data, { id }) => {
|
||||
queryClient.invalidateQueries({ queryKey: ['shortlists'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['shortlist', id] })
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user