Browse Source

for BVC: fix the attendee & show appropriate success message

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

Loading…
Cancel
Save