import { useTranslation } from "react-i18next"; import { app } from "../app" import { ErrorAlert, InfoAlert } from "../components/alert" import { useEffect, useState } from "react"; import { ServerConfig } from "../network/models"; import Loading from "../components/loading"; import Input from "../components/input"; import { network } from "../network/network"; import showToast from "../components/toast"; import Button from "../components/button"; export default function ManageServerConfigPage() { const { t } = useTranslation(); const [config, setConfig] = useState(null); const [isLoading, setIsLoading] = useState(false); useEffect(() => { network.getServerConfig().then((res) => { if (res.success) { setConfig(res.data!); } else { showToast({ message: res.message, type: "error", }) } }) }, []); if (!app.user) { return } if (!app.user?.is_admin) { return } if (config == null) { return } const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (isLoading) { return; } setIsLoading(true); const res = await network.setServerConfig(config); if (res.success) { showToast({ message: t("Update server config successfully"), type: "success", }); } else { showToast({ message: res.message, type: "error", }); } setIsLoading(false); }; return
{ setConfig({...config, max_uploading_size_in_mb: parseInt(e.target.value) }) }}> { setConfig({...config, max_file_size_in_mb: parseInt(e.target.value) }) }}> { setConfig({...config, max_downloads_per_day_for_single_ip: parseInt(e.target.value) }) }}>
Allow register { setConfig({ ...config, allow_register: e.target.checked }) }} />
{ setConfig({...config, cloudflare_turnstile_site_key: e.target.value }) }}> { setConfig({...config, cloudflare_turnstile_secret_key: e.target.value }) }}>
}