forked from trent_larson/crowd-funder-for-time-pwa
Refactor: eliminate "special" entity type and use DID-based logic
Replace string-based entity type matching with DID-based logic for "You" and "Unnamed" entities. Treat these as regular person entities instead of special types. - Remove "special" type from EntitySelectionEvent interface - Update EntityGrid to emit "You" and "Unnamed" as person entities - Simplify SpecialEntityCard emit structure (remove entityType parameter) - Refactor GiftedDialog to process all person entities with DID-based logic - Update ContactGiftingView and HomeView to use DID-based entity creation - Remove string literals "You" and "Unnamed" from method signatures
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user