mirror of
https://github.com/kikootwo/ReadMeABook.git
synced 2026-06-03 04:40: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.
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
/**
|
|
* Component: Hardcover Shelves Hook
|
|
* Documentation: documentation/frontend/components.md
|
|
*/
|
|
|
|
'use client';
|
|
|
|
import { createShelfHooks, ShelfBook } from './createShelfHooks';
|
|
|
|
export type { ShelfBook };
|
|
|
|
export interface HardcoverShelf {
|
|
id: string;
|
|
name: string;
|
|
listId: string;
|
|
lastSyncAt: string | null;
|
|
createdAt: string;
|
|
bookCount: number | null;
|
|
books: ShelfBook[];
|
|
}
|
|
|
|
const { useList, useAdd, useDelete, useUpdate } =
|
|
createShelfHooks<HardcoverShelf>('/api/user/hardcover-shelves');
|
|
|
|
export const useHardcoverShelves = useList;
|
|
|
|
export function useAddHardcoverShelf() {
|
|
const { addShelf: addGeneric, isLoading, error } = useAdd();
|
|
|
|
const addShelf = async (apiToken: string, listId: string) => {
|
|
return addGeneric({ apiToken, listId });
|
|
};
|
|
|
|
return { addShelf, isLoading, error };
|
|
}
|
|
|
|
export const useDeleteHardcoverShelf = useDelete;
|
|
|
|
export function useUpdateHardcoverShelf() {
|
|
const { updateShelf: updateGeneric, isLoading, error } = useUpdate();
|
|
|
|
const updateShelf = async (
|
|
shelfId: string,
|
|
updates: { listId?: string; apiToken?: string },
|
|
) => {
|
|
return updateGeneric(shelfId, updates);
|
|
};
|
|
|
|
return { updateShelf, isLoading, error };
|
|
}
|