import { Button, Input, Typography } from "@mui/joy"; import { useState } from "react"; import { toast } from "react-hot-toast"; import { useGlobalStore } from "@/store/module"; import * as api from "@/helpers/api"; import { generateDialog } from "./Dialog"; import Icon from "./Icon"; interface Props extends DialogProps { localStoragePath?: string; confirmCallback?: () => void; } const UpdateLocalStorageDialog: React.FC = (props: Props) => { const { destroy, localStoragePath, confirmCallback } = props; const globalStore = useGlobalStore(); const [path, setPath] = useState(localStoragePath || ""); const handleCloseBtnClick = () => { destroy(); }; const handleConfirmBtnClick = async () => { try { await api.upsertSystemSetting({ name: "local-storage-path", value: JSON.stringify(path), }); await globalStore.fetchSystemStatus(); } catch (error: any) { console.error(error); toast.error(error.response.data.message); } if (confirmCallback) { confirmCallback(); } destroy(); }; return ( <>

Update local storage path

Local Path {"e.g., {year}/{month}/{day}/your/path/{timestamp}_{filename}"} setPath(e.target.value)} fullWidth />
); }; function showUpdateLocalStorageDialog(localStoragePath?: string, confirmCallback?: () => void) { generateDialog( { className: "update-local-storage-dialog", dialogName: "update-local-storage-dialog", }, UpdateLocalStorageDialog, { localStoragePath, confirmCallback } ); } export default showUpdateLocalStorageDialog;