diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue index c6eb2064..51b7e833 100644 --- a/src/components/GiftedDialog.vue +++ b/src/components/GiftedDialog.vue @@ -1,99 +1,534 @@ + + + + + + + +
+
+ + +
+
+ + +
+ +
+

+ {{ + giverEntityType === "project" + ? "Benefited from:" + : "Received from:" + }} +

+

+ {{ giver.name }} +

+

+ (No name) +

+

+ (Unnamed) +

+
+ +

+ +

+
+ + + +
+
+ +
+ +
+

+ Given to project: +

+

+ {{ receiver.name }} +

+

+ (Unnamed) +

+
+ +

+ +

+
-
+ + + + + +
+ - + Photo & more options… + +

+ Sign & Send to publish to the world + +

+ + +
+

+ + Cannot record: Same person selected as both giver and recipient +

-
-
- - +
-

- Sign & Send to publish to the world - -

-
- - + Sign & Send + + +
diff --git a/src/libs/fontawesome.ts b/src/libs/fontawesome.ts index b1768d38..2fa70e3c 100644 --- a/src/libs/fontawesome.ts +++ b/src/libs/fontawesome.ts @@ -29,6 +29,7 @@ import { faCircleCheck, faCircleInfo, faCircleQuestion, + faCircleRight, faCircleUser, faClock, faCoins, @@ -60,6 +61,7 @@ import { faLightbulb, faLink, faLocationDot, + faLock, faLongArrowAltLeft, faLongArrowAltRight, faMagnifyingGlass, @@ -79,6 +81,7 @@ import { faSquareCaretDown, faSquareCaretUp, faSquarePlus, + faThumbtack, faTrashCan, faTriangleExclamation, faUser, @@ -111,6 +114,7 @@ library.add( faCircleCheck, faCircleInfo, faCircleQuestion, + faCircleRight, faCircleUser, faClock, faCoins, @@ -142,6 +146,7 @@ library.add( faLightbulb, faLink, faLocationDot, + faLock, faLongArrowAltLeft, faLongArrowAltRight, faMagnifyingGlass, @@ -161,6 +166,7 @@ library.add( faSquareCaretDown, faSquareCaretUp, faSquarePlus, + faThumbtack, faTrashCan, faTriangleExclamation, faUser, diff --git a/src/libs/util.ts b/src/libs/util.ts index 17ba3c8e..79ef1120 100644 --- a/src/libs/util.ts +++ b/src/libs/util.ts @@ -50,6 +50,8 @@ import { DEFAULT_ROOT_DERIVATION_PATH } from "./crypto"; export interface GiverReceiverInputInfo { did?: string; name?: string; + image?: string; + handleId?: string; } export enum OnboardPage { diff --git a/src/views/ContactGiftingView.vue b/src/views/ContactGiftingView.vue index c359a817..d351fdcb 100644 --- a/src/views/ContactGiftingView.vue +++ b/src/views/ContactGiftingView.vue @@ -4,14 +4,14 @@
-

+

- Given by... + {{ stepType === "giver" ? "Given by..." : "Given to..." }}

@@ -19,19 +19,18 @@ - +
@@ -97,6 +103,24 @@ export default class ContactGiftingView extends Vue { description = ""; projectId = ""; prompt = ""; + recipientProjectName = ""; + recipientProjectImage = ""; + recipientProjectHandleId = ""; + + // New context parameters + stepType = "giver"; + giverEntityType = "person" as "person" | "project"; + recipientEntityType = "person" as "person" | "project"; + giverProjectId = ""; + giverProjectName = ""; + giverProjectImage = ""; + giverProjectHandleId = ""; + giverDid = ""; + recipientDid = ""; + fromProjectId = ""; + toProjectId = ""; + showProjects = false; + isFromProjectView = false; async created() { try { @@ -124,9 +148,41 @@ export default class ContactGiftingView extends Vue { ); } - this.projectId = (this.$route.query["projectId"] as string) || ""; + this.projectId = + (this.$route.query["recipientProjectId"] as string) || ""; + this.recipientProjectName = + (this.$route.query["recipientProjectName"] as string) || ""; + this.recipientProjectImage = + (this.$route.query["recipientProjectImage"] as string) || ""; + this.recipientProjectHandleId = + (this.$route.query["recipientProjectHandleId"] as string) || ""; this.prompt = (this.$route.query["prompt"] as string) ?? this.prompt; + // Read new context parameters + this.stepType = (this.$route.query["stepType"] as string) || "giver"; + this.giverEntityType = + (this.$route.query["giverEntityType"] as "person" | "project") || + "person"; + this.recipientEntityType = + (this.$route.query["recipientEntityType"] as "person" | "project") || + "person"; + this.giverProjectId = + (this.$route.query["giverProjectId"] as string) || ""; + this.giverProjectName = + (this.$route.query["giverProjectName"] as string) || ""; + this.giverProjectImage = + (this.$route.query["giverProjectImage"] as string) || ""; + this.giverProjectHandleId = + (this.$route.query["giverProjectHandleId"] as string) || ""; + this.giverDid = (this.$route.query["giverDid"] as string) || ""; + this.recipientDid = (this.$route.query["recipientDid"] as string) || ""; + this.fromProjectId = (this.$route.query["fromProjectId"] as string) || ""; + this.toProjectId = (this.$route.query["toProjectId"] as string) || ""; + this.showProjects = + (this.$route.query["showProjects"] as string) === "true"; + this.isFromProjectView = + (this.$route.query["isFromProjectView"] as string) === "true"; + // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (err: any) { logger.error("Error retrieving settings & contacts:", err); @@ -144,17 +200,108 @@ export default class ContactGiftingView extends Vue { } } - openDialog(giver?: GiverReceiverInputInfo) { - const recipient = this.projectId - ? undefined - : { did: this.activeDid, name: "you" }; - (this.$refs.customDialog as GiftedDialog).open( - giver, - recipient, - undefined, - "Given by " + (giver?.name || "someone not named"), - this.prompt, - ); + openDialog(contact?: GiverReceiverInputInfo | "Unnamed") { + if (contact === "Unnamed") { + // Special case: Pass undefined to trigger Step 1, but with "Unnamed" pre-selected + let recipient: GiverReceiverInputInfo; + let giver: GiverReceiverInputInfo | undefined; + + if (this.stepType === "giver") { + // We're selecting a giver, so recipient is either a project or the current user + if (this.recipientEntityType === "project") { + recipient = { + did: this.recipientProjectHandleId, + name: this.recipientProjectName, + image: this.recipientProjectImage, + handleId: this.recipientProjectHandleId, + }; + } else { + recipient = { did: this.activeDid, name: "You" }; + } + giver = undefined; // Will be set to "Unnamed" in GiftedDialog + } else { + // We're selecting a recipient, so recipient is "Unnamed" and giver is preserved from context + recipient = { did: "", name: "Unnamed" }; + + // Preserve the existing giver from the context + if (this.giverEntityType === "project") { + giver = { + // no did, because it's a project + name: this.giverProjectName, + image: this.giverProjectImage, + handleId: this.giverProjectHandleId, + }; + } else if (this.giverDid) { + giver = { + did: this.giverDid, + name: this.giverProjectName || "Someone", + }; + } else { + giver = { did: this.activeDid, name: "You" }; + } + } + + (this.$refs.customDialog as GiftedDialog).open( + giver, + recipient, + undefined, + this.stepType === "giver" ? "Given by Unnamed" : "Given to Unnamed", + this.prompt, + ); + // Immediately select "Unnamed" and move to Step 2 + (this.$refs.customDialog as GiftedDialog).selectGiver(); + } else { + // Regular case: contact is a GiverReceiverInputInfo + let giver: GiverReceiverInputInfo; + let recipient: GiverReceiverInputInfo; + + if (this.stepType === "giver") { + // We're selecting a giver, so the contact becomes the giver + giver = contact as GiverReceiverInputInfo; // Safe because we know contact is not "Unnamed" or undefined + + // Recipient is either a project or the current user + if (this.recipientEntityType === "project") { + recipient = { + did: this.recipientProjectHandleId, + name: this.recipientProjectName, + image: this.recipientProjectImage, + handleId: this.recipientProjectHandleId, + }; + } else { + recipient = { did: this.activeDid, name: "You" }; + } + } else { + // We're selecting a recipient, so the contact becomes the recipient + recipient = contact as GiverReceiverInputInfo; // Safe because we know contact is not "Unnamed" or undefined + + // Preserve the existing giver from the context + if (this.giverEntityType === "project") { + giver = { + did: this.giverProjectHandleId, + name: this.giverProjectName, + image: this.giverProjectImage, + handleId: this.giverProjectHandleId, + }; + } else if (this.giverDid) { + giver = { + did: this.giverDid, + name: this.giverProjectName || "Someone", + }; + } else { + giver = { did: this.activeDid, name: "You" }; + } + } + + (this.$refs.customDialog as GiftedDialog).open( + giver, + recipient, + undefined, + this.stepType === "giver" + ? "Given by " + (contact?.name || "someone not named") + : "Given to " + (contact?.name || "someone not named"), + this.prompt, + ); + } } } diff --git a/src/views/GiftedDetailsView.vue b/src/views/GiftedDetailsView.vue index 277546bc..6dbec987 100644 --- a/src/views/GiftedDetailsView.vue +++ b/src/views/GiftedDetailsView.vue @@ -4,84 +4,91 @@
- -
-

- + +
+

+ +
+ +
+ What Was Given

+ +

+
+ From + {{ + providedByProject + ? providerProjectName + : providedByGiver + ? giverName + : "someone not named" + }} +
+
+ to + {{ + givenToProject + ? fulfillsProjectName + : givenToRecipient + ? recipientName + : "someone not named" + }} +
+

- -

What Was Given

- -

- - From - {{ - providedByProject - ? providerProjectName - : providedByGiver - ? giverName - : "someone not named" - }} - -
- - to - {{ - givenToProject - ? fulfillsProjectName - : givenToRecipient - ? recipientName - : "someone not named" - }} -