feat(fournisseurs) : categories (M2M) + telephones (1-N) + import customer.json
All checks were successful
Auto Tag Develop / tag (push) Successful in 9s
All checks were successful
Auto Tag Develop / tag (push) Successful in 9s
- Nouvelles entites ConstructeurCategorie (referentiel M2M) et ConstructeurTelephone (1-N) - Constructeur : retrait colonne phone, ajout collections telephones/categories, groupes de serialisation constructeur:read/write - Migration : cree les 3 tables, migre la colonne phone existante vers constructeur_telephone, drop phone - Commande app:import-fournisseurs (dry-run par defaut, --force) : non destructive, find-or-create par nom, ne touche jamais un ID existant, ajout-seulement pour telephones/categories - MAJ MCP tools / MachineStructureController / audit subscriber / tests - Frontend : page constructeurs avec telephones multiples + categories (tableau, filtre, formulaire), composable useConstructeurCategories, composant ConstructeurCategorieSelect Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,49 @@
|
||||
import { formatPhone } from '~/utils/formatters/phone';
|
||||
|
||||
export interface ConstructeurTelephoneSummary {
|
||||
numero?: string | null;
|
||||
label?: string | null;
|
||||
}
|
||||
|
||||
export interface ConstructeurSummary {
|
||||
id: string;
|
||||
name?: string | null;
|
||||
email?: string | null;
|
||||
// Legacy single-phone string: still exposed by the machine-structure normalization.
|
||||
phone?: string | null;
|
||||
// Multi-phone list: exposed by the /constructeurs API resource.
|
||||
telephones?: ConstructeurTelephoneSummary[] | null;
|
||||
}
|
||||
|
||||
type ConstructeurPhoneSource = {
|
||||
phone?: string | null;
|
||||
telephones?: ConstructeurTelephoneSummary[] | null;
|
||||
} | null | undefined;
|
||||
|
||||
export const constructeurPhones = (
|
||||
constructeur: ConstructeurPhoneSource,
|
||||
): Array<{ numero: string; label: string | null }> => {
|
||||
if (!constructeur) {
|
||||
return [];
|
||||
}
|
||||
const list = Array.isArray(constructeur.telephones)
|
||||
? constructeur.telephones
|
||||
.filter((t): t is ConstructeurTelephoneSummary => Boolean(t && t.numero && String(t.numero).trim()))
|
||||
.map(t => ({ numero: String(t.numero).trim(), label: (t.label ?? null) || null }))
|
||||
: [];
|
||||
if (!list.length && constructeur.phone && constructeur.phone.trim()) {
|
||||
return [{ numero: constructeur.phone.trim(), label: null }];
|
||||
}
|
||||
return list;
|
||||
};
|
||||
|
||||
export const constructeurPrimaryPhone = (
|
||||
constructeur: ConstructeurPhoneSource,
|
||||
): string | null => {
|
||||
const phones = constructeurPhones(constructeur);
|
||||
return phones.length ? phones[0]!.numero : null;
|
||||
};
|
||||
|
||||
export interface ConstructeurLinkEntry {
|
||||
linkId?: string;
|
||||
constructeurId: string;
|
||||
@@ -133,8 +170,8 @@ export const formatConstructeurContact = (
|
||||
return '';
|
||||
}
|
||||
|
||||
const formattedPhone = formatPhone(constructeur.phone);
|
||||
const phone = formattedPhone || constructeur.phone || null;
|
||||
const primary = constructeurPrimaryPhone(constructeur);
|
||||
const phone = formatPhone(primary) || primary || null;
|
||||
|
||||
return [constructeur.email, phone].filter(Boolean).join(' • ');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user