diff --git a/src/components/OfferDialog.vue b/src/components/OfferDialog.vue index efbe7d789..980a61f11 100644 --- a/src/components/OfferDialog.vue +++ b/src/components/OfferDialog.vue @@ -81,8 +81,7 @@ import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; export default class OfferDialog extends Vue { $notify!: (notification: NotificationIface, timeout?: number) => void; - @Prop message = ""; - @Prop projectId = ""; + @Prop projectId? = ""; activeDid = ""; apiServer = ""; @@ -91,16 +90,20 @@ export default class OfferDialog extends Vue { amountUnitCode = "HUR"; description = ""; expirationDateInput = ""; + recipientDid? = ""; visible = false; libsUtil = libsUtil; - async open() { + async open(recipientDid?: string) { try { + this.recipientDid = recipientDid; + await db.open(); const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; this.apiServer = settings?.apiServer || ""; this.activeDid = settings?.activeDid || ""; + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (err: any) { console.error("Error retrieving settings from database:", err); @@ -222,6 +225,7 @@ export default class OfferDialog extends Vue { amount, unitCode, expirationDateInput, + this.recipientDid, this.projectId, ); diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 65371ef87..a51467f9d 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -143,6 +143,7 @@ export interface OfferVerifiableCredential { isPartOf?: { identifier?: string; lastClaimId?: string; "@type"?: string }; }; offeredBy?: { identifier: string }; + recipient?: { identifier: string }; validThrough?: string; } @@ -582,6 +583,7 @@ export async function createAndSubmitOffer( amount?: number, unitCode?: string, expirationDate?: string, + recipientDid?: string, fulfillsProjectHandleId?: string, ): Promise { const vcClaim: OfferVerifiableCredential = { @@ -599,6 +601,9 @@ export async function createAndSubmitOffer( if (description) { vcClaim.itemOffered = { description }; } + if (recipientDid) { + vcClaim.recipient = { identifier: recipientDid }; + } if (fulfillsProjectHandleId) { vcClaim.itemOffered = vcClaim.itemOffered || {}; vcClaim.itemOffered.isPartOf = { diff --git a/src/views/ClaimView.vue b/src/views/ClaimView.vue index e47e40efe..e1ba5489a 100644 --- a/src/views/ClaimView.vue +++ b/src/views/ClaimView.vue @@ -406,7 +406,6 @@ import { Component, Vue } from "vue-facing-decorator"; import { useClipboard } from "@vueuse/core"; import GiftedDialog from "@/components/GiftedDialog.vue"; -import OfferDialog from "@/components/OfferDialog.vue"; import { NotificationIface } from "@/constants/app"; import { accountsDB, db } from "@/db/index"; import { Contact } from "@/db/tables/contacts"; @@ -419,7 +418,7 @@ import { Account } from "@/db/tables/accounts"; import { GiverInputInfo } from "@/libs/endorserServer"; @Component({ - components: { GiftedDialog, OfferDialog, QuickNav }, + components: { GiftedDialog, QuickNav }, }) export default class ClaimView extends Vue { $notify!: (notification: NotificationIface, timeout?: number) => void; diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 6f1119d45..aecd23393 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -177,7 +177,7 @@ + + @@ -241,6 +248,9 @@

There are no contacts.

+ + +
void; @@ -1131,6 +1142,10 @@ export default class ContactsView extends Vue { } } + openOfferDialog(recipientDid: string) { + (this.$refs.customOfferDialog as OfferDialog).open(recipientDid); + } + // similar function is in endorserServer.ts private async createAndSubmitContactGive( identity: IIdentifier,