feat: use notify for alerts

This commit is contained in:
karishmas6
2024-10-01 00:09:06 +05:30
parent ca329e25b5
commit aabf48fa7e

View File

@@ -2,6 +2,7 @@ import React, { useState } from 'react';
import { styled } from '@mui/system'; import { styled } from '@mui/system';
import { TextField, Button, RadioGroup, FormControlLabel, Radio, Box, Typography } from '@mui/material'; import { TextField, Button, RadioGroup, FormControlLabel, Radio, Box, Typography } from '@mui/material';
import { sendProxyConfig } from '../../api/proxy'; import { sendProxyConfig } from '../../api/proxy';
import { useGlobalInfoStore } from '../../context/globalInfo';
const FormContainer = styled(Box)({ const FormContainer = styled(Box)({
display: 'flex', display: 'flex',
@@ -23,6 +24,8 @@ const ProxyForm: React.FC = () => {
password: '', password: '',
}); });
const { notify } = useGlobalInfoStore();
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 });
@@ -32,9 +35,9 @@ const ProxyForm: React.FC = () => {
e.preventDefault(); e.preventDefault();
await sendProxyConfig(proxyConfig).then((response) => { await sendProxyConfig(proxyConfig).then((response) => {
if (response) { if (response) {
alert('Proxy configuration submitted successfully'); notify('success','Proxy configuration submitted successfully');
} else { } else {
alert('Failed to submit proxy configuration. Try again.'); notify('error', 'Failed to submit proxy configuration. Try again.');
} }
}); });
}; };