forked from trent_larson/crowd-funder-for-time-pwa
Merge branch 'master' into search-projects
This commit is contained in:
@@ -51,8 +51,9 @@
|
||||
|
||||
<div class="mb-8">
|
||||
<h1 class="text-2xl">Quick Action</h1>
|
||||
<p class="mb-2">Choose a contact to whom to show appreciation:</p>
|
||||
<div>
|
||||
<p>Choose a contact to whom to show appreciation:</p>
|
||||
<!-- similar contact selection code is in multiple places -->
|
||||
<div class="px-4">
|
||||
<button
|
||||
v-for="contact in allContacts"
|
||||
:key="contact.did"
|
||||
@@ -61,12 +62,9 @@
|
||||
>
|
||||
{{ contact.name }}
|
||||
</button>
|
||||
<span v-if="allContacts.length > 0">or</span>
|
||||
<button
|
||||
@click="openDialog()"
|
||||
class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md"
|
||||
>
|
||||
nobody in particular
|
||||
<span v-if="allContacts.length > 0"> or </span>
|
||||
<button @click="openDialog()" class="text-blue-500">
|
||||
someone not specified
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -74,7 +72,7 @@
|
||||
<GiftedDialog
|
||||
ref="customDialog"
|
||||
@dialog-result="handleDialogResult"
|
||||
message="Confirm to publish to the world."
|
||||
message="Received from"
|
||||
>
|
||||
</GiftedDialog>
|
||||
|
||||
@@ -279,13 +277,13 @@ export default class HomeView extends Vue {
|
||||
return unitCode === "HUR" ? (single ? "hour" : "hours") : unitCode;
|
||||
}
|
||||
|
||||
openDialog(contact) {
|
||||
this.$refs.customDialog.open(contact);
|
||||
openDialog(giver) {
|
||||
this.$refs.customDialog.open(giver);
|
||||
}
|
||||
handleDialogResult(result) {
|
||||
if (result.action === "confirm") {
|
||||
return new Promise((resolve) => {
|
||||
this.recordGive(result.contact, result.description, result.hours);
|
||||
this.recordGive(result.contact?.did, result.description, result.hours);
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
@@ -295,17 +293,23 @@ export default class HomeView extends Vue {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param contact may be null
|
||||
* @param giverDid may be null
|
||||
* @param description may be an empty string
|
||||
* @param hours may be 0
|
||||
*/
|
||||
recordGive(contact, description, hours) {
|
||||
recordGive(giverDid, description, hours) {
|
||||
if (this.activeDid == null) {
|
||||
this.alertTitle = "Error";
|
||||
this.alertMessage =
|
||||
"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 +323,7 @@ export default class HomeView extends Vue {
|
||||
this.axios,
|
||||
this.apiServer,
|
||||
identity,
|
||||
contact?.did,
|
||||
giverDid,
|
||||
this.activeDid,
|
||||
description,
|
||||
hours
|
||||
@@ -329,7 +333,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.";
|
||||
@@ -337,10 +342,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.";
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user