Add error message for missing subnet
This commit is contained in:
parent
9aae3144fe
commit
ff404be6c0
1 changed files with 22 additions and 6 deletions
|
@ -15,7 +15,14 @@ const results = ref( {} );
|
|||
/**
|
||||
* Load subnet data based on input
|
||||
*/
|
||||
const getSubnetData = async () => {
|
||||
const getSubnetData = async (): void => {
|
||||
// Check if subnet is filled
|
||||
if (subnet.value === '') {
|
||||
errorMsg('Subnet is required');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Enable loading state
|
||||
isLoading.value = true;
|
||||
|
@ -34,10 +41,7 @@ const getSubnetData = async () => {
|
|||
} catch (error) {
|
||||
// Extract and show error message
|
||||
const errorMessage = error.response?.data?.message || 'Something went wrong.';
|
||||
$toast.error(errorMessage, {
|
||||
position: 'top',
|
||||
duration: 1500,
|
||||
});
|
||||
errorMsg(errorMessage);
|
||||
} finally {
|
||||
// Reset loading state
|
||||
isLoading.value = false;
|
||||
|
@ -47,12 +51,24 @@ const getSubnetData = async () => {
|
|||
/**
|
||||
* Reset form by resetting al vars
|
||||
*/
|
||||
const resetForm = () => {
|
||||
const resetForm = (): void => {
|
||||
subnet.value = '';
|
||||
isLoading.value = false;
|
||||
hasResults.value = false;
|
||||
results.value = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Send error message
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
const errorMsg = (message: string): void => {
|
||||
$toast.error(message, {
|
||||
position: 'top',
|
||||
duration: 1500,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue