feat(react): add toasts, loading states, skeletons, animations, and mobile responsiveness

- Toast notifications (sonner): success/error toasts on all mutations
- Loading spinners: EntryCard add/remove, ConfirmDialog, EntrySeenDialog, favorite/refresh buttons
- Page skeletons: 13 page-specific Suspense fallbacks replacing generic skeleton
- CSS animations: card-enter (staggered), page-enter, slide-up-fade keyframes
- Mobile layout: hamburger menu with sheet sidebar, responsive entry details
- Mobile controls: separate compact filter/sort popovers for Library and Watchlist
- Desktop sort: popover menu replacing Select dropdown on Library and Watchlist
- Filter ranges: year 1950-2100, rating 0-10
This commit is contained in:
Mohammed Abad committed 2026-04-02 03:00:49 +01:00
1 parent ae67663623
commit d60d142d17
29 files changed
+1008 -226

No files matched your search

+25 -2
View File
@@ -1,4 +1,5 @@
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { toast } from 'sonner';
import { entriesApi } from '@/api/entries';
import { useLibraryStore } from '@/stores/useLibraryStore';
import type { Entry } from '@/types';
@@ -54,6 +55,10 @@ export function useCreateEntry() {
onSuccess: (entry) => {
addEntry(entry);
queryClient.invalidateQueries({ queryKey: entryKeys.all });
toast.success(`"${entry.title}" added to library`);
},
onError: () => {
toast.error('Failed to add entry to library');
},
});
}
@@ -66,11 +71,13 @@ export function useUpdateEntry() {
mutationFn: ({ id, data }: { id: number; data: Partial<Entry> }) =>
entriesApi.update(id, data),
onSuccess: (entry) => {
// Update library store immediately so the UI reflects the change
updateEntry(entry.id, entry);
// Invalidate both the detail query and the library list
queryClient.invalidateQueries({ queryKey: entryKeys.detail(entry.id) });
queryClient.invalidateQueries({ queryKey: entryKeys.all });
toast.success('Entry updated');
},
onError: () => {
toast.error('Failed to update entry');
},
});
}
@@ -84,6 +91,10 @@ export function useDeleteEntry() {
onSuccess: (_data, id) => {
removeEntry(id);
queryClient.invalidateQueries({ queryKey: entryKeys.all });
toast.success('Entry removed from library');
},
onError: () => {
toast.error('Failed to remove entry');
},
});
}
@@ -97,6 +108,10 @@ export function useRefreshEntry() {
onSuccess: (entry) => {
updateEntry(entry.id, entry);
queryClient.invalidateQueries({ queryKey: entryKeys.detail(entry.id) });
toast.success('Entry details refreshed');
},
onError: () => {
toast.error('Failed to refresh entry');
},
});
}
@@ -115,6 +130,10 @@ export function useUpdateEntryRatings() {
onSuccess: (_data, { id }) => {
queryClient.invalidateQueries({ queryKey: entryKeys.detail(id) });
queryClient.invalidateQueries({ queryKey: entryKeys.all });
toast.success('Rating updated');
},
onError: () => {
toast.error('Failed to update rating');
},
});
}
@@ -127,6 +146,10 @@ export function useUploadMedia() {
entriesApi.uploadMedia(id, formData),
onSuccess: (_data, { id }) => {
queryClient.invalidateQueries({ queryKey: entryKeys.detail(id) });
toast.success('Media uploaded successfully');
},
onError: () => {
toast.error('Failed to upload media');
},
});
}