Skip to content

Commit

Permalink
fix(ui): enhance member invite error handling and conditional UI rend…
Browse files Browse the repository at this point in the history
…ering

-Added envVariables to conditionally render invite instructions in cloud
environments.

-Enhanced error handling in addMember to include a specific message for 404
errors.

-Moved the error dispatch for 409 status to align with other case-specific
error handling logic.
  • Loading branch information
luannmoreira authored and gustavosbarreto committed Dec 13, 2024
1 parent b93945e commit 542130b
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions ui/src/components/Team/Member/MemberInvite.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<v-card-title class="bg-primary"> Invite member </v-card-title>

<v-card-text>
<p class="text-caption text-grey-lighten-4 mb-1">
<p class="text-caption text-grey-lighten-4 mb-1" v-if="envVariables.isCloud">
If this email isn't associated with an existing account, we'll send an email to sign-up.
</p>
<v-text-field
Expand Down Expand Up @@ -72,6 +72,7 @@ import {
INotificationsSuccess,
} from "@/interfaces/INotifications";
import handleError from "@/utils/handleError";
import { envVariables } from "@/envVariables";
const items = ["administrator", "operator", "observer"];
Expand Down Expand Up @@ -154,18 +155,21 @@ const addMember = async () => {
update();
resetFields();
} catch (error: unknown) {
store.dispatch(
"snackbar/showSnackbarErrorAction",
INotificationsError.namespaceNewMember,
);
if (axios.isAxiosError(error)) {
const axiosError = error as AxiosError;
if (axiosError.response?.status === 409) {
setEmailError(
"This user is already a member of this namespace.",
);
} else {
store.dispatch(
"snackbar/showSnackbarErrorAction",
INotificationsError.namespaceNewMember,
);
handleError(error);
switch (axiosError.response?.status) {
case 409:
setEmailError("This user is already a member of this namespace.");
break;
case 404:
setEmailError("This user does not exist.");
break;
default:
handleError(error);
}
}
}
Expand Down

0 comments on commit 542130b

Please sign in to comment.