From 0b24d7bbd82d4dd8907de648a792f93dee87d26e Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sun, 25 Feb 2024 18:55:58 -0700 Subject: [PATCH] for BVC: fix the attendee & show appropriate success message --- src/views/QuickActionBvcBeginView.vue | 104 +++++++++++++++----------- 1 file changed, 59 insertions(+), 45 deletions(-) diff --git a/src/views/QuickActionBvcBeginView.vue b/src/views/QuickActionBvcBeginView.vue index b5c58db83..7cc0d9982 100644 --- a/src/views/QuickActionBvcBeginView.vue +++ b/src/views/QuickActionBvcBeginView.vue @@ -91,8 +91,6 @@ import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; export default class QuickActionBvcBeginView extends Vue { $notify!: (notification: NotificationIface, timeout?: number) => void; - activeDid = ""; - apiServer = ""; attended = true; gaveTime = true; hoursStr = "1"; @@ -127,60 +125,76 @@ export default class QuickActionBvcBeginView extends Vue { const hoursNum = libsUtil.numberOrZero(this.hoursStr); const identity = await libsUtil.getIdentity(activeDid); - const result = await createAndSubmitGive( - axios, - apiServer, - identity, - activeDid, - undefined, - undefined, - hoursNum, - "HUR", - BVC_MEETUPS_PROJECT_CLAIM_ID, - ); - if (result.type === "error") { - console.error("Error sending give:", result); - this.$notify( - { - group: "alert", - type: "danger", - title: "Error", - text: - result?.error?.userMessage || - "There was an error sending the give.", - }, - -1, + let timeSuccess = false; + if (this.gaveTime && hoursNum > 0) { + const timeResult = await createAndSubmitGive( + axios, + apiServer, + identity, + activeDid, + undefined, + undefined, + hoursNum, + "HUR", + BVC_MEETUPS_PROJECT_CLAIM_ID, ); + if (timeResult.type === "success") { + timeSuccess = true; + } else { + console.error("Error sending give:", timeResult); + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: + timeResult?.error?.userMessage || + "There was an error sending the time.", + }, + -1, + ); + } } - const result2 = await createAndSubmitClaim( - bvcMeetingJoinClaim(this.activeDid, this.todayOrPreviousStartDate), - identity, - apiServer, - axios, - ); - if (result2.type === "error") { - console.error("Error sending give:", result2); - this.$notify( - { - group: "alert", - type: "danger", - title: "Error", - text: - result2?.error?.userMessage || - "There was an error sending the attendance.", - }, - -1, + let attendedSuccess = false; + if (this.attended) { + const attendResult = await createAndSubmitClaim( + bvcMeetingJoinClaim(activeDid, this.todayOrPreviousStartDate), + identity, + apiServer, + axios, ); + if (attendResult.type === "success") { + attendedSuccess = true; + } else { + console.error("Error sending give:", attendResult); + this.$notify( + { + group: "alert", + type: "danger", + title: "Error", + text: + attendResult?.error?.userMessage || + "There was an error sending the attendance.", + }, + -1, + ); + } } - if (result.type === "success" || result2.type === "success") { + if (timeSuccess || attendedSuccess) { + const actions = + timeSuccess && attendedSuccess + ? "attendance and time have been" + : timeSuccess + ? "time has been" + : "attendance has been"; this.$notify( { group: "alert", type: "success", title: "Success", - text: "Your actions have been recorded.", + text: `Your ${actions} recorded.`, }, -1, );