refactor(front): extract shared utils and rewire pages

This commit is contained in:
Matthieu
2026-02-06 17:16:16 +01:00
parent 1fbd1d1b2e
commit 9ee348fff0
36 changed files with 1686 additions and 2194 deletions

View File

@@ -173,6 +173,20 @@ export interface NormalizedCustomFieldDefinition {
orderIndex: number
}
export interface NormalizedCustomFieldEntry {
customFieldValueId: unknown
id: string | undefined
customFieldId: string | null
name: string
type: string
required: boolean
options: string[]
optionsText: string
defaultValue: unknown
value: string
readOnly: boolean
}
export const normalizeCustomFieldDefinitionEntry = (
definition: Record<string, unknown> = {},
fallbackIndex = 0,
@@ -237,8 +251,8 @@ export const mergeCustomFieldValuesWithDefinitions = (
valueEntries: Record<string, unknown>[] = [],
...definitionSources: unknown[][]
): Record<string, unknown>[] => {
const normalizedValues = (Array.isArray(valueEntries) ? valueEntries : [])
.map((entry) => {
const normalizedValues: Record<string, unknown>[] = (Array.isArray(valueEntries) ? valueEntries : [])
.map((entry): Record<string, unknown> | null => {
if (!entry || typeof entry !== 'object') return null
const normalizedDefinition = normalizeCustomFieldDefinitionEntry(
((entry as Record<string, unknown>).customField || entry) as Record<string, unknown>,
@@ -265,7 +279,7 @@ export const mergeCustomFieldValuesWithDefinitions = (
defaultValue: normalizedDefinition.defaultValue ?? '',
value,
readOnly: !!(entry as Record<string, unknown>)?.readOnly,
}
} as Record<string, unknown>
})
.filter((entry): entry is Record<string, unknown> => entry !== null)