From 40e81d1f59c550269a45c618de05c28d67be3368 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Tue, 1 Oct 2024 00:06:56 +0530 Subject: [PATCH] feat: use sendProxyConfig() --- src/components/organisms/ProxyForm.tsx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/components/organisms/ProxyForm.tsx b/src/components/organisms/ProxyForm.tsx index ae6f7d72..b92c9ae3 100644 --- a/src/components/organisms/ProxyForm.tsx +++ b/src/components/organisms/ProxyForm.tsx @@ -1,7 +1,8 @@ import React, { useState } from 'react'; -import { TextField, Button, RadioGroup, FormControlLabel, Radio, Box, Typography } from '@mui/material'; -import { styled } from '@mui/system'; import axios from 'axios'; +import { styled } from '@mui/system'; +import { TextField, Button, RadioGroup, FormControlLabel, Radio, Box, Typography } from '@mui/material'; +import { sendProxyConfig } from '../../api/proxy'; const FormContainer = styled(Box)({ display: 'flex', @@ -30,16 +31,13 @@ const ProxyForm: React.FC = () => { const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); - try { - const response = await axios.post('http://localhost:8080/proxy/config', proxyConfig); - if (response.status === 200) { - return response.data; - } else { - throw new Error(`Failed to submit proxy configuration. Try again.`); - } - } catch (error) { - alert('Error submitting proxy configuration'); - } + await sendProxyConfig(proxyConfig).then((response) => { + if (response) { + alert('Proxy configuration submitted successfully'); + } else { + alert('Failed to submit proxy configuration. Try again.'); + } + }); }; return (