import { createDraftStore } from '@/lib/draft-store';

export type RestockDraftData = {
    stockType: 'good' | 'reject';
    selectedProductId: string;
    quantities: Record<string, number>;
    notes: string;
    photo?: string;
};

export const restockDraftStore =
    createDraftStore<RestockDraftData>('restock-draft');

export function saveRestockDraft(
    type: 'create' | 'edit',
    data: RestockDraftData,
    userId?: number,
): boolean {
    return restockDraftStore.save(type, data, userId);
}

export function loadRestockDraft(
    type: 'create' | 'edit',
    userId?: number,
): RestockDraftData | null {
    return restockDraftStore.load(type, userId);
}

export function clearRestockDraft(
    type: 'create' | 'edit',
    userId?: number,
): void {
    restockDraftStore.clear(type, userId);
}
