Files
ReadMeABook/src/lib/hooks/useGoodreadsShelves.ts
T
kikootwo 338331d006 Add Hardcover shelf sync & unify book mappings
Introduce Hardcover provider support and consolidate per-provider book mapping tables into a unified BookMapping model. Adds two Prisma migrations (add_hardcover_shelves, unify_book_mappings), new backend services (hardcover-api, shelf-sync-core), and provider-specific sync logic and API routes for hardcover shelves with token/list validation. Frontend: new HardcoverForm component, refactor AddShelfModal to support Hardcover, hook updates, and small UI/accessibility tweaks. Also add documentation for Goodreads and Hardcover sync flows and update tests to cover scheduler/prisma helpers.
2026-03-04 10:11:19 -05:00

48 lines
1.1 KiB
TypeScript

/**
* Component: Goodreads Shelves Hook
* Documentation: documentation/frontend/components.md
*/
'use client';
import { createShelfHooks, ShelfBook } from './createShelfHooks';
export type { ShelfBook };
export interface GoodreadsShelf {
id: string;
name: string;
rssUrl: string;
lastSyncAt: string | null;
createdAt: string;
bookCount: number | null;
books: ShelfBook[];
}
const { useList, useAdd, useDelete, useUpdate } =
createShelfHooks<GoodreadsShelf>('/api/user/goodreads-shelves');
export const useGoodreadsShelves = useList;
export function useAddGoodreadsShelf() {
const { addShelf: addGeneric, isLoading, error } = useAdd();
const addShelf = async (rssUrl: string) => {
return addGeneric({ rssUrl });
};
return { addShelf, isLoading, error };
}
export const useDeleteGoodreadsShelf = useDelete;
export function useUpdateGoodreadsShelf() {
const { updateShelf: updateGeneric, isLoading, error } = useUpdate();
const updateShelf = async (shelfId: string, rssUrl: string) => {
return updateGeneric(shelfId, { rssUrl });
};
return { updateShelf, isLoading, error };
}