Update address handling in third-party components and types for consistency.

- Replaced `address_id` with `id` in `ThirdPartyEdit.vue` and associated logic.
- Introduced `SetAddress` type to standardize address references in write operations.
- Updated `SetThirdParty` and related types to use `SetAddress` for better type safety.
This commit is contained in:
2025-10-24 17:03:27 +02:00
parent f1bf6023ff
commit ffac143ab9
3 changed files with 16 additions and 7 deletions

View File

@@ -182,6 +182,13 @@ export interface Address {
isNoAddress: boolean; isNoAddress: boolean;
} }
/**
* Associate an existing address in write operations.
*/
export interface SetAddress {
id: number;
}
export interface AddressWithPoint extends Address { export interface AddressWithPoint extends Address {
point: Point; point: Point;
} }

View File

@@ -2,7 +2,7 @@ import {
Address, Address,
Center, Center,
Civility, Civility,
DateTime, SetCivility, DateTime, SetAddress, SetCivility,
User, User,
} from "ChillMainAssets/types"; } from "ChillMainAssets/types";
@@ -111,6 +111,9 @@ export interface ThirdpartyCategory {
}; };
} }
/**
* Associate an existing ThirdParty during write operation.
*/
export interface SetThirdParty { export interface SetThirdParty {
readonly type: "thirdparty"; readonly type: "thirdparty";
id: number; id: number;
@@ -129,9 +132,7 @@ export interface ThirdPartyWrite {
email: string; email: string;
telephone: string; telephone: string;
telephone2: string; telephone2: string;
address: null|{ address: null|SetAddress;
address_id: number;
}
comment: string; comment: string;
parent: SetThirdParty|null; parent: SetThirdParty|null;
} }

View File

@@ -336,7 +336,7 @@ const context = computed(() => {
defaults: (window as any).addaddress, defaults: (window as any).addaddress,
} }
if (thirdParty.value.address) { if (thirdParty.value.address) {
ctx.addressId = thirdParty.value.address.address_id ctx.addressId = thirdParty.value.address.id
ctx.edit = true ctx.edit = true
} }
return ctx return ctx
@@ -385,8 +385,9 @@ async function loadData(): Promise<void> {
if (!props.id) return Promise.resolve() if (!props.id) return Promise.resolve()
} }
function submitAddress(payload: { address_id: number }) { function submitAddress(payload: { addressId: number }) {
// TODO console.log(payload);
thirdParty.value.address = {id: payload.addressId};
} }
function addQueryItem(field: 'name' | 'firstName', queryItem: string) { function addQueryItem(field: 'name' | 'firstName', queryItem: string) {