"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSelfFiles = void 0;
const react_1 = require("react");
const constants_1 = require("../../constants");
const useSelfFiles = () => {
    const [selfFiles, setSelfFiles] = (0, react_1.useState)({});
    const setLoadingStatusFile = (0, react_1.useCallback)((fileId, progress) => setSelfFiles((currentFiles) => ({
        ...currentFiles,
        [fileId]: {
            ...currentFiles[fileId],
            status: { ...constants_1.DEFAULT_FILE_STATUS, isLoading: true, progress },
        },
    })), []);
    const setSuccessStatusFile = (0, react_1.useCallback)((fileId) => setSelfFiles((currentFiles) => ({
        ...currentFiles,
        [fileId]: { ...currentFiles[fileId], status: constants_1.DEFAULT_FILE_STATUS },
    })), []);
    const setErrorStatusFile = (0, react_1.useCallback)((fileId, errorMsg) => setSelfFiles((currentFiles) => ({
        ...currentFiles,
        [fileId]: {
            ...currentFiles[fileId],
            status: { ...constants_1.DEFAULT_FILE_STATUS, isUploadError: true, errorMsg },
        },
    })), []);
    const updateFileInfo = (0, react_1.useCallback)((fileId, data) => setSelfFiles((currentFiles) => ({
        ...currentFiles,
        [fileId]: { ...currentFiles[fileId], ...data },
    })), []);
    return {
        selfFiles,
        setLoadingStatusFile,
        setSuccessStatusFile,
        setErrorStatusFile,
        updateFileInfo,
    };
};
exports.useSelfFiles = useSelfFiles;
