Skip to content

Commit

Permalink
feat: Display extended address field in contact view
Browse files Browse the repository at this point in the history
  • Loading branch information
zatteo committed Sep 26, 2024
1 parent 2bec6b4 commit 091bafc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 10 additions & 1 deletion libs/cozy/contact.lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ export const addressFieldOptions = [
},
];

export const extendedAddressFields = [
"locality",
"floor",
"building",
"stairs",
"apartment",
"entrycode",
];

export const fields = [
{
name: "gender",
Expand Down Expand Up @@ -242,7 +251,7 @@ const CONTACT_FIELDS_FR = {
note: "Notes",
label: "Libellé",
number: "Numéro de voie",
street: "Adresse postal",
street: "Adresse postale",
code: "Code postal",
city: "Ville",
country: "Pays",
Expand Down
6 changes: 5 additions & 1 deletion libs/cozy/fields.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
fields as fieldsModels,
getTranslatedNameForContactField,
getFormattedValueForContactField,
extendedAddressFields,
} from "./contact.lib";

const {
Expand Down Expand Up @@ -168,7 +169,10 @@ const buildFieldsFromContactByBrowsingModels = ({
}: any) => {
models.forEach((fieldModel: any) => {
const fieldName = fieldModel.name;
const fieldValue = data[fieldModel.name];
// Small hack to support extended fields inside extended address
const fieldValue = extendedAddressFields.includes(fieldModel.name)
? data?.extendedAddress[fieldModel.name]
: data[fieldModel.name];

if (!fieldValue) {
return;
Expand Down

0 comments on commit 091bafc

Please sign in to comment.