"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useFakeLogic = void 0;
const react_1 = require("react");
const Notification_1 = require("../../components/Notification");
const useFakeLogic = ({ initialValue, containerId, }) => {
    const [value, setValue] = (0, react_1.useState)(initialValue);
    const [isLoading, setIsLoading] = (0, react_1.useState)(false);
    const onSubmit = (newValue) => {
        setIsLoading(true);
        new Promise((resolve) => setTimeout(() => {
            resolve(newValue);
        }, 1000))
            .then((response) => {
            setValue(response);
            Notification_1.notify.success('Данные успешно обновлены', { containerId });
        })
            .finally(() => {
            setIsLoading(false);
        });
    };
    return {
        value,
        isLoading,
        onSubmit,
    };
};
exports.useFakeLogic = useFakeLogic;
