mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-16 03:00:09 +00:00
338331d006
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.
48 lines
1.1 KiB
TypeScript
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 };
|
|
}
|