import React from "react";

type Params = {
    initialLoading?: boolean;
    initialReady?: 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);

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