|
|
@ -21,12 +21,22 @@ |
|
|
|
<h1 class="text-4xl text-center font-light px-4 mb-4">What Was Given</h1> |
|
|
|
|
|
|
|
<h1 class="text-xl font-bold text-center mb-4"> |
|
|
|
<span>From {{ giverName || "someone not named" }}</span> |
|
|
|
<span> |
|
|
|
From |
|
|
|
{{ |
|
|
|
providedByProject |
|
|
|
? providerProjectName |
|
|
|
: providedByGiver |
|
|
|
? giverName |
|
|
|
: "someone not named" |
|
|
|
}} |
|
|
|
</span> |
|
|
|
<br /> |
|
|
|
<span> |
|
|
|
to |
|
|
|
{{ |
|
|
|
givenToProject |
|
|
|
? projectName |
|
|
|
? fulfillsProjectName |
|
|
|
: givenToRecipient |
|
|
|
? recipientName |
|
|
|
: "someone unidentified" |
|
|
@ -87,7 +97,29 @@ |
|
|
|
|
|
|
|
<div class="h-7 mt-4 flex"> |
|
|
|
<input |
|
|
|
v-if="projectId && !givenToRecipient" |
|
|
|
v-if="providerProjectId && !providedByGiver" |
|
|
|
type="checkbox" |
|
|
|
class="h-6 w-6 mr-2" |
|
|
|
v-model="providedByProject" |
|
|
|
/> |
|
|
|
<fa |
|
|
|
v-else |
|
|
|
icon="square" |
|
|
|
class="bg-slate-500 text-slate-500 h-5 w-5 px-0.5 py-0.5 mr-2 rounded" |
|
|
|
@click="notifyUserOfProvidingProject()" |
|
|
|
/> |
|
|
|
<label class="text-sm mt-1"> |
|
|
|
{{ |
|
|
|
providerProjectId |
|
|
|
? "This was provided by " + providerProjectName |
|
|
|
: "This was not provided by a project" |
|
|
|
}} |
|
|
|
</label> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="h-7 mt-4 flex"> |
|
|
|
<input |
|
|
|
v-if="fulfillsProjectId && !givenToRecipient" |
|
|
|
type="checkbox" |
|
|
|
class="h-6 w-6 mr-2" |
|
|
|
v-model="givenToProject" |
|
|
@ -96,13 +128,13 @@ |
|
|
|
v-else |
|
|
|
icon="square" |
|
|
|
class="bg-slate-500 text-slate-500 h-5 w-5 px-0.5 py-0.5 mr-2 rounded" |
|
|
|
@click="notifyUserOfProject()" |
|
|
|
@click="notifyUserFulfillsProject()" |
|
|
|
/> |
|
|
|
<label class="text-sm mt-1"> |
|
|
|
{{ |
|
|
|
projectId |
|
|
|
? "This was given to " + projectName |
|
|
|
: "No project was chosen" |
|
|
|
fulfillsProjectId |
|
|
|
? "This was given to " + fulfillsProjectName |
|
|
|
: "No recipient project was chosen" |
|
|
|
}} |
|
|
|
</label> |
|
|
|
</div> |
|
|
@ -211,8 +243,10 @@ export default class GiftedDetails extends Vue { |
|
|
|
amountInput = "0"; |
|
|
|
description = ""; |
|
|
|
destinationPathAfter = ""; |
|
|
|
givenToProject = false; |
|
|
|
givenToRecipient = false; |
|
|
|
fulfillsProjectId = ""; |
|
|
|
fulfillsProjectName = "a project"; |
|
|
|
givenToProject = false; // basically static, based on input; if we allow changing then let's fix things (see below) |
|
|
|
givenToRecipient = false; // basically static, based on input; if we allow changing then let's fix things (see below) |
|
|
|
giverDid: string | undefined; |
|
|
|
giverName = ""; |
|
|
|
hideBackButton = false; |
|
|
@ -221,8 +255,10 @@ export default class GiftedDetails extends Vue { |
|
|
|
message = ""; |
|
|
|
offerId = ""; |
|
|
|
prevCredToEdit?: GenericCredWrapper<GiveVerifiableCredential>; |
|
|
|
projectId = ""; |
|
|
|
projectName = "a project"; |
|
|
|
providerProjectId = ""; |
|
|
|
providerProjectName = "a project"; |
|
|
|
providedByProject = false; // basically static, based on input; if we allow changing then let's fix things (see below) |
|
|
|
providedByGiver = false; // basically static, based on input; if we allow changing then let's fix things (see below) |
|
|
|
recipientDid = ""; |
|
|
|
recipientName = ""; |
|
|
|
showGeneralAdvanced = false; |
|
|
@ -282,11 +318,31 @@ export default class GiftedDetails extends Vue { |
|
|
|
offer?.identifier || |
|
|
|
this.offerId) as string; |
|
|
|
|
|
|
|
// find any project ID |
|
|
|
const project = fulfillsArray.find((rec) => rec["@type"] === "PlanAction"); |
|
|
|
this.projectId = ((this.$route as Router).query["projectId"] || |
|
|
|
project?.identifier || |
|
|
|
this.projectId) as string; |
|
|
|
// find any fulfills project ID |
|
|
|
const fulfillsProject = fulfillsArray.find( |
|
|
|
(rec) => rec["@type"] === "PlanAction", |
|
|
|
); |
|
|
|
// eslint-disable-next-line prettier/prettier |
|
|
|
this.fulfillsProjectId = |
|
|
|
((this.$route as Router).query["fulfillsProjectId"] || |
|
|
|
fulfillsProject?.identifier || |
|
|
|
this.fulfillsProjectId) as string; |
|
|
|
|
|
|
|
// find any provider project ID |
|
|
|
const provider = this.prevCredToEdit?.claim?.provider; |
|
|
|
const providerArray = Array.isArray(provider) |
|
|
|
? provider |
|
|
|
: provider |
|
|
|
? [provider] |
|
|
|
: []; |
|
|
|
const providerProject = providerArray.find( |
|
|
|
(rec) => rec["@type"] === "PlanAction", |
|
|
|
); |
|
|
|
this.providerProjectId = ((this.$route as Router).query[ |
|
|
|
"providerProjectId" |
|
|
|
] || |
|
|
|
providerProject?.identifier || |
|
|
|
this.providerProjectId) as string; |
|
|
|
|
|
|
|
this.recipientDid = ((this.$route as Router).query["recipientDid"] || |
|
|
|
this.prevCredToEdit?.claim?.recipient?.identifier) as string; |
|
|
@ -318,7 +374,6 @@ export default class GiftedDetails extends Vue { |
|
|
|
this.imageUrl = (this.$route as Router).query["shareUrl"] as string; |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
const settings = await retrieveSettingsForActiveAccount(); |
|
|
|
this.apiServer = settings.apiServer || ""; |
|
|
|
this.activeDid = settings.activeDid || ""; |
|
|
@ -352,35 +407,37 @@ export default class GiftedDetails extends Vue { |
|
|
|
} |
|
|
|
} |
|
|
|
// these should be functions but something's wrong with the syntax in the <> conditional |
|
|
|
this.givenToProject = !!this.projectId; |
|
|
|
this.givenToProject = !!this.fulfillsProjectId; |
|
|
|
this.givenToRecipient = !this.givenToProject && !!this.recipientDid; |
|
|
|
|
|
|
|
// these should be functions but something's wrong with the syntax in the <> conditional |
|
|
|
this.providedByProject = !!this.providerProjectId; |
|
|
|
this.providedByGiver = !this.providedByProject && !!this.giverDid; |
|
|
|
|
|
|
|
this.showGeneralAdvanced = !!settings.showGeneralAdvanced; |
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any |
|
|
|
} catch (err: any) { |
|
|
|
console.error("Error retrieving settings from database:", err); |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "danger", |
|
|
|
title: "Error", |
|
|
|
text: err.message || "There was an error retrieving your settings.", |
|
|
|
}, |
|
|
|
-1, |
|
|
|
if (this.fulfillsProjectId) { |
|
|
|
// console.log("Getting project name from cache", this.fulfillsProjectId); |
|
|
|
const fulfillsProject = await getPlanFromCache( |
|
|
|
this.fulfillsProjectId, |
|
|
|
this.axios, |
|
|
|
this.apiServer, |
|
|
|
this.activeDid, |
|
|
|
); |
|
|
|
this.fulfillsProjectName = fulfillsProject?.name |
|
|
|
? `the project "${fulfillsProject.name}"` |
|
|
|
: "a project"; |
|
|
|
} |
|
|
|
|
|
|
|
if (this.projectId) { |
|
|
|
// console.log("Getting project name from cache", this.projectId); |
|
|
|
const project = await getPlanFromCache( |
|
|
|
this.projectId, |
|
|
|
if (this.providerProjectId) { |
|
|
|
// console.log("Getting project name from cache", this.providerProjectId); |
|
|
|
const providerProject = await getPlanFromCache( |
|
|
|
this.providerProjectId, |
|
|
|
this.axios, |
|
|
|
this.apiServer, |
|
|
|
this.activeDid, |
|
|
|
); |
|
|
|
this.projectName = project?.name |
|
|
|
? "the project: " + project.name |
|
|
|
this.providerProjectName = providerProject?.name |
|
|
|
? `the project "${providerProject.name}"` |
|
|
|
: "a project"; |
|
|
|
} |
|
|
|
} |
|
|
@ -545,8 +602,35 @@ export default class GiftedDetails extends Vue { |
|
|
|
await this.recordGive(); |
|
|
|
} |
|
|
|
|
|
|
|
notifyUserOfProject() { |
|
|
|
if (!this.projectId) { |
|
|
|
notifyUserOfProvidingProject() { |
|
|
|
// we're here because they clicked and either there is no provider project or there is a giver chosen |
|
|
|
if (!this.providerProjectId) { |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "warning", |
|
|
|
title: "Error", |
|
|
|
text: "To select a project as a provider, you must open this page through a project.", |
|
|
|
}, |
|
|
|
3000, |
|
|
|
); |
|
|
|
} else { |
|
|
|
// no providing project was chosen |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
|
type: "warning", |
|
|
|
title: "Error", |
|
|
|
text: "You cannot select both a giving project and person.", |
|
|
|
}, |
|
|
|
3000, |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
notifyUserFulfillsProject() { |
|
|
|
// we're here because they clicked and either there is no fulfills project or there is a recipient chosen |
|
|
|
if (!this.fulfillsProjectId) { |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
@ -557,7 +641,7 @@ export default class GiftedDetails extends Vue { |
|
|
|
3000, |
|
|
|
); |
|
|
|
} else { |
|
|
|
// must be because givenToRecipient is true |
|
|
|
// no fulfills project was chosen |
|
|
|
this.$notify( |
|
|
|
{ |
|
|
|
group: "alert", |
|
|
@ -607,7 +691,9 @@ export default class GiftedDetails extends Vue { |
|
|
|
const recipientDid = this.givenToRecipient |
|
|
|
? this.recipientDid |
|
|
|
: undefined; |
|
|
|
const projectId = this.givenToProject ? this.projectId : undefined; |
|
|
|
const fulfillsProjectId = this.givenToProject |
|
|
|
? this.fulfillsProjectId |
|
|
|
: undefined; |
|
|
|
let result; |
|
|
|
if (this.prevCredToEdit) { |
|
|
|
// don't create from a blank one in case some properties were set from a different interface |
|
|
@ -621,10 +707,11 @@ export default class GiftedDetails extends Vue { |
|
|
|
this.description, |
|
|
|
parseFloat(this.amountInput), |
|
|
|
this.unitCode, |
|
|
|
projectId, |
|
|
|
fulfillsProjectId, |
|
|
|
this.offerId, |
|
|
|
this.isTrade, |
|
|
|
this.imageUrl, |
|
|
|
this.providerProjectId, |
|
|
|
); |
|
|
|
} else { |
|
|
|
result = await createAndSubmitGive( |
|
|
@ -636,11 +723,11 @@ export default class GiftedDetails extends Vue { |
|
|
|
this.description, |
|
|
|
parseFloat(this.amountInput), |
|
|
|
this.unitCode, |
|
|
|
projectId, |
|
|
|
fulfillsProjectId, |
|
|
|
this.offerId, |
|
|
|
this.isTrade, |
|
|
|
this.imageUrl, |
|
|
|
[], |
|
|
|
this.providerProjectId, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
@ -697,7 +784,9 @@ export default class GiftedDetails extends Vue { |
|
|
|
|
|
|
|
constructGiveParam() { |
|
|
|
const recipientDid = this.givenToRecipient ? this.recipientDid : undefined; |
|
|
|
const projectId = this.givenToProject ? this.projectId : undefined; |
|
|
|
const fulfillsProjectId = this.givenToProject |
|
|
|
? this.fulfillsProjectId |
|
|
|
: undefined; |
|
|
|
const giveClaim = hydrateGive( |
|
|
|
this.prevCredToEdit?.claim as GiveVerifiableCredential, |
|
|
|
this.giverDid, |
|
|
@ -705,11 +794,11 @@ export default class GiftedDetails extends Vue { |
|
|
|
this.description, |
|
|
|
parseFloat(this.amountInput), |
|
|
|
this.unitCode, |
|
|
|
projectId, |
|
|
|
fulfillsProjectId, |
|
|
|
this.offerId, |
|
|
|
this.isTrade, |
|
|
|
this.imageUrl, |
|
|
|
[], |
|
|
|
this.providerProjectId, |
|
|
|
this.prevCredToEdit?.id as string, |
|
|
|
); |
|
|
|
const claimStr = JSON.stringify(giveClaim); |
|
|
|