for BVC shortcut: send attend & give actions, and list actions to confirm

This commit is contained in:
2024-02-25 18:38:54 -07:00
parent 866dcb3a2a
commit 2058205150
15 changed files with 246 additions and 118 deletions

View File

@@ -446,7 +446,7 @@
>
<!-- label -->
<span class="text-slate-500 text-sm font-bold"
>Show Shortcut on Home Page</span
>Show BVC Shortcut on Home Page</span
>
<!-- toggle -->
<div class="relative ml-2">

View File

@@ -179,7 +179,7 @@ export default class ContactAmountssView extends Vue {
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
console.log("Error retrieving settings or gives.", err);
console.error("Error retrieving settings or gives.", err);
this.$notify(
{
group: "alert",

View File

@@ -119,7 +119,7 @@ export default class ContactGiftingView extends Vue {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
console.log("Error retrieving settings & contacts:", err);
console.error("Error retrieving settings & contacts:", err);
this.$notify(
{
group: "alert",

View File

@@ -180,7 +180,6 @@ export default class ContactQRScanShow extends Vue {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onScanDetect(content: any) {
if (content[0]?.rawValue) {
//console.log("onDetect", content[0].rawValue);
localStorage.setItem("contactEndorserUrl", content[0].rawValue);
this.$router.push({ name: "contacts" });
} else {
@@ -198,7 +197,7 @@ export default class ContactQRScanShow extends Vue {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onScanError(error: any) {
console.log("Scan was invalid:", error);
console.error("Scan was invalid:", error);
this.$notify(
{
group: "alert",

View File

@@ -284,6 +284,7 @@
<script lang="ts">
import { AxiosError } from "axios";
import { IndexableType } from "dexie";
import * as didJwt from "did-jwt";
import * as R from "ramda";
import { IIdentifier } from "@veramo/core";
@@ -311,7 +312,6 @@ import * as libsUtil from "@/libs/util";
import QuickNav from "@/components/QuickNav.vue";
import EntityIcon from "@/components/EntityIcon.vue";
import { Account } from "@/db/tables/accounts";
import { IndexableType } from "dexie";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Buffer = require("buffer/").Buffer;
@@ -497,7 +497,7 @@ export default class ContactsView extends Vue {
this.givenToMeConfirmed = givenToMeConfirmed;
this.givenToMeUnconfirmed = givenToMeUnconfirmed;
} catch (error) {
console.log("Error loading gives", error);
console.error("Error loading gives", error);
this.$notify(
{
group: "alert",
@@ -1000,7 +1000,7 @@ export default class ContactsView extends Vue {
-1,
);
} else {
console.log("Got bad server response when checking visibility: ", resp);
console.error("Got bad server response checking visibility:", resp);
const message = resp.data.error?.message || "Got bad server response.";
this.$notify(
{
@@ -1013,7 +1013,7 @@ export default class ContactsView extends Vue {
);
}
} catch (err) {
console.log("Caught error from request to check visibility:", err);
console.error("Caught error from request to check visibility:", err);
this.$notify(
{
group: "alert",
@@ -1026,12 +1026,6 @@ export default class ContactsView extends Vue {
}
}
// from https://stackoverflow.com/a/175787/845494
//
private isNumeric(str: string): boolean {
return !isNaN(+str);
}
private nameForDid(contacts: Array<Contact>, did: string): string {
const contact = R.find((con) => con.did == did, contacts);
return this.nameForContact(contact);
@@ -1067,7 +1061,7 @@ export default class ContactsView extends Vue {
return;
}
}
if (!this.isNumeric(this.hourInput)) {
if (!libsUtil.isNumeric(this.hourInput)) {
this.$notify(
{
group: "alert",
@@ -1204,7 +1198,7 @@ export default class ContactsView extends Vue {
}
}
} catch (error) {
console.log("Error in createAndSubmitContactGive: ", error);
console.error("Error in createAndSubmitContactGive: ", error);
let userMessage = "There was an error. See logs for more info.";
const serverError = error as AxiosError;
if (serverError) {

View File

@@ -254,7 +254,7 @@ export default class DiscoverView extends Vue {
if (response.status !== 200) {
const details = await response.text();
console.log("Problem with full search:", details);
console.error("Problem with full search:", details);
this.$notify(
{
group: "alert",
@@ -282,7 +282,7 @@ export default class DiscoverView extends Vue {
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
console.log("Error with feed load:", e);
console.error("Error with feed load:", e);
this.$notify(
{
group: "alert",
@@ -337,7 +337,7 @@ export default class DiscoverView extends Vue {
if (response.status !== 200) {
const details = await response.text();
console.log("Problem with nearby search:", details);
console.error("Problem with nearby search:", details);
this.$notify(
{
group: "alert",
@@ -374,7 +374,7 @@ export default class DiscoverView extends Vue {
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
console.log("Error with feed load:", e);
console.error("Error with feed load:", e);
this.$notify(
{
group: "alert",

View File

@@ -3,8 +3,8 @@
<TopMessage />
<!-- CONTENT -->
<section id="Content" class="p-6 pb-24 max-w-3xl mx-auto">
<h1 id="ViewHeading" class="text-4xl text-center font-light pt-4 mb-8">
<section id="Content" class="p-2 pb-24 max-w-3xl mx-auto">
<h1 id="ViewHeading" class="text-4xl text-center font-light px-4 mb-8">
Time Safari
</h1>
@@ -346,7 +346,7 @@ export default class HomeView extends Vue {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (err: any) {
console.log("Error retrieving settings or feed.", err);
console.error("Error retrieving settings or feed.", err);
this.$notify(
{
group: "alert",
@@ -452,7 +452,7 @@ export default class HomeView extends Vue {
}
})
.catch((e) => {
console.log("Error with feed load:", e);
console.error("Error with feed load:", e);
this.$notify(
{
group: "alert",

View File

@@ -15,20 +15,24 @@
</div>
<!-- Heading -->
<h1 id="ViewHeading" class="text-4xl text-center font-light pt-4 mb-4">
<h1 id="ViewHeading" class="text-4xl text-center font-light px-4 mb-4">
Beginning of BVC Saturday Meeting
</h1>
<div>
<h2 class="text-2xl m-4">You're Here</h2>
<div class="m-4 flex">
<input type="checkbox" v-model="gaveTime" class="h-6 w-6" />
<h2 class="text-2xl m-2">You're Here</h2>
<div class="m-2 flex">
<input type="checkbox" v-model="attended" class="h-6 w-6" />
<span class="pb-2 pl-2 pr-2">Attended</span>
</div>
<div class="m-2 flex">
<input type="checkbox" v-model="gaveTime" class="h-6 w-6" />
<span class="pb-2 pl-2 pr-2">Spent Time</span>
<span v-if="gaveTime">
<input
type="text"
placeholder="How much time"
v-model="hours"
v-model="hoursStr"
size="1"
class="border border-slate-400 h-6 px-2"
/>
@@ -39,25 +43,44 @@
</div>
</div>
<div class="m-4" v-if="gaveTime && hours && hours != '0'">
<div
v-if="attended || (gaveTime && hoursStr && hoursStr != '0')"
class="flex justify-center mt-4"
>
<button
@click="record()"
class="block text-center text-md font-bold bg-blue-500 text-white px-2 py-3 rounded-md"
class="block text-center text-md font-bold bg-blue-500 text-white px-2 py-3 rounded-md w-56"
>
Sign & Send
</button>
</div>
<div v-else class="flex justify-center mt-4">
<button
class="block text-center text-md font-bold bg-slate-500 text-white px-2 py-3 rounded-md w-56"
>
Select Your Actions
</button>
</div>
</section>
</template>
<script lang="ts">
import axios from "axios";
import { DateTime } from "luxon";
import { Component, Vue } from "vue-facing-decorator";
import QuickNav from "@/components/QuickNav.vue";
import TopMessage from "@/components/TopMessage.vue";
import { NotificationIface } from "@/constants/app";
import { numberOrZero } from "@/libs/endorserServer";
import { db } from "@/db/index";
import {
BVC_MEETUPS_PROJECT_CLAIM_ID,
bvcMeetingJoinClaim,
createAndSubmitClaim,
createAndSubmitGive,
} from "@/libs/endorserServer";
import * as libsUtil from "@/libs/util";
import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings";
@Component({
components: {
@@ -68,8 +91,11 @@ import { numberOrZero } from "@/libs/endorserServer";
export default class QuickActionBvcBeginView extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void;
gaveTime = false;
hours = "1";
activeDid = "";
apiServer = "";
attended = true;
gaveTime = true;
hoursStr = "1";
todayOrPreviousStartDate = "";
async mounted() {
@@ -91,9 +117,88 @@ export default class QuickActionBvcBeginView extends Vue {
}) || "";
}
record() {
const hoursNum = numberOrZero(this.hours);
alert("Nope" + hoursNum);
async record() {
await db.open();
const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings;
const activeDid = settings?.activeDid || "";
const apiServer = settings?.apiServer || "";
try {
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,
);
}
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,
);
}
if (result.type === "success" || result2.type === "success") {
this.$notify(
{
group: "alert",
type: "success",
title: "Success",
text: "Your actions have been recorded.",
},
-1,
);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
console.error("Error sending claims.", error);
this.$notify(
{
group: "alert",
type: "danger",
title: "Error",
text: error.userMessage || "There was an error sending those claims.",
},
-1,
);
}
}
}
</script>

View File

@@ -15,19 +15,26 @@
</div>
<!-- Heading -->
<h1 id="ViewHeading" class="text-4xl text-center font-light pt-4 mb-4">
<h1 id="ViewHeading" class="text-4xl text-center font-light px-4 mb-4">
End of BVC Saturday Meeting
</h1>
<div>
<h2 class="text-2xl m-4">Confirm</h2>
<div v-if="claimsToConfirm.length === 0">
There are no claims today yet for you to confirm.
<span v-if="claimCountWithHidden">
(There are {{ claimCountWithHidden }} hidden claims.)
<h2 class="text-2xl m-2">Confirm</h2>
<div v-if="loadingConfirms" class="flex justify-center">
<fa icon="spinner" class="animate-spin" />
</div>
<div v-else-if="claimsToConfirm.length === 0">
There are no claims yet today for you to confirm.
<span v-if="claimCountWithHidden > 0">
{{
claimCountWithHidden === 1
? "(There is 1 claim with hidden details.)"
: `(There are ${claimCountWithHidden} claims with hidden details.)`
}}
</span>
</div>
<ul class="border-t border-slate-300">
<ul class="border-t border-slate-300 m-2">
<li
class="border-b border-slate-300 py-2"
v-for="record in claimsToConfirm"
@@ -36,7 +43,19 @@
<div class="grid grid-cols-12">
<span class="col-span-11 justify-self-start">
<span>
<input type="checkbox" class="mr-2 h-6 w-6" />
<input
type="checkbox"
:checked="claimsToConfirmSelected.includes(record.id)"
@click="
claimsToConfirmSelected.includes(record.id)
? claimsToConfirmSelected.splice(
claimsToConfirmSelected.indexOf(record.id),
1,
)
: claimsToConfirmSelected.push(record.id)
"
class="mr-2 h-6 w-6"
/>
</span>
{{
claimSpecialDescription(
@@ -59,10 +78,10 @@
</div>
<div>
<h2 class="text-2xl m-4">Anything else?</h2>
<div class="m-4 flex">
<h2 class="text-2xl m-2">Anything else?</h2>
<div class="m-2 flex">
<input type="checkbox" v-model="someoneGave" class="h-6 w-6" />
<span class="pb-2 pl-2 pr-2">Someone gave</span>
<span class="pb-2 pl-2 pr-2">Someone else gave</span>
<span v-if="someoneGave">
<input
type="text"
@@ -76,14 +95,24 @@
</div>
</div>
<div class="m-4" v-if="someoneGave && description">
<div
v-if="claimsToConfirmSelected.length || (someoneGave && description)"
class="flex justify-center mt-4"
>
<button
@click="record()"
class="block text-center text-md font-bold bg-blue-500 text-white px-2 py-3 rounded-md"
class="block text-center text-md font-bold bg-blue-500 text-white px-2 py-3 rounded-md w-56"
>
Sign & Send
</button>
</div>
<div v-else class="flex justify-center mt-4">
<button
class="block text-center text-md font-bold bg-slate-500 text-white px-2 py-3 rounded-md w-56"
>
Choose What To Confirm
</button>
</div>
</section>
</template>
@@ -123,7 +152,9 @@ export default class QuickActionBvcBeginView extends Vue {
apiServer = "";
claimCountWithHidden = 0;
claimsToConfirm: GenericServerRecord[] = [];
description = "";
claimsToConfirmSelected: string[] = [];
description = "breakfast";
loadingConfirms = true;
someoneGave = false;
async created() {
@@ -135,6 +166,7 @@ export default class QuickActionBvcBeginView extends Vue {
}
async mounted() {
this.loadingConfirms = true;
let currentOrPreviousSat = DateTime.now().setZone("America/Denver");
if (currentOrPreviousSat.weekday < 6) {
// it's not Saturday or Sunday,
@@ -165,15 +197,7 @@ export default class QuickActionBvcBeginView extends Vue {
const headers = {
Authorization: "Bearer " + (await accessToken(identity)),
};
console.log("todayOrPreviousStartDate", todayOrPreviousStartDate);
try {
console.log(
this.apiServer +
"/api/claim/?" +
"issuedAt_greaterThanOrEqualTo=" +
encodeURIComponent(todayOrPreviousStartDate) +
"&excludeConfirmations=true",
);
const response = await fetch(
this.apiServer +
"/api/claim/?" +
@@ -187,7 +211,7 @@ export default class QuickActionBvcBeginView extends Vue {
console.log("Bad response", response);
throw new Error("Bad response when retrieving claims.");
}
response.json().then((data) => {
await response.json().then((data) => {
const dataByOthers = R.reject(
(claim: GenericServerRecord) => claim.issuer === this.activeDid,
data,
@@ -212,6 +236,7 @@ export default class QuickActionBvcBeginView extends Vue {
-1,
);
}
this.loadingConfirms = false;
}
onClickLoadClaim(jwtId: string) {

View File

@@ -15,7 +15,7 @@
</div>
<!-- Heading -->
<h1 id="ViewHeading" class="text-4xl text-center font-light pt-4 mb-4">
<h1 id="ViewHeading" class="text-4xl text-center font-light px-4 mb-4">
Bountiful Voluntaryist Community Actions
</h1>