Browse Source

switch BVC-meeting-end gift to be from the plan, and add display of providers on claim-view page

master
Trent Larson 2 months ago
parent
commit
36e5d0a6f5
  1. 4
      CHANGELOG.md
  2. 10
      src/libs/endorserServer.ts
  3. 85
      src/views/ClaimView.vue
  4. 2
      src/views/GiftedDetailsView.vue
  5. 2
      src/views/ProjectViewView.vue
  6. 14
      src/views/QuickActionBvcEndView.vue

4
CHANGELOG.md

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [?]
### Added
- Display of providers on claim view page
### Changed
- Switched BVC-meeting-ending gift to be a gift from the group.
## [0.3.27] - 2024.09.22 - ee23e6f005e47f5bd6f04d804599f6395371b0e4

10
src/libs/endorserServer.ts

@ -141,6 +141,7 @@ export interface GiveVerifiableCredential extends GenericVerifiableCredential {
identifier?: string;
image?: string;
object?: { amountOfThisGood: number; unitCode: string };
provider?: Array<GenericVerifiableCredential>; // typically @type & identifier
recipient?: { identifier: string };
}
@ -592,6 +593,7 @@ export function hydrateGive(
fulfillsOfferHandleId?: string,
isTrade: boolean = false,
imageUrl?: string,
providers?: Array<GenericVerifiableCredential>, // typically @type & identifier
lastClaimId?: string,
): GiveVerifiableCredential {
// Remember: replace values or erase if it's null
@ -650,6 +652,8 @@ export function hydrateGive(
vcClaim.image = imageUrl || undefined;
vcClaim.provider = providers || undefined;
return vcClaim;
}
@ -674,6 +678,7 @@ export async function createAndSubmitGive(
fulfillsOfferHandleId?: string,
isTrade: boolean = false,
imageUrl?: string,
providers?: Array<GenericVerifiableCredential>,
): Promise<CreateAndSubmitClaimResult> {
const vcClaim = hydrateGive(
undefined,
@ -686,6 +691,7 @@ export async function createAndSubmitGive(
fulfillsOfferHandleId,
isTrade,
imageUrl,
providers,
undefined,
);
return createAndSubmitClaim(
@ -718,6 +724,7 @@ export async function editAndSubmitGive(
fulfillsOfferHandleId?: string,
isTrade: boolean = false,
imageUrl?: string,
providers?: Array<GenericVerifiableCredential>,
): Promise<CreateAndSubmitClaimResult> {
const vcClaim = hydrateGive(
fullClaim.claim,
@ -730,6 +737,7 @@ export async function editAndSubmitGive(
fulfillsOfferHandleId,
isTrade,
imageUrl,
providers,
fullClaim.id,
);
return createAndSubmitClaim(
@ -1180,7 +1188,7 @@ export const claimSpecialDescription = (
export const BVC_MEETUPS_PROJECT_CLAIM_ID =
import.meta.env.VITE_BVC_MEETUPS_PROJECT_CLAIM_ID ||
"https://endorser.ch/entity/01HWE8FWHQ1YGP7GFZYYPS272F"; // this won't resolve as a URL on production; it's a URN only found in the test system
"https://endorser.ch/entity/01GXYPFF7FA03NXKPYY142PY4H"; // production value, which seems like the safest value if forgotten
export const bvcMeetingJoinClaim = (did: string, startTime: string) => {
return {

85
src/views/ClaimView.vue

@ -89,7 +89,7 @@
<!-- Fullfills Links -->
<!-- fullfills links for a give -->
<div v-if="detailsForGive?.fulfillsPlanHandleId">
<div v-if="detailsForGive?.fulfillsPlanHandleId" class="mt-4">
<router-link
:to="
'/project/' +
@ -113,7 +113,7 @@
@click="
showDifferentClaimPage(detailsForGive?.fulfillsHandleId)
"
class="text-blue-500 mt-4"
class="text-blue-500 mt-4 cursor-pointer"
>
Fulfills
{{
@ -136,6 +136,41 @@
Offered to a bigger plan...
</router-link>
</div>
<!-- Providers -->
<div v-if="providersForGive?.length > 0" class="mt-4">
<span>Other assistance provided by:</span>
<ul class="ml-4">
<li
v-for="provider of providersForGive"
:key="provider.identifier"
class="list-disc ml-4"
>
<div class="flex gap-4">
<div class="grow overflow-hidden">
<a
@click="
provider.identifier.startsWith('did:')
? this.$router.push(
'/did/' +
encodeURIComponent(provider.identifier),
)
: showDifferentClaimPage(provider.identifier)
"
class="text-blue-500 mt-4 cursor-pointer"
>
{{
provider.identifier.startsWith("did:")
? "a person..."
: "an activity..."
}}
</a>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
@ -465,6 +500,11 @@ import {
OfferVerifiableCredential,
} from "@/libs/endorserServer";
interface ProviderInfo {
identifier: string; // could be a DID or a handleId
linkConfirmed: boolean;
}
@Component({
components: { GiftedDialog, QuickNav },
})
@ -488,6 +528,7 @@ export default class ClaimView extends Vue {
isEditedGlobalId = false;
isRegistered = false;
numConfsNotVisible = 0; // number of hidden DIDs in the confirmerIdList, minus the issuer if they aren't visible
providersForGive: ProviderInfo[] = [];
showDidCopy = false;
showIdCopy = false;
showVeriClaimDump = false;
@ -620,11 +661,40 @@ export default class ClaimView extends Vue {
const giveResp = await this.axios.get(giveUrl, {
headers: giveHeaders,
});
if (giveResp.status === 200) {
if (giveResp.status === 200 && giveResp.data.data?.length > 0) {
this.detailsForGive = giveResp.data.data[0];
} else {
console.error("Error getting detailed give info:", giveResp);
}
// look for providers
const providerUrl =
this.apiServer +
"/api/v2/report/providersToGive?handleId=" +
encodeURIComponent(this.veriClaim.handleId as string);
console.log("providerUrl:", providerUrl);
const providerHeaders = await serverUtil.getHeaders(userDid);
const providerResp = await this.axios.get(providerUrl, {
headers: providerHeaders,
});
// should be at least an empty array
if (
providerResp.status === 200 &&
Array.isArray(providerResp.data.data)
) {
this.providersForGive = providerResp.data.data;
} else {
console.error("Error getting give providers:", giveResp);
this.$notify(
{
group: "alert",
type: "warning",
title: "Error",
text: "Got error retrieving linked provider data.",
},
-1,
);
}
} else if (this.veriClaim.claimType === "Offer") {
const offerUrl =
this.apiServer +
@ -638,6 +708,15 @@ export default class ClaimView extends Vue {
this.detailsForOffer = offerResp.data.data[0];
} else {
console.error("Error getting detailed offer info:", offerResp);
this.$notify(
{
group: "alert",
type: "warning",
title: "Error",
text: "Got error retrieving linked offer data.",
},
-1,
);
}
}

2
src/views/GiftedDetailsView.vue

@ -640,6 +640,7 @@ export default class GiftedDetails extends Vue {
this.offerId,
this.isTrade,
this.imageUrl,
[],
);
}
@ -708,6 +709,7 @@ export default class GiftedDetails extends Vue {
this.offerId,
this.isTrade,
this.imageUrl,
[],
this.prevCredToEdit?.id as string,
);
const claimStr = JSON.stringify(giveClaim);

2
src/views/ProjectViewView.vue

@ -385,7 +385,7 @@
<span>
{{
serverUtil.didInfo(
give.agentDid,
give.recipientDid,
activeDid,
allMyDids,
allContacts,

14
src/views/QuickActionBvcEndView.vue

@ -97,7 +97,7 @@
<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 else gave</span>
<span class="pb-2 pl-2 pr-2">The group provided</span>
<span v-if="someoneGave">
<input
type="text"
@ -305,6 +305,12 @@ export default class QuickActionBvcBeginView extends Vue {
// now send the give for the description
let giveSucceeded = false;
if (this.someoneGave) {
const providers: Array<GenericVerifiableCredential> = [
{
"@type": "PlanAction",
identifier: BVC_MEETUPS_PROJECT_CLAIM_ID,
},
];
const giveResult = await createAndSubmitGive(
axios,
this.apiServer,
@ -314,7 +320,11 @@ export default class QuickActionBvcBeginView extends Vue {
this.description,
undefined,
undefined,
BVC_MEETUPS_PROJECT_CLAIM_ID,
undefined,
undefined,
false,
undefined,
providers,
);
giveSucceeded = giveResult.type === "success";
if (!giveSucceeded) {

Loading…
Cancel
Save