import { FormControl, FormField, FormItem, FormLabel, Input, Switch, } from "@marzneshin/common/components"; import { useFormContext, useWatch } from "react-hook-form"; import { useTranslation } from "react-i18next"; export const SplitHttpXmuxFields = () => { const { t } = useTranslation(); const form = useFormContext(); const xmux = useWatch({ name: "splithttp_settings.xmux" }); const isXMuxDisabled = xmux === null; const updateFieldValue = (path: string, value: any) => { form.setValue(path, value === "" ? null : value, { shouldDirty: true, shouldValidate: true, }); }; return (
{t("page.hosts.xmux-settings")} form.setValue( "splithttp_settings.xmux", checked ? { xmux: {} } : null, ) } /> {!isXMuxDisabled && (
{[ "max_concurrency", "max_connections", "max_reuse_times", "max_lifetime", "max_request_times", ].map((fieldName) => ( ( {t(`${fieldName.replace(/_/g, " ")}`)} updateFieldValue( `splithttp_settings.xmux.${fieldName}`, e.target.value, ) } className="w-full" /> )} /> ))} ( Keep Alive Period updateFieldValue( `splithttp_settings.xmux.keep_alive_period`, e.target.value === "" ? null : Number.parseInt( e.target.value, ), ) } className="w-full" /> )} />
)}
); };