import { Divider, Select, Option } from "@mui/joy"; import { useEffect, useState } from "react"; import { toast } from "react-hot-toast"; import { useTranslation } from "react-i18next"; import { useGlobalStore } from "@/store/module"; import * as api from "@/helpers/api"; import showCreateStorageServiceDialog from "../CreateStorageServiceDialog"; import showUpdateLocalStorageDialog from "../UpdateLocalStorageDialog"; import Dropdown from "../kit/Dropdown"; import { showCommonDialog } from "../Dialog/CommonDialog"; import HelpButton from "../kit/HelpButton"; const StorageSection = () => { const { t } = useTranslation(); const globalStore = useGlobalStore(); const systemStatus = globalStore.state.systemStatus; const [storageServiceId, setStorageServiceId] = useState(systemStatus.storageServiceId); const [storageList, setStorageList] = useState([]); useEffect(() => { fetchStorageList(); }, []); const fetchStorageList = async () => { const { data: { data: storageList }, } = await api.getStorageList(); setStorageList(storageList); }; const handleActiveStorageServiceChanged = async (storageId: StorageId) => { await api.upsertSystemSetting({ name: "storage-service-id", value: JSON.stringify(storageId), }); await globalStore.fetchSystemStatus(); setStorageServiceId(storageId); }; const handleDeleteStorage = (storage: ObjectStorage) => { showCommonDialog({ title: t("setting.storage-section.delete-storage"), content: t("setting.storage-section.warning-text", { name: storage.name }), style: "warning", dialogName: "delete-storage-dialog", onConfirm: async () => { try { await api.deleteStorage(storage.id); } catch (error: any) { console.error(error); toast.error(error.response.data.message); } await fetchStorageList(); }, }); }; return (
{t("setting.storage-section.current-storage")}
{t("setting.storage-section.storage-services-list")}

{t("setting.storage-section.type-local")}

} />
{storageList.map((storage) => (

{storage.name}

} />
))}
); }; export default StorageSection;