updated and improved ip address validation
This commit is contained in:
@@ -35,6 +35,14 @@ const ModemSettings = () => {
|
||||
};
|
||||
|
||||
const handleSubmit = async (values: ModemSettingsType) => {
|
||||
const invalidPrimary = ValidateIPaddress(values.serverPrimary);
|
||||
const invalidSecondary = ValidateIPaddress(values.serverSecondary);
|
||||
if (invalidPrimary || invalidSecondary) {
|
||||
toast.error(invalidPrimary || invalidSecondary, {
|
||||
id: "invalid-ip",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const modemConfig = {
|
||||
id: "ModemAndWifiManager-modem",
|
||||
fields: [
|
||||
@@ -68,7 +76,7 @@ const ModemSettings = () => {
|
||||
|
||||
const response = await modemMutation.mutateAsync(modemConfig);
|
||||
|
||||
if (response?.id) {
|
||||
if (!response?.id) {
|
||||
toast.success("Modem settings updated successfully", {
|
||||
id: "modemSettings",
|
||||
});
|
||||
@@ -138,7 +146,6 @@ const ModemSettings = () => {
|
||||
id="serverPrimary"
|
||||
type="text"
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
validate={ValidateIPaddress}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
@@ -151,7 +158,6 @@ const ModemSettings = () => {
|
||||
id="serverSecondary"
|
||||
type="text"
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
validate={ValidateIPaddress}
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
|
||||
Reference in New Issue
Block a user