chore: lint
This commit is contained in:
@@ -4,96 +4,96 @@ import { styled } from '@mui/system';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
const FormContainer = styled(Box)({
|
const FormContainer = styled(Box)({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
gap: '16px',
|
gap: '16px',
|
||||||
padding: '20px',
|
padding: '20px',
|
||||||
backgroundColor: '#f9f9f9',
|
backgroundColor: '#f9f9f9',
|
||||||
borderRadius: '8px',
|
borderRadius: '8px',
|
||||||
});
|
});
|
||||||
|
|
||||||
const FormControl = styled(Box)({
|
const FormControl = styled(Box)({
|
||||||
marginBottom: '16px',
|
marginBottom: '16px',
|
||||||
});
|
});
|
||||||
|
|
||||||
const ProxyForm: React.FC = () => {
|
const ProxyForm: React.FC = () => {
|
||||||
const [proxyConfig, setProxyConfig] = useState({
|
const [proxyConfig, setProxyConfig] = useState({
|
||||||
type: 'http',
|
type: 'http',
|
||||||
server: '',
|
server: '',
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const { name, value } = e.target;
|
const { name, value } = e.target;
|
||||||
setProxyConfig({ ...proxyConfig, [name]: value });
|
setProxyConfig({ ...proxyConfig, [name]: value });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
try {
|
try {
|
||||||
const response = await axios.post('/api/proxy', proxyConfig);
|
const response = await axios.post('/api/proxy', proxyConfig);
|
||||||
alert(`Success!`);
|
alert(`Success!`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert('Error submitting proxy configuration');
|
alert('Error submitting proxy configuration');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormContainer>
|
<FormContainer>
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
name="type"
|
name="type"
|
||||||
value={proxyConfig.type}
|
value={proxyConfig.type}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
row
|
row
|
||||||
>
|
>
|
||||||
<FormControlLabel value="http" control={<Radio />} label="HTTP" />
|
<FormControlLabel value="http" control={<Radio />} label="HTTP" />
|
||||||
<FormControlLabel value="https" control={<Radio />} label="HTTPS" />
|
<FormControlLabel value="https" control={<Radio />} label="HTTPS" />
|
||||||
<FormControlLabel value="socks5" control={<Radio />} label="SOCKS5" />
|
<FormControlLabel value="socks5" control={<Radio />} label="SOCKS5" />
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<TextField
|
<TextField
|
||||||
label="Proxy Server URL"
|
label="Proxy Server URL"
|
||||||
name="server"
|
name="server"
|
||||||
value={proxyConfig.server}
|
value={proxyConfig.server}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
fullWidth
|
fullWidth
|
||||||
required
|
required
|
||||||
helperText="e.g., http://proxy-server.com:8080"
|
helperText="e.g., http://proxy-server.com:8080"
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<TextField
|
<TextField
|
||||||
label="Username (Optional)"
|
label="Username (Optional)"
|
||||||
name="username"
|
name="username"
|
||||||
value={proxyConfig.username}
|
value={proxyConfig.username}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<TextField
|
<TextField
|
||||||
label="Password (Optional)"
|
label="Password (Optional)"
|
||||||
name="password"
|
name="password"
|
||||||
value={proxyConfig.password}
|
value={proxyConfig.password}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
type="password"
|
type="password"
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
|
||||||
<Button variant="contained" color="primary" type="submit" fullWidth>
|
<Button variant="contained" color="primary" type="submit" fullWidth>
|
||||||
Add Proxy
|
Add Proxy
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</FormContainer>
|
</FormContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProxyForm;
|
export default ProxyForm;
|
||||||
|
|||||||
Reference in New Issue
Block a user