import {Context, createContext, Dispatch, SetStateAction} from "react";

export interface LocalSyncOperation {
    id: string;
    channel: string;
    data: Record<string, unknown>;
    timestamp: number;
}

export interface LocalSyncQueueContextProps {
    queue: LocalSyncOperation[];
    setQueue: Dispatch<SetStateAction<LocalSyncOperation[]>>;
    addToQueue: (channel: string, data: Record<string, unknown>) => void;
    isProcessing: boolean;
}

export const LocalSyncQueueContext: Context<LocalSyncQueueContextProps> = createContext<LocalSyncQueueContextProps>({
    queue: [],
    setQueue: (): void => {},
    addToQueue: (): void => {},
    isProcessing: false,
});
