From ffac143ab944207a45c5dd82adb86c6e3a346cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 24 Oct 2025 17:03:27 +0200 Subject: [PATCH] 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. --- src/Bundle/ChillMainBundle/Resources/public/types.ts | 7 +++++++ .../ChillThirdPartyBundle/Resources/public/types.ts | 9 +++++---- .../public/vuejs/_components/OnTheFly/ThirdPartyEdit.vue | 7 ++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/types.ts b/src/Bundle/ChillMainBundle/Resources/public/types.ts index efd250c10..bf6122080 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/types.ts +++ b/src/Bundle/ChillMainBundle/Resources/public/types.ts @@ -182,6 +182,13 @@ export interface Address { isNoAddress: boolean; } +/** + * Associate an existing address in write operations. + */ +export interface SetAddress { + id: number; +} + export interface AddressWithPoint extends Address { point: Point; } diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/types.ts b/src/Bundle/ChillThirdPartyBundle/Resources/public/types.ts index 2185b0b9a..3c48c7929 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/types.ts +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/types.ts @@ -2,7 +2,7 @@ import { Address, Center, Civility, - DateTime, SetCivility, + DateTime, SetAddress, SetCivility, User, } from "ChillMainAssets/types"; @@ -111,6 +111,9 @@ export interface ThirdpartyCategory { }; } +/** + * Associate an existing ThirdParty during write operation. + */ export interface SetThirdParty { readonly type: "thirdparty"; id: number; @@ -129,9 +132,7 @@ export interface ThirdPartyWrite { email: string; telephone: string; telephone2: string; - address: null|{ - address_id: number; - } + address: null|SetAddress; comment: string; parent: SetThirdParty|null; } diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdPartyEdit.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdPartyEdit.vue index 4fba5a137..89c98ce85 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdPartyEdit.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdPartyEdit.vue @@ -336,7 +336,7 @@ const context = computed(() => { defaults: (window as any).addaddress, } if (thirdParty.value.address) { - ctx.addressId = thirdParty.value.address.address_id + ctx.addressId = thirdParty.value.address.id ctx.edit = true } return ctx @@ -385,8 +385,9 @@ async function loadData(): Promise { if (!props.id) return Promise.resolve() } -function submitAddress(payload: { address_id: number }) { - // TODO +function submitAddress(payload: { addressId: number }) { + console.log(payload); + thirdParty.value.address = {id: payload.addressId}; } function addQueryItem(field: 'name' | 'firstName', queryItem: string) {