feat: use notify for alerts
This commit is contained in:
@@ -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.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user