forked from trent_larson/crowd-funder-for-time-pwa
add links for give & offer when they fulfill other things
This commit is contained in:
@@ -39,6 +39,57 @@
|
|||||||
<fa icon="calendar" class="fa-fw text-slate-400"></fa>
|
<fa icon="calendar" class="fa-fw text-slate-400"></fa>
|
||||||
{{ veriClaim.issuedAt?.replace(/T/, " ").replace(/Z/, " UTC") }}
|
{{ veriClaim.issuedAt?.replace(/T/, " ").replace(/Z/, " UTC") }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Fullfills Links -->
|
||||||
|
|
||||||
|
<!-- fullfills links for a give -->
|
||||||
|
<div v-if="detailsForGive?.fulfillsPlanHandleId">
|
||||||
|
<router-link
|
||||||
|
:to="
|
||||||
|
'/project/' +
|
||||||
|
encodeURIComponent(detailsForGive?.fulfillsPlanHandleId)
|
||||||
|
"
|
||||||
|
class="text-blue-500 mt-2"
|
||||||
|
>
|
||||||
|
Fulfills a bigger plan...
|
||||||
|
</router-link>
|
||||||
|
</div>
|
||||||
|
<!-- if there's another, it's probably fulfilling an offer, too -->
|
||||||
|
<div
|
||||||
|
v-if="
|
||||||
|
detailsForGive?.fulfillsType &&
|
||||||
|
detailsForGive?.fulfillsType !== 'PlanAction' &&
|
||||||
|
detailsForGive?.fulfillsHandleId
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<!-- router-link to /claim/ only changes URL path -->
|
||||||
|
<a
|
||||||
|
@click="
|
||||||
|
showDifferentClaimPage(detailsForGive?.fulfillsHandleId)
|
||||||
|
"
|
||||||
|
class="text-blue-500 mt-4"
|
||||||
|
>
|
||||||
|
Fulfills
|
||||||
|
{{
|
||||||
|
capitalizeAndInsertSpacesBeforeCaps(
|
||||||
|
detailsForGive.fulfillsType,
|
||||||
|
)
|
||||||
|
}}...
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- fullfills links for an offer -->
|
||||||
|
<div v-if="detailsForOffer?.fulfillsPlanHandleId">
|
||||||
|
<router-link
|
||||||
|
:to="
|
||||||
|
'/project/' +
|
||||||
|
encodeURIComponent(detailsForOffer?.fulfillsPlanHandleId)
|
||||||
|
"
|
||||||
|
class="text-blue-500 mt-4"
|
||||||
|
>
|
||||||
|
Offered to a bigger plan...
|
||||||
|
</router-link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -54,7 +105,7 @@
|
|||||||
confirmerIdList,
|
confirmerIdList,
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
@click="confirmClaim(veriClaim.id)"
|
@click="confirmClaim()"
|
||||||
>
|
>
|
||||||
Confirm
|
Confirm
|
||||||
<fa icon="circle-check" class="ml-2 text-white cursor-pointer" />
|
<fa icon="circle-check" class="ml-2 text-white cursor-pointer" />
|
||||||
@@ -177,7 +228,7 @@
|
|||||||
<button
|
<button
|
||||||
v-else
|
v-else
|
||||||
class="block w-full text-center text-md uppercase bg-blue-600 text-white px-1.5 py-2 rounded-md mb-2"
|
class="block w-full text-center text-md uppercase bg-blue-600 text-white px-1.5 py-2 rounded-md mb-2"
|
||||||
@click="showFullClaim(veriClaim.id)"
|
@click="showFullClaim(veriClaim.id as string)"
|
||||||
>
|
>
|
||||||
Load Full Claim Details
|
Load Full Claim Details
|
||||||
</button>
|
</button>
|
||||||
@@ -229,13 +280,17 @@ interface Notification {
|
|||||||
export default class ClaimView extends Vue {
|
export default class ClaimView extends Vue {
|
||||||
$notify!: (notification: Notification, timeout?: number) => void;
|
$notify!: (notification: Notification, timeout?: number) => void;
|
||||||
|
|
||||||
|
accountIdentityStr: string = "null";
|
||||||
activeDid = "";
|
activeDid = "";
|
||||||
allMyDids: Array<string> = [];
|
allMyDids: Array<string> = [];
|
||||||
allContacts: Array<Contact> = [];
|
allContacts: Array<Contact> = [];
|
||||||
apiServer = "";
|
apiServer = "";
|
||||||
|
|
||||||
confirmerIdList: string[] = []; // list of DIDs that have confirmed this claim excluding the issuer
|
confirmerIdList: string[] = []; // list of DIDs that have confirmed this claim excluding the issuer
|
||||||
confsVisibleErrorMessage = "";
|
confsVisibleErrorMessage = "";
|
||||||
confsVisibleToIdList: string[] = []; // list of DIDs that can see any confirmer
|
confsVisibleToIdList: string[] = []; // list of DIDs that can see any confirmer
|
||||||
|
detailsForGive = null;
|
||||||
|
detailsForOffer = null;
|
||||||
fullClaim = null;
|
fullClaim = null;
|
||||||
fullClaimDump = "";
|
fullClaimDump = "";
|
||||||
fullClaimMessage = "";
|
fullClaimMessage = "";
|
||||||
@@ -247,6 +302,20 @@ export default class ClaimView extends Vue {
|
|||||||
libsUtil = libsUtil;
|
libsUtil = libsUtil;
|
||||||
serverUtil = serverUtil;
|
serverUtil = serverUtil;
|
||||||
|
|
||||||
|
resetThisValues() {
|
||||||
|
this.confirmerIdList = [];
|
||||||
|
this.confsVisibleErrorMessage = "";
|
||||||
|
this.confsVisibleToIdList = [];
|
||||||
|
this.detailsForGive = null;
|
||||||
|
this.detailsForOffer = null;
|
||||||
|
this.fullClaim = null;
|
||||||
|
this.fullClaimDump = "";
|
||||||
|
this.fullClaimMessage = "";
|
||||||
|
this.numConfsNotVisible = 0;
|
||||||
|
this.veriClaim = serverUtil.BLANK_GENERIC_SERVER_RECORD;
|
||||||
|
this.veriClaimDump = "";
|
||||||
|
}
|
||||||
|
|
||||||
async created() {
|
async created() {
|
||||||
await db.open();
|
await db.open();
|
||||||
const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings;
|
const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings;
|
||||||
@@ -259,7 +328,8 @@ export default class ClaimView extends Vue {
|
|||||||
const accountsArr = await accounts?.toArray();
|
const accountsArr = await accounts?.toArray();
|
||||||
this.allMyDids = accountsArr.map((acc) => acc.did);
|
this.allMyDids = accountsArr.map((acc) => acc.did);
|
||||||
const account = accountsArr.find((acc) => acc.did === this.activeDid);
|
const account = accountsArr.find((acc) => acc.did === this.activeDid);
|
||||||
const identity = JSON.parse(account?.identity || "null");
|
this.accountIdentityStr = account?.identity || "null";
|
||||||
|
const identity = JSON.parse(this.accountIdentityStr);
|
||||||
|
|
||||||
const pathParam = window.location.pathname.substring("/claim/".length);
|
const pathParam = window.location.pathname.substring("/claim/".length);
|
||||||
let claimId;
|
let claimId;
|
||||||
@@ -350,31 +420,50 @@ export default class ClaimView extends Vue {
|
|||||||
group: "alert",
|
group: "alert",
|
||||||
type: "danger",
|
type: "danger",
|
||||||
title: "Error",
|
title: "Error",
|
||||||
text: "There was a problem getting that claim. See logs for more info.",
|
text: "There was a problem retrieving that claim.",
|
||||||
},
|
},
|
||||||
-1,
|
-1,
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
|
||||||
const serverError = error as AxiosError;
|
|
||||||
console.error("Error retrieving claim:", serverError);
|
|
||||||
this.$notify(
|
|
||||||
{
|
|
||||||
group: "alert",
|
|
||||||
type: "danger",
|
|
||||||
title: "Error",
|
|
||||||
text: "Something went wrong retrieving that claim. See logs for more info.",
|
|
||||||
},
|
|
||||||
-1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const confirmUrl =
|
// retrieve more details on Give, Offer, or Plan
|
||||||
this.apiServer +
|
if (this.veriClaim.claimType === "GiveAction") {
|
||||||
"/api/report/issuersWhoClaimedOrConfirmed?claimId=" +
|
const giveUrl =
|
||||||
encodeURIComponent(serverUtil.stripEndorserPrefix(claimId));
|
this.apiServer +
|
||||||
const confirmHeaders = await this.getHeaders(identity);
|
"/api/v2/report/gives?handleId=" +
|
||||||
try {
|
encodeURIComponent(this.veriClaim.handleId as string);
|
||||||
|
const giveHeaders = await this.getHeaders(identity);
|
||||||
|
const giveResp = await this.axios.get(giveUrl, {
|
||||||
|
headers: giveHeaders,
|
||||||
|
});
|
||||||
|
if (giveResp.status === 200) {
|
||||||
|
this.detailsForGive = giveResp.data.data[0];
|
||||||
|
} else {
|
||||||
|
console.error("Error getting detailed give info:", giveResp);
|
||||||
|
}
|
||||||
|
} else if (this.veriClaim.claimType === "Offer") {
|
||||||
|
const offerUrl =
|
||||||
|
this.apiServer +
|
||||||
|
"/api/v2/report/offers?handleId=" +
|
||||||
|
encodeURIComponent(this.veriClaim.handleId as string);
|
||||||
|
const offerHeaders = await this.getHeaders(identity);
|
||||||
|
const offerResp = await this.axios.get(offerUrl, {
|
||||||
|
headers: offerHeaders,
|
||||||
|
});
|
||||||
|
if (offerResp.status === 200) {
|
||||||
|
this.detailsForOffer = offerResp.data.data[0];
|
||||||
|
} else {
|
||||||
|
console.error("Error getting detailed offer info:", offerResp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// retrieve the list of confirmers
|
||||||
|
const confirmUrl =
|
||||||
|
this.apiServer +
|
||||||
|
"/api/report/issuersWhoClaimedOrConfirmed?claimId=" +
|
||||||
|
encodeURIComponent(serverUtil.stripEndorserPrefix(claimId));
|
||||||
|
const confirmHeaders = await this.getHeaders(identity);
|
||||||
const response = await this.axios.get(confirmUrl, {
|
const response = await this.axios.get(confirmUrl, {
|
||||||
headers: confirmHeaders,
|
headers: confirmHeaders,
|
||||||
});
|
});
|
||||||
@@ -400,16 +489,23 @@ export default class ClaimView extends Vue {
|
|||||||
}
|
}
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
const serverError = error as AxiosError;
|
const serverError = error as AxiosError;
|
||||||
console.error("Error retrieving confirmations:", serverError);
|
console.error("Error retrieving claim:", serverError);
|
||||||
this.confsVisibleErrorMessage =
|
this.$notify(
|
||||||
"Had problems retrieving confirmations. See logs for more info.";
|
{
|
||||||
|
group: "alert",
|
||||||
|
type: "danger",
|
||||||
|
title: "Error",
|
||||||
|
text: "Something went wrong retrieving claim data.",
|
||||||
|
},
|
||||||
|
-1,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async showFullClaim(claimId: string) {
|
async showFullClaim(claimId: string) {
|
||||||
await accountsDB.open();
|
await accountsDB.open();
|
||||||
const accounts = accountsDB.accounts;
|
const accounts = accountsDB.accounts;
|
||||||
const accountsArr = await accounts?.toArray();
|
const accountsArr: Account[] = await accounts?.toArray();
|
||||||
const account = accountsArr.find((acc) => acc.did === this.activeDid);
|
const account = accountsArr.find((acc) => acc.did === this.activeDid);
|
||||||
const identity = JSON.parse(account?.identity || "null");
|
const identity = JSON.parse(account?.identity || "null");
|
||||||
|
|
||||||
@@ -512,6 +608,16 @@ export default class ClaimView extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showDifferentClaimPage(claimId: string) {
|
||||||
|
const route = {
|
||||||
|
path: "/claim/" + encodeURIComponent(claimId),
|
||||||
|
};
|
||||||
|
this.$router.push(route).then(async () => {
|
||||||
|
this.resetThisValues();
|
||||||
|
await this.loadClaim(claimId, JSON.parse(this.accountIdentityStr));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
openFulfillGiftDialog() {
|
openFulfillGiftDialog() {
|
||||||
const giver: GiverInputInfo = {
|
const giver: GiverInputInfo = {
|
||||||
did: libsUtil.offerGiverDid(this.veriClaim),
|
did: libsUtil.offerGiverDid(this.veriClaim),
|
||||||
|
|||||||
@@ -699,11 +699,6 @@ export default class ProjectViewView extends Vue {
|
|||||||
claimType: "Offer",
|
claimType: "Offer",
|
||||||
issuer: offer.offeredByDid,
|
issuer: offer.offeredByDid,
|
||||||
};
|
};
|
||||||
console.log(
|
|
||||||
"checking for can fulfill ",
|
|
||||||
libsUtil.canFulfillOffer(offerRecord),
|
|
||||||
offerRecord,
|
|
||||||
);
|
|
||||||
return libsUtil.canFulfillOffer(offerRecord);
|
return libsUtil.canFulfillOffer(offerRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user