forked from jsnbuchanan/crowd-funder-for-time-pwa
for BVC: fix the attendee & show appropriate success message
This commit is contained in:
@@ -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,60 +125,76 @@ 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;
|
||||||
axios,
|
if (this.gaveTime && hoursNum > 0) {
|
||||||
apiServer,
|
const timeResult = await createAndSubmitGive(
|
||||||
identity,
|
axios,
|
||||||
activeDid,
|
apiServer,
|
||||||
undefined,
|
identity,
|
||||||
undefined,
|
activeDid,
|
||||||
hoursNum,
|
undefined,
|
||||||
"HUR",
|
undefined,
|
||||||
BVC_MEETUPS_PROJECT_CLAIM_ID,
|
hoursNum,
|
||||||
);
|
"HUR",
|
||||||
if (result.type === "error") {
|
BVC_MEETUPS_PROJECT_CLAIM_ID,
|
||||||
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,
|
|
||||||
);
|
);
|
||||||
|
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(
|
let attendedSuccess = false;
|
||||||
bvcMeetingJoinClaim(this.activeDid, this.todayOrPreviousStartDate),
|
if (this.attended) {
|
||||||
identity,
|
const attendResult = await createAndSubmitClaim(
|
||||||
apiServer,
|
bvcMeetingJoinClaim(activeDid, this.todayOrPreviousStartDate),
|
||||||
axios,
|
identity,
|
||||||
);
|
apiServer,
|
||||||
if (result2.type === "error") {
|
axios,
|
||||||
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,
|
|
||||||
);
|
);
|
||||||
|
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(
|
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,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user