Browse Source

for BVC: fix the attendee & show appropriate success message

bvc-shortcut
Trent Larson 9 months ago
parent
commit
0b24d7bbd8
  1. 42
      src/views/QuickActionBvcBeginView.vue

42
src/views/QuickActionBvcBeginView.vue

@ -91,8 +91,6 @@ import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings";
export default class QuickActionBvcBeginView extends Vue { export default class QuickActionBvcBeginView extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void; $notify!: (notification: NotificationIface, timeout?: number) => void;
activeDid = "";
apiServer = "";
attended = true; attended = true;
gaveTime = true; gaveTime = true;
hoursStr = "1"; hoursStr = "1";
@ -127,7 +125,9 @@ export default class QuickActionBvcBeginView extends Vue {
const hoursNum = libsUtil.numberOrZero(this.hoursStr); const hoursNum = libsUtil.numberOrZero(this.hoursStr);
const identity = await libsUtil.getIdentity(activeDid); const identity = await libsUtil.getIdentity(activeDid);
const result = await createAndSubmitGive( let timeSuccess = false;
if (this.gaveTime && hoursNum > 0) {
const timeResult = await createAndSubmitGive(
axios, axios,
apiServer, apiServer,
identity, identity,
@ -138,49 +138,63 @@ export default class QuickActionBvcBeginView extends Vue {
"HUR", "HUR",
BVC_MEETUPS_PROJECT_CLAIM_ID, BVC_MEETUPS_PROJECT_CLAIM_ID,
); );
if (result.type === "error") { if (timeResult.type === "success") {
console.error("Error sending give:", result); timeSuccess = true;
} else {
console.error("Error sending give:", timeResult);
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Error", title: "Error",
text: text:
result?.error?.userMessage || timeResult?.error?.userMessage ||
"There was an error sending the give.", "There was an error sending the time.",
}, },
-1, -1,
); );
} }
}
const result2 = await createAndSubmitClaim( let attendedSuccess = false;
bvcMeetingJoinClaim(this.activeDid, this.todayOrPreviousStartDate), if (this.attended) {
const attendResult = await createAndSubmitClaim(
bvcMeetingJoinClaim(activeDid, this.todayOrPreviousStartDate),
identity, identity,
apiServer, apiServer,
axios, axios,
); );
if (result2.type === "error") { if (attendResult.type === "success") {
console.error("Error sending give:", result2); attendedSuccess = true;
} else {
console.error("Error sending give:", attendResult);
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
type: "danger", type: "danger",
title: "Error", title: "Error",
text: text:
result2?.error?.userMessage || attendResult?.error?.userMessage ||
"There was an error sending the attendance.", "There was an error sending the attendance.",
}, },
-1, -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( this.$notify(
{ {
group: "alert", group: "alert",
type: "success", type: "success",
title: "Success", title: "Success",
text: "Your actions have been recorded.", text: `Your ${actions} recorded.`,
}, },
-1, -1,
); );

Loading…
Cancel
Save