feat(constructeur) : add ConstructeurLinkEntry type, useConstructeurLinks composable, and ConstructeurLinksTable component
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,32 @@ export interface ConstructeurSummary {
|
||||
phone?: string | null;
|
||||
}
|
||||
|
||||
export interface ConstructeurLinkEntry {
|
||||
linkId?: string;
|
||||
constructeurId: string;
|
||||
constructeur?: ConstructeurSummary | null;
|
||||
supplierReference: string | null;
|
||||
}
|
||||
|
||||
export const constructeurIdsFromLinks = (links: ConstructeurLinkEntry[]): string[] =>
|
||||
links.map(l => l.constructeurId).filter(Boolean);
|
||||
|
||||
export const parseConstructeurLinksFromApi = (
|
||||
apiLinks: any[],
|
||||
): ConstructeurLinkEntry[] => {
|
||||
if (!Array.isArray(apiLinks)) return [];
|
||||
return apiLinks
|
||||
.filter(link => link && typeof link === 'object')
|
||||
.map(link => ({
|
||||
linkId: link.id || (typeof link['@id'] === 'string' ? link['@id'].split('/').pop() : undefined),
|
||||
constructeurId: typeof link.constructeur === 'string'
|
||||
? link.constructeur.split('/').pop()!
|
||||
: link.constructeur?.id || '',
|
||||
constructeur: typeof link.constructeur === 'object' ? link.constructeur : null,
|
||||
supplierReference: link.supplierReference ?? null,
|
||||
}));
|
||||
};
|
||||
|
||||
const isObject = (value: unknown): value is Record<string, unknown> =>
|
||||
Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user