diff --git a/src/components/EntityGrid.vue b/src/components/EntityGrid.vue
index 847f36e7..2fcf7acb 100644
--- a/src/components/EntityGrid.vue
+++ b/src/components/EntityGrid.vue
@@ -310,16 +310,13 @@ export default class EntityGrid extends Vue {
/**
* Handle special entity selection from SpecialEntityCard
+ * Treat "You" and "Unnamed" as person entities
*/
- handleEntitySelected(event: {
- type: string;
- entityType: string;
- data: { did?: string; name: string };
- }): void {
+ handleEntitySelected(event: { data: { did?: string; name: string } }): void {
+ // Convert special entities to person entities since they represent people
this.emitEntitySelected({
- type: "special",
- entityType: event.entityType,
- data: event.data,
+ type: "person",
+ data: event.data as Contact,
});
}
@@ -327,13 +324,11 @@ export default class EntityGrid extends Vue {
@Emit("entity-selected")
emitEntitySelected(data: {
- type: "person" | "project" | "special";
- entityType?: string;
- data: Contact | PlanData | { did?: string; name: string };
+ type: "person" | "project";
+ data: Contact | PlanData;
}): {
- type: "person" | "project" | "special";
- entityType?: string;
- data: Contact | PlanData | { did?: string; name: string };
+ type: "person" | "project";
+ data: Contact | PlanData;
} {
return data;
}
diff --git a/src/components/EntitySelectionStep.vue b/src/components/EntitySelectionStep.vue
index dcbd8490..2fb6bcac 100644
--- a/src/components/EntitySelectionStep.vue
+++ b/src/components/EntitySelectionStep.vue
@@ -56,9 +56,8 @@ interface EntityData {
* Entity selection event data structure
*/
interface EntitySelectionEvent {
- type: "person" | "project" | "special";
- entityType?: string;
- data: Contact | PlanData | EntityData;
+ type: "person" | "project";
+ data: Contact | PlanData;
}
/**
diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue
index 923596fd..ec78ddf4 100644
--- a/src/components/GiftedDialog.vue
+++ b/src/components/GiftedDialog.vue
@@ -561,20 +561,21 @@ export default class GiftedDialog extends Vue {
/**
* Handle entity selection from EntitySelectionStep
- * @param entity - The selected entity (person, project, or special) with stepType
+ * @param entity - The selected entity (person or project) with stepType
*/
handleEntitySelected(entity: {
- type: "person" | "project" | "special";
- entityType?: string;
- data: Contact | PlanData | { did?: string; name: string };
+ type: "person" | "project";
+ data: Contact | PlanData;
stepType: string;
}) {
if (entity.type === "person") {
const contact = entity.data as Contact;
+ // Apply DID-based logic for person entities
+ const processedContact = this.processPersonEntity(contact);
if (entity.stepType === "giver") {
- this.selectGiver(contact);
+ this.selectGiver(processedContact);
} else {
- this.selectRecipient(contact);
+ this.selectRecipient(processedContact);
}
} else if (entity.type === "project") {
const project = entity.data as PlanData;
@@ -583,33 +584,22 @@ export default class GiftedDialog extends Vue {
} else {
this.selectRecipientProject(project);
}
- } else if (entity.type === "special") {
- // Handle special entities like "You" and "Unnamed"
- if (entity.entityType === "you") {
- // "You" entity selected
- const youEntity = {
- did: this.activeDid,
- name: "You",
- };
- if (entity.stepType === "giver") {
- this.giver = youEntity;
- } else {
- this.receiver = youEntity;
- }
- this.firstStep = false;
- } else if (entity.entityType === "unnamed") {
- // "Unnamed" entity selected
- const unnamedEntity = {
- did: "",
- name: "Unnamed",
- };
- if (entity.stepType === "giver") {
- this.giver = unnamedEntity;
- } else {
- this.receiver = unnamedEntity;
- }
- this.firstStep = false;
- }
+ }
+ }
+
+ /**
+ * Processes person entities using DID-based logic for "You" and "Unnamed"
+ */
+ private processPersonEntity(contact: Contact): Contact {
+ if (contact.did === this.activeDid) {
+ // If DID matches active DID, create "You" entity
+ return { ...contact, name: "You" };
+ } else if (!contact.did || contact.did === "") {
+ // If DID is empty/null, create "Unnamed" entity
+ return { ...contact, name: "Unnamed" };
+ } else {
+ // Return the contact as-is
+ return contact;
}
}
diff --git a/src/components/SpecialEntityCard.vue b/src/components/SpecialEntityCard.vue
index 1d475229..e489d003 100644
--- a/src/components/SpecialEntityCard.vue
+++ b/src/components/SpecialEntityCard.vue
@@ -124,8 +124,6 @@ export default class SpecialEntityCard extends Vue {
handleClick(): void {
if (this.selectable && !this.conflicted) {
this.emitEntitySelected({
- type: "special",
- entityType: this.entityType,
data: this.entityData,
});
} else if (this.conflicted && this.notify) {
@@ -145,13 +143,7 @@ export default class SpecialEntityCard extends Vue {
// Emit methods using @Emit decorator
@Emit("entity-selected")
- emitEntitySelected(data: {
- type: string;
- entityType: string;
- data: { did?: string; name: string };
- }): {
- type: string;
- entityType: string;
+ emitEntitySelected(data: { data: { did?: string; name: string } }): {
data: { did?: string; name: string };
} {
return data;
diff --git a/src/views/ContactGiftingView.vue b/src/views/ContactGiftingView.vue
index 2534f551..f27abc13 100644
--- a/src/views/ContactGiftingView.vue
+++ b/src/views/ContactGiftingView.vue
@@ -28,7 +28,7 @@
@@ -48,7 +48,7 @@
@@ -207,7 +207,7 @@ export default class ContactGiftingView extends Vue {
}
}
- openDialog(contact?: GiverReceiverInputInfo | "Unnamed" | "You") {
+ openDialog(contact?: GiverReceiverInputInfo) {
// Determine the selected entity based on contact type
const selectedEntity = this.createEntityFromContact(contact);
@@ -231,19 +231,26 @@ export default class ContactGiftingView extends Vue {
/**
* Creates an entity object from the contact parameter
+ * Uses DID-based logic to determine "You" and "Unnamed" entities
*/
private createEntityFromContact(
- contact?: GiverReceiverInputInfo | "Unnamed" | "You",
+ contact?: GiverReceiverInputInfo,
): GiverReceiverInputInfo | undefined {
- if (contact === "You") {
+ if (!contact) {
+ return undefined;
+ }
+
+ // Handle GiverReceiverInputInfo object
+ if (contact.did === this.activeDid) {
+ // If DID matches active DID, create "You" entity
return { did: this.activeDid, name: "You" };
- } else if (contact === "Unnamed") {
+ } else if (!contact.did || contact.did === "") {
+ // If DID is empty/null, create "Unnamed" entity
return { did: "", name: "Unnamed" };
- } else if (contact) {
+ } else {
// Create a copy of the contact to avoid modifying the original
return { ...contact };
}
- return undefined;
}
/**
diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue
index 4af9b5bc..7c4789f7 100644
--- a/src/views/HomeView.vue
+++ b/src/views/HomeView.vue
@@ -1475,30 +1475,41 @@ export default class HomeView extends Vue {
* @param giver Optional contact info for giver
* @param description Optional gift description
*/
- openDialog(giver?: GiverReceiverInputInfo | "Unnamed", prompt?: string) {
- if (giver === "Unnamed") {
- // Special case: Pass undefined to trigger Step 1, but with "Unnamed" pre-selected
- (this.$refs.giftedDialog as GiftedDialog).open(
- undefined,
- {
- did: this.activeDid,
- name: "You",
- } as GiverReceiverInputInfo,
- undefined,
- prompt,
- );
- // Immediately select "Unnamed" and move to Step 2
- (this.$refs.giftedDialog as GiftedDialog).selectGiver();
+ openDialog(giver?: GiverReceiverInputInfo, prompt?: string) {
+ // Determine the giver entity based on DID logic
+ const giverEntity = this.createGiverEntity(giver);
+
+ (this.$refs.giftedDialog as GiftedDialog).open(
+ giverEntity,
+ {
+ did: this.activeDid,
+ name: "You", // In HomeView, we always use "You" as the giver
+ } as GiverReceiverInputInfo,
+ undefined,
+ prompt,
+ );
+ }
+
+ /**
+ * Creates giver entity using DID-based logic
+ */
+ private createGiverEntity(
+ giver?: GiverReceiverInputInfo,
+ ): GiverReceiverInputInfo | undefined {
+ if (!giver) {
+ return undefined;
+ }
+
+ // Handle GiverReceiverInputInfo object
+ if (giver.did === this.activeDid) {
+ // If DID matches active DID, create "You" entity
+ return { did: this.activeDid, name: "You" };
+ } else if (!giver.did || giver.did === "") {
+ // If DID is empty/null, create "Unnamed" entity
+ return { did: "", name: "Unnamed" };
} else {
- (this.$refs.giftedDialog as GiftedDialog).open(
- giver,
- {
- did: this.activeDid,
- name: "You",
- } as GiverReceiverInputInfo,
- undefined,
- prompt,
- );
+ // Return the giver as-is
+ return giver;
}
}
@@ -1627,10 +1638,7 @@ export default class HomeView extends Vue {
}
}
- openPersonDialog(
- giver?: GiverReceiverInputInfo | "Unnamed",
- prompt?: string,
- ) {
+ openPersonDialog(giver?: GiverReceiverInputInfo, prompt?: string) {
this.showProjectsDialog = false;
this.openDialog(giver, prompt);
}