import { create } from 'zustand';

type AppState = {
    isComplete: boolean;
    excess: number;
    precision: number;
    showFullRefreshButton: boolean;
    setInitial: (isComplete: boolean, excess: number, precision: number) => void;
    updateFromResponse: (isComplete: boolean | undefined, excess: number | undefined, precision: number | undefined) => void;
    markAsComplete: () => void;
    markAsIncomplete: () => void;
    setFullRefreshButton: (b: boolean) => void;
};

export const useGlobalZustandState = create<AppState>((set) => ({
    isComplete: false,
    showFullRefreshButton: false,
    excess: 0,
    precision: 0,

    setInitial: (isComplete, excess, precision) => set({ isComplete, excess, precision }),
    updateFromResponse: (isComplete, excess, precision) => set({ isComplete, excess, precision }),
    markAsComplete: () => set({isComplete: true}),
    markAsIncomplete: () => set({isComplete: false}),
    setFullRefreshButton: (showFullRefreshButton: boolean) => set({showFullRefreshButton}),
}));