import {BookSyncCompare, SyncedBook} from "@/lib/models/SyncedBook";
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[];
    localSyncedBooks:SyncedBook[];
    booksToSyncFromServer:BookSyncCompare[];
    booksToSyncToServer:BookSyncCompare[];
    setServerSyncedBooks:Dispatch<SetStateAction<SyncedBook[]>>;
    setLocalSyncedBooks:Dispatch<SetStateAction<SyncedBook[]>>;
    setServerOnlyBooks:Dispatch<SetStateAction<SyncedBook[]>>;
    setLocalOnlyBooks:Dispatch<SetStateAction<SyncedBook[]>>;
    setBooksToSyncFromServer:Dispatch<SetStateAction<BookSyncCompare[]>>;
    setBooksToSyncToServer:Dispatch<SetStateAction<BookSyncCompare[]>>;
    serverOnlyBooks:SyncedBook[];
    localOnlyBooks:SyncedBook[];
}

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