add error messages for gives

This commit is contained in:
2023-07-01 22:20:10 -06:00
parent a2b3cebdb3
commit a8f1e25986
2 changed files with 36 additions and 4 deletions

View File

@@ -296,6 +296,12 @@ export default class HomeView extends Vue {
"You must select an identity before you can record a give.";
return;
}
if (!description && !hours) {
this.alertTitle = "Error";
this.alertMessage =
"You must enter a description or some number of hours.";
return;
}
const account = R.find(
(acc) => acc.did === this.activeDid,
this.allAccounts
@@ -319,7 +325,8 @@ export default class HomeView extends Vue {
console.log("Error with give result:", result);
this.alertTitle = "Error";
this.alertMessage =
result.data?.message || "There was an error recording the give.";
result.data?.error?.message ||
"There was an error recording the give.";
} else {
this.alertTitle = "Success";
this.alertMessage = "That gift was recorded.";
@@ -327,10 +334,13 @@ export default class HomeView extends Vue {
}
})
.catch((e) => {
// axios throws errors on 400 responses
console.log("Error with give caught:", e);
this.alertTitle = "Error";
this.alertMessage =
e.userMessage || "There was an error recording the give.";
e.userMessage ||
e.response?.data?.error?.message ||
"There was an error recording the give.";
});
}