remove more duplicate data & consolidate interfaces

This commit is contained in:
2026-01-20 20:41:44 -07:00
parent bcf654e2e8
commit a0b99d5fca
5 changed files with 38 additions and 48 deletions

View File

@@ -45,7 +45,7 @@ import EntityGrid from "./EntityGrid.vue";
import { Contact } from "../db/tables/contacts";
import { PlanData } from "../interfaces/records";
import { NotificationIface } from "../constants/app";
import { EntityData } from "@/interfaces";
import { GiverReceiverInputInfo } from "@/libs/util";
/**
* Entity selection event data structure
@@ -96,11 +96,11 @@ export default class EntitySelectionStep extends Vue {
/** Current giver entity for context */
@Prop()
giver?: EntityData | null;
giver?: GiverReceiverInputInfo | null;
/** Current receiver entity for context */
@Prop()
receiver?: EntityData | null;
receiver?: GiverReceiverInputInfo | null;
/** Notification function from parent component */
@Prop()

View File

@@ -50,7 +50,7 @@ import EntityIcon from "./EntityIcon.vue";
import ProjectIcon from "./ProjectIcon.vue";
import { Contact } from "../db/tables/contacts";
import { UNNAMED_ENTITY_NAME } from "@/constants/entities";
import { EntityData } from "@/interfaces";
import { GiverReceiverInputInfo } from "@/libs/util";
/**
* EntitySummaryButton - Displays selected entity with edit capability
@@ -72,7 +72,7 @@ import { EntityData } from "@/interfaces";
export default class EntitySummaryButton extends Vue {
/** Entity data to display */
@Prop({ required: true })
entity!: EntityData | Contact | null;
entity!: GiverReceiverInputInfo | Contact | null;
/** Display label for the entity role */
@Prop({ required: true })
@@ -85,7 +85,7 @@ export default class EntitySummaryButton extends Vue {
@Prop({ type: Function, default: () => {} })
onEditRequested!: (data: {
entityType: string;
entity: EntityData | Contact | null;
entity: GiverReceiverInputInfo | Contact | null;
}) => void | Promise<void>;
get entityType(): string {

View File

@@ -102,7 +102,7 @@ import { Component, Prop, Vue, Watch, Emit } from "vue-facing-decorator";
import EntitySummaryButton from "./EntitySummaryButton.vue";
import AmountInput from "./AmountInput.vue";
import { RouteLocationRaw } from "vue-router";
import { EntityData } from "@/interfaces";
import { GiverReceiverInputInfo } from "@/libs/util";
/**
* GiftDetailsStep - Complete step 2 gift details form interface
@@ -128,11 +128,11 @@ import { EntityData } from "@/interfaces";
export default class GiftDetailsStep extends Vue {
/** Giver entity data */
@Prop({ required: true })
giver!: EntityData | null;
giver!: GiverReceiverInputInfo | null;
/** Receiver entity data */
@Prop({ required: true })
receiver!: EntityData | null;
receiver!: GiverReceiverInputInfo | null;
/** Gift description */
@Prop({ default: "" })
@@ -321,7 +321,7 @@ export default class GiftDetailsStep extends Vue {
*/
handleEditGiver(_data: {
entityType: string;
entity: EntityData | null;
entity: GiverReceiverInputInfo | null;
}): void {
this.emitEditEntity({
entityType: "giver",
@@ -335,7 +335,7 @@ export default class GiftDetailsStep extends Vue {
*/
handleEditRecipient(_data: {
entityType: string;
entity: EntityData | null;
entity: GiverReceiverInputInfo | null;
}): void {
this.emitEditEntity({
entityType: "recipient",
@@ -375,8 +375,8 @@ export default class GiftDetailsStep extends Vue {
@Emit("edit-entity")
emitEditEntity(data: {
entityType: string;
currentEntity: EntityData | null;
}): { entityType: string; currentEntity: EntityData | null } {
currentEntity: GiverReceiverInputInfo | null;
}): { entityType: string; currentEntity: GiverReceiverInputInfo | null } {
return data;
}

View File

@@ -3,7 +3,7 @@
<div
class="dialog"
data-testid="gifted-dialog"
:data-recipient-entity-type="currentRecipientEntityType"
:data-recipient-entity-type="recipientEntityType"
>
<!-- Step 1: Entity Selection -->
<EntitySelectionStep
@@ -25,8 +25,8 @@
v-show="!firstStep"
:giver="giver"
:receiver="receiver"
:giver-entity-type="currentGiverEntityType"
:recipient-entity-type="currentRecipientEntityType"
:giver-entity-type="giverEntityType"
:recipient-entity-type="recipientEntityType"
:description="description"
:amount="parseFloat(amountInput) || 0"
:unit-code="unitCode"
@@ -117,8 +117,6 @@ export default class GiftedDialog extends Vue {
description = "";
firstStep = true; // true = Step 1 (giver/recipient selection), false = Step 2 (amount/description)
giver?: libsUtil.GiverReceiverInputInfo; // undefined means no identified giver agent
currentGiverEntityType: "person" | "project" = "person"; // Mutable version (can be toggled)
currentRecipientEntityType: "person" | "project" = "person"; // Mutable version (can be toggled)
offerId = "";
prompt = "";
receiver?: libsUtil.GiverReceiverInputInfo;
@@ -130,12 +128,20 @@ export default class GiftedDialog extends Vue {
didInfo = didInfo;
get giverEntityType(): string {
return this.giver && "handleId" in this.giver ? "project" : "person";
}
get recipientEntityType(): string {
return this.receiver && "handleId" in this.receiver ? "project" : "person";
}
// Computed property to check if current selection would create a conflict
get hasPersonConflict() {
// Only check for conflicts when both entities are persons
if (
this.currentGiverEntityType !== "person" ||
this.currentRecipientEntityType !== "person"
this.giverEntityType !== "person" ||
this.recipientEntityType !== "person"
) {
return false;
}
@@ -156,8 +162,8 @@ export default class GiftedDialog extends Vue {
get hasProjectConflict() {
// Only check for conflicts when both entities are projects
if (
this.currentGiverEntityType !== "project" ||
this.currentRecipientEntityType !== "project"
this.giverEntityType !== "project" ||
this.recipientEntityType !== "project"
) {
return false;
}
@@ -192,9 +198,6 @@ export default class GiftedDialog extends Vue {
this.amountInput = amountInput || "0";
this.unitCode = unitCode || "HUR";
this.callbackOnSuccess = callbackOnSuccess;
// Initialize current entity types from initial prop values
this.currentGiverEntityType = this.initialGiverEntityType;
this.currentRecipientEntityType = this.initialRecipientEntityType;
try {
const settings = await this.$accountSettings();
@@ -265,8 +268,8 @@ export default class GiftedDialog extends Vue {
wouldCreateConflict(identifier: string) {
// Check for person conflicts when both entities are persons
if (
this.currentGiverEntityType === "person" &&
this.currentRecipientEntityType === "person"
this.giverEntityType === "person" &&
this.recipientEntityType === "person"
) {
if (this.stepType === "giver") {
// If selecting as giver, check if it conflicts with current recipient
@@ -279,8 +282,8 @@ export default class GiftedDialog extends Vue {
// Check for project conflicts when both entities are projects
if (
this.currentGiverEntityType === "project" &&
this.currentRecipientEntityType === "project"
this.giverEntityType === "project" &&
this.recipientEntityType === "project"
) {
if (this.stepType === "giver") {
// If selecting as giver, check if it conflicts with current recipient
@@ -302,9 +305,6 @@ export default class GiftedDialog extends Vue {
this.prompt = "";
this.unitCode = "HUR";
this.firstStep = true;
// Reset to initial prop values
this.currentGiverEntityType = this.initialGiverEntityType;
this.currentRecipientEntityType = this.initialRecipientEntityType;
}
async confirm() {
@@ -392,8 +392,8 @@ export default class GiftedDialog extends Vue {
let providerPlanHandleId: string | undefined;
if (
this.currentGiverEntityType === "project" &&
this.currentRecipientEntityType === "person"
this.giverEntityType === "project" &&
this.recipientEntityType === "person"
) {
// Project-to-person gift
fromDid = undefined;
@@ -401,8 +401,8 @@ export default class GiftedDialog extends Vue {
fulfillsProjectHandleId = undefined;
providerPlanHandleId = this.giver?.handleId;
} else if (
this.currentGiverEntityType === "person" &&
this.currentRecipientEntityType === "project"
this.giverEntityType === "person" &&
this.recipientEntityType === "project"
) {
// Person-to-project gift
fromDid = giverDid as string;
@@ -410,8 +410,8 @@ export default class GiftedDialog extends Vue {
fulfillsProjectHandleId = this.receiver?.handleId;
providerPlanHandleId = undefined;
} else if (
this.currentGiverEntityType === "person" &&
this.currentRecipientEntityType === "person"
this.giverEntityType === "person" &&
this.recipientEntityType === "person"
) {
// Person-to-person gift
fromDid = giverDid as string;

View File

@@ -125,16 +125,6 @@ export interface DexieError extends Error {
stack?: string;
}
/**
* Entity interface for both person and project entities
*/
export interface EntityData {
did?: string;
handleId?: string;
name?: string;
image?: string;
}
/**
* Type guard for database constraint errors
*/