feat(frontend): navigate non-library entries to TMDB preview page
- Add TmdbPreviewPage showing TMDB details without adding to library - Display backdrop, poster, title, tagline, genres, rating, storyline - Show season/episode count for TV series - Add "Add to Library" button that creates entry then redirects to details page - Show "Already in Library — View" if entry exists in DB - Add /entry/tmdb/:type/:tmdbId route in router.tsx - Add TmdbPreview type, entriesApi.previewTmdb(), and useTmdbPreview() hook - Update EntryCard to navigate to preview page instead of auto-adding Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
1 parent
25b645a16f
commit
02cdcf733d
18 files changed
+949
-204
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { useQuery, useMutation } from '@tanstack/react-query';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { toast } from 'sonner';
|
||||
import { peopleApi } from '@/api/people';
|
||||
|
||||
export const peopleKeys = {
|
||||
@@ -38,3 +39,27 @@ export function useFetchPersonByTmdbId() {
|
||||
mutationFn: (tmdb_id: number) => peopleApi.fetchByTmdbId(tmdb_id),
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdatePerson() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ id, data }: { id: number; data: Partial<import('@/types').People> }) =>
|
||||
peopleApi.update(id, data),
|
||||
onSuccess: (updatedPerson) => {
|
||||
queryClient.invalidateQueries({ queryKey: peopleKeys.detail(updatedPerson.id) });
|
||||
toast.success('Person updated');
|
||||
},
|
||||
onError: () => {
|
||||
toast.error('Failed to update person');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useSearchLocalPeople(query: string) {
|
||||
return useQuery({
|
||||
queryKey: ['people', 'search', query],
|
||||
queryFn: () => query === '*' ? peopleApi.getAll() : peopleApi.search(query),
|
||||
enabled: query.length > 0,
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user