|
@ -428,9 +428,18 @@ export default class HomeView extends Vue { |
|
|
this.allMyDids, |
|
|
this.allMyDids, |
|
|
this.allContacts, |
|
|
this.allContacts, |
|
|
); |
|
|
); |
|
|
const gaveAmount = claim.object?.amountOfThisGood |
|
|
let gaveAmount = claim.object?.amountOfThisGood |
|
|
? this.displayAmount(claim.object.unitCode, claim.object.amountOfThisGood) |
|
|
? this.displayAmount(claim.object.unitCode, claim.object.amountOfThisGood) |
|
|
: claim.description || "something without description"; |
|
|
: ""; |
|
|
|
|
|
if (claim.description) { |
|
|
|
|
|
if (gaveAmount) { |
|
|
|
|
|
gaveAmount = gaveAmount + ", and also: "; |
|
|
|
|
|
} |
|
|
|
|
|
gaveAmount = gaveAmount + claim.description; |
|
|
|
|
|
} |
|
|
|
|
|
if (!gaveAmount) { |
|
|
|
|
|
gaveAmount = "something not described"; |
|
|
|
|
|
} |
|
|
// recipient.did is for legacy data, before March 2023 |
|
|
// recipient.did is for legacy data, before March 2023 |
|
|
const gaveRecipientId = |
|
|
const gaveRecipientId = |
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
@ -524,15 +533,18 @@ export default class HomeView extends Vue { |
|
|
hours, |
|
|
hours, |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
if (this.isGiveCreationError(result)) { |
|
|
if ( |
|
|
|
|
|
result.type === "error" || |
|
|
|
|
|
this.isGiveCreationError(result.response) |
|
|
|
|
|
) { |
|
|
const errorMessage = this.getGiveCreationErrorMessage(result); |
|
|
const errorMessage = this.getGiveCreationErrorMessage(result); |
|
|
console.log("Error with give result:", result); |
|
|
console.log("Error with give creation result:", result); |
|
|
this.$notify( |
|
|
this.$notify( |
|
|
{ |
|
|
{ |
|
|
group: "alert", |
|
|
group: "alert", |
|
|
type: "danger", |
|
|
type: "danger", |
|
|
title: "Error", |
|
|
title: "Error", |
|
|
text: errorMessage || "There was an error recording the give.", |
|
|
text: errorMessage || "There was an error creating the give.", |
|
|
}, |
|
|
}, |
|
|
-1, |
|
|
-1, |
|
|
); |
|
|
); |
|
@ -549,7 +561,7 @@ export default class HomeView extends Vue { |
|
|
} |
|
|
} |
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
|
} catch (error: any) { |
|
|
} catch (error: any) { |
|
|
console.log("Error with give caught:", error); |
|
|
console.log("Error with give recordation caught:", error); |
|
|
const message = |
|
|
const message = |
|
|
error.userMessage || |
|
|
error.userMessage || |
|
|
error.response?.data?.error?.message || |
|
|
error.response?.data?.error?.message || |
|
@ -568,14 +580,26 @@ export default class HomeView extends Vue { |
|
|
|
|
|
|
|
|
// Helper functions for readability |
|
|
// Helper functions for readability |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @param result response "data" from the server |
|
|
|
|
|
* @returns true if the result indicates an error |
|
|
|
|
|
*/ |
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
|
isGiveCreationError(result: any) { |
|
|
isGiveCreationError(result: any) { |
|
|
return result.status !== 201 || result.data?.error; |
|
|
return result.status !== 201 || result.data?.error; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @param result direct response eg. ErrorResult or SuccessResult (potentially with embedded "data") |
|
|
|
|
|
* @returns best guess at an error message |
|
|
|
|
|
*/ |
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
|
getGiveCreationErrorMessage(result: any) { |
|
|
getGiveCreationErrorMessage(result: any) { |
|
|
return result.data?.error?.message; |
|
|
return ( |
|
|
|
|
|
result.error?.userMessage || |
|
|
|
|
|
result.error?.error || |
|
|
|
|
|
result.response?.data?.error?.message |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|