forked from trent_larson/crowd-funder-for-time-pwa
add 'isRegistered' check to guard against many buttons
This commit is contained in:
@@ -102,11 +102,13 @@ export const doCopyTwoSecRedo = (text: string, fn: () => void) => {
|
||||
* @param veriClaim is expected to have fields: claim, claimType, and issuer
|
||||
*/
|
||||
export const isGiveRecordTheUserCanConfirm = (
|
||||
isRegistered: boolean,
|
||||
veriClaim: GenericCredWrapper<GenericVerifiableCredential>,
|
||||
activeDid: string,
|
||||
confirmerIdList: string[] = [],
|
||||
) => {
|
||||
return (
|
||||
isRegistered &&
|
||||
isGiveAction(veriClaim) &&
|
||||
!confirmerIdList.includes(activeDid) &&
|
||||
veriClaim.issuer !== activeDid &&
|
||||
|
||||
@@ -136,6 +136,7 @@
|
||||
class="col-span-1 bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-4 py-2 rounded-md"
|
||||
v-if="
|
||||
libsUtil.isGiveRecordTheUserCanConfirm(
|
||||
isRegistered,
|
||||
veriClaim,
|
||||
activeDid,
|
||||
confirmerIdList,
|
||||
@@ -472,6 +473,7 @@ export default class ClaimView extends Vue {
|
||||
fullClaimDump = "";
|
||||
fullClaimMessage = "";
|
||||
isEditedGlobalId = false;
|
||||
isRegistered = false;
|
||||
numConfsNotVisible = 0; // number of hidden DIDs in the confirmerIdList, minus the issuer if they aren't visible
|
||||
showDidCopy = false;
|
||||
showIdCopy = false;
|
||||
@@ -496,6 +498,7 @@ export default class ClaimView extends Vue {
|
||||
this.fullClaimDump = "";
|
||||
this.fullClaimMessage = "";
|
||||
this.isEditedGlobalId = false;
|
||||
this.isRegistered = false;
|
||||
this.numConfsNotVisible = 0;
|
||||
this.veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD;
|
||||
this.veriClaimDump = "";
|
||||
@@ -507,6 +510,7 @@ export default class ClaimView extends Vue {
|
||||
this.activeDid = settings?.activeDid || "";
|
||||
this.apiServer = settings?.apiServer || "";
|
||||
this.allContacts = await db.contacts.toArray();
|
||||
this.isRegistered = settings?.isRegistered || false;
|
||||
|
||||
await accountsDB.open();
|
||||
const accounts = accountsDB.accounts;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<span
|
||||
v-if="
|
||||
libsUtil.isGiveRecordTheUserCanConfirm(
|
||||
isRegistered,
|
||||
veriClaim,
|
||||
activeDid,
|
||||
confirmerIdList,
|
||||
@@ -33,6 +34,7 @@
|
||||
class="col-span-1 bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-4 py-2 rounded-md"
|
||||
v-if="
|
||||
libsUtil.isGiveRecordTheUserCanConfirm(
|
||||
isRegistered,
|
||||
veriClaim,
|
||||
activeDid,
|
||||
confirmerIdList,
|
||||
@@ -52,6 +54,7 @@
|
||||
<fa icon="circle-check" class="ml-2 text-white cursor-pointer" />
|
||||
</button>
|
||||
<a
|
||||
v-if="isRegistered"
|
||||
class="col-span-1 bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white ml-2 px-4 py-2 rounded-md"
|
||||
:href="urlForNewGive"
|
||||
>
|
||||
@@ -431,6 +434,7 @@ export default class ClaimView extends Vue {
|
||||
giverName = "";
|
||||
issuerName = "";
|
||||
isLoading = false;
|
||||
isRegistered = false;
|
||||
numConfsNotVisible = 0; // number of hidden DIDs in the confirmerIdList, minus the issuer if they aren't visible
|
||||
recipientName = "";
|
||||
showDetails = false;
|
||||
@@ -450,6 +454,7 @@ export default class ClaimView extends Vue {
|
||||
this.confsVisibleErrorMessage = "";
|
||||
this.confsVisibleToIdList = [];
|
||||
this.giveDetails = null;
|
||||
this.isRegistered = false;
|
||||
this.numConfsNotVisible = 0;
|
||||
this.urlForNewGive = "";
|
||||
this.veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD;
|
||||
@@ -463,6 +468,7 @@ export default class ClaimView extends Vue {
|
||||
this.activeDid = settings?.activeDid || "";
|
||||
this.apiServer = settings?.apiServer || "";
|
||||
this.allContacts = await db.contacts.toArray();
|
||||
this.isRegistered = settings?.isRegistered || false;
|
||||
|
||||
await accountsDB.open();
|
||||
const accounts = accountsDB.accounts;
|
||||
@@ -782,7 +788,17 @@ export default class ClaimView extends Vue {
|
||||
}
|
||||
|
||||
notifyWhyCannotConfirm() {
|
||||
if (!isGiveAction(this.veriClaim)) {
|
||||
if (!this.isRegistered) {
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "info",
|
||||
title: "Not Registered",
|
||||
text: "Someone needs to register you before you can contribute.",
|
||||
},
|
||||
3000,
|
||||
);
|
||||
} else if (!isGiveAction(this.veriClaim)) {
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="activeDid" class="mt-4">
|
||||
<div v-if="activeDid && isRegistered" class="mt-4">
|
||||
<div class="text-center">
|
||||
<button
|
||||
@click="openOfferDialog()"
|
||||
@@ -171,7 +171,7 @@
|
||||
</div>
|
||||
<OfferDialog ref="customOfferDialog" :projectId="this.projectId" />
|
||||
|
||||
<div v-if="activeDid">
|
||||
<div v-if="activeDid && isRegistered">
|
||||
<div class="text-center">
|
||||
<p class="mt-2 mt-4 text-center">Record a contribution from:</p>
|
||||
</div>
|
||||
@@ -467,6 +467,7 @@ export default class ProjectViewView extends Vue {
|
||||
givesProvidedByThis: Array<GiveSummaryRecord> = [];
|
||||
givesProvidedByHitLimit = false;
|
||||
imageUrl = "";
|
||||
isRegistered = false;
|
||||
issuer = "";
|
||||
latitude = 0;
|
||||
longitude = 0;
|
||||
@@ -489,6 +490,7 @@ export default class ProjectViewView extends Vue {
|
||||
this.activeDid = settings?.activeDid || "";
|
||||
this.apiServer = settings?.apiServer || "";
|
||||
this.allContacts = await db.contacts.toArray();
|
||||
this.isRegistered = !!settings?.isRegistered;
|
||||
|
||||
await accountsDB.open();
|
||||
const accounts = accountsDB.accounts;
|
||||
@@ -939,7 +941,11 @@ export default class ProjectViewView extends Vue {
|
||||
claimType: "GiveAction",
|
||||
issuer: give.agentDid,
|
||||
};
|
||||
return libsUtil.isGiveRecordTheUserCanConfirm(giveDetails, this.activeDid);
|
||||
return libsUtil.isGiveRecordTheUserCanConfirm(
|
||||
this.isRegistered,
|
||||
giveDetails,
|
||||
this.activeDid,
|
||||
);
|
||||
}
|
||||
|
||||
confirmConfirmClaim(give: GiveSummaryRecord) {
|
||||
|
||||
@@ -189,11 +189,15 @@
|
||||
<InfiniteScroll v-if="showProjects" @reached-bottom="loadMoreProjectData">
|
||||
<div v-if="projects.length === 0" class="text-center py-4">
|
||||
You have not announced any projects.
|
||||
<br />
|
||||
<div v-if="isRegistered">
|
||||
Hit the big
|
||||
<fa icon="plus" class="bg-blue-600 text-white px-1 py-1 rounded-full" />
|
||||
<fa
|
||||
icon="plus"
|
||||
class="bg-blue-600 text-white px-1 py-1 rounded-full"
|
||||
/>
|
||||
button. You'll never know until you try.
|
||||
</div>
|
||||
</div>
|
||||
<ul id="listProjects" class="border-t border-slate-300">
|
||||
<li
|
||||
class="border-b border-slate-300"
|
||||
|
||||
Reference in New Issue
Block a user