import {BookSyncCompare, SyncedBook} from "@/lib/types/synced-book";
import {Context, createContext, Dispatch, SetStateAction} from "react";

export type SyncType = 'server-only' | 'local-only' | 'to-sync-from-server' | 'to-sync-to-server' | 'synced'

export interface BooksSyncContextProps {
    serverSyncedBooks: SyncedBook[];
    setServerSyncedBooks: Dispatch<SetStateAction<SyncedBook[]>>;
    localSyncedBooks: SyncedBook[];
    setLocalSyncedBooks: Dispatch<SetStateAction<SyncedBook[]>>;
    booksToSyncFromServer: BookSyncCompare[];
    setBooksToSyncFromServer: Dispatch<SetStateAction<BookSyncCompare[]>>;
    booksToSyncToServer: BookSyncCompare[];
    setBooksToSyncToServer: Dispatch<SetStateAction<BookSyncCompare[]>>;
    setServerOnlyBooks: Dispatch<SetStateAction<SyncedBook[]>>;
    setLocalOnlyBooks: Dispatch<SetStateAction<SyncedBook[]>>;
    serverOnlyBooks: SyncedBook[];
    localOnlyBooks: SyncedBook[];
}

export const BooksSyncContext: Context<BooksSyncContextProps> = createContext<BooksSyncContextProps>({
    serverSyncedBooks: [],
    setServerSyncedBooks: (): void => {},
    localSyncedBooks: [],
    setLocalSyncedBooks: (): void => {},
    booksToSyncFromServer: [],
    setBooksToSyncFromServer: (): void => {},
    booksToSyncToServer: [],
    setBooksToSyncToServer: (): void => {},
    setServerOnlyBooks: (): void => {},
    setLocalOnlyBooks: (): void => {},
    serverOnlyBooks: [],
    localOnlyBooks: []
});
