import React from "react";

type Params = {
    initialLoading?: boolean;
    initialReady?: boolean;
    initialOpen?: boolean;
};

export type UseStatusStatusType = {
    msg?: string;
    error?: boolean;
};

export default function useStatus(params?: Params) {
    const [refresh, setRefresh] = React.useState(0);
    const [loading, setLoading] = React.useState(
        params?.initialLoading || false,
    );
    const [status, setStatus] = React.useState<UseStatusStatusType>({});
    const [ready, setReady] = React.useState(params?.initialReady || false);
    const [open, setOpen] = React.useState(params?.initialOpen || false);

    return {
        refresh,
        setRefresh,
        loading,
        setLoading,
        status,
        setStatus,
        ready,
        setReady,
        open,
        setOpen,
    };
}
