import { WebApplication } from '@/ui_models/application'; import { AppState } from '@/ui_models/app_state'; import { observer } from 'mobx-react-lite'; import { FunctionComponent } from 'preact'; import { useState } from 'preact/hooks'; import { Checkbox } from '../Checkbox'; import { Icon } from '../Icon'; import { InputWithIcon } from '../InputWithIcon'; type Props = { application: WebApplication; appState: AppState; disabled?: boolean; }; export const AdvancedOptions: FunctionComponent = observer( ({ appState, application, disabled = false, children }) => { const { server, setServer, enableServerOption, setEnableServerOption } = appState.accountMenu; const [showAdvanced, setShowAdvanced] = useState(false); const handleServerOptionChange = (e: Event) => { if (e.target instanceof HTMLInputElement) { setEnableServerOption(e.target.checked); } }; const handleSyncServerChange = (e: Event) => { if (e.target instanceof HTMLInputElement) { setServer(e.target.value); application.setCustomHost(e.target.value); } }; const toggleShowAdvanced = () => { setShowAdvanced(!showAdvanced); }; return ( <> {showAdvanced ? (
{children}
) : null} ); } );