feat: test proxy config

This commit is contained in:
karishmas6
2024-10-26 05:37:21 +05:30
parent ffe664664f
commit e3a818680c

View File

@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import { styled } from '@mui/system';
import { TextField, Button, Switch, FormControlLabel, Box, Typography, Tabs, Tab } from '@mui/material';
import { sendProxyConfig } from '../../api/proxy';
import { sendProxyConfig, getProxyConfig, testProxyConfig } from '../../api/proxy';
import { useGlobalInfoStore } from '../../context/globalInfo';
const FormContainer = styled(Box)({
@@ -28,6 +28,7 @@ const ProxyForm: React.FC = () => {
password: '',
});
const [tabIndex, setTabIndex] = useState(0);
const [isProxyConfigured, setIsProxyConfigured] = useState(false);
const { notify } = useGlobalInfoStore();
@@ -87,6 +88,17 @@ const ProxyForm: React.FC = () => {
setTabIndex(newValue);
};
// test proxy config
const testProxy = async () => {
await testProxyConfig().then((response) => {
if (response.success) {
notify('success', 'Proxy configuration is working');
} else {
notify('error', 'Failed to test proxy configuration. Try again.');
}
});
};
return (
<FormContainer>
<Typography variant="h6" gutterBottom component="div" style={{ marginTop: '20px' }}>