refactor(components): extract shared entity utilities and simplify item components (F1.3, F1.4)

Extract 3 entity composables (useEntityCustomFields, useEntityDocuments,
useEntityProductDisplay) and entityCustomFieldLogic utility shared across
ComponentItem (1336→585 LOC) and PieceItem (1588→740 LOC).
Improve type safety in edit/create pages with explicit casts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-02-09 11:19:40 +01:00
parent e1594cab76
commit 519fa3a8f4
15 changed files with 1047 additions and 1883 deletions

View File

@@ -813,13 +813,14 @@ const fetchPieceTypeNames = async (ids: string[]) => {
)
const next = { ...fetchedPieceTypeMap.value }
results.forEach((result, index) => {
if (result.status !== 'fulfilled') {
const key = missing[index]
if (!key || result.status !== 'fulfilled') {
return
}
const data = result.value?.data
const name = data?.name || data?.code
if (name) {
next[missing[index]] = name
next[key] = name
}
})
fetchedPieceTypeMap.value = next
@@ -1144,7 +1145,7 @@ const resolveOptions = (field: any): string[] => {
return option.trim()
}
if (typeof option === 'object') {
const record = option || {}
const record = option as Record<string, unknown>
const keys = ['value', 'label', 'name']
for (const key of keys) {
const candidate = record[key]