import { useState } from 'react';
import { notify } from '../../components/Notification';
export const useFakeLogic = ({ initialValue, containerId, }) => {
    const [value, setValue] = useState(initialValue);
    const [isLoading, setIsLoading] = useState(false);
    const onSubmit = (newValue) => {
        setIsLoading(true);
        new Promise((resolve) => setTimeout(() => {
            resolve(newValue);
        }, 1000))
            .then((response) => {
            setValue(response);
            notify.success('Данные успешно обновлены', { containerId });
        })
            .finally(() => {
            setIsLoading(false);
        });
    };
    return {
        value,
        isLoading,
        onSubmit,
    };
};
