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

@@ -825,10 +825,9 @@ const customFieldReorderClass = (index: number) => {
const addCustomField = () => {
ensureArray('customFields')
const nextIndex = Array.isArray(props.node.customFields)
? props.node.customFields.length
: 0
props.node.customFields.push({
const fields = props.node.customFields!
const nextIndex = fields.length
fields.push({
name: '',
type: 'text',
required: false,
@@ -847,7 +846,7 @@ const removeCustomField = (index: number) => {
const addPiece = () => {
ensureArray('pieces')
props.node.pieces.push({
props.node.pieces!.push({
typePieceId: '',
typePieceLabel: '',
reference: '',
@@ -863,7 +862,7 @@ const removePiece = (index: number) => {
const addProduct = () => {
ensureArray('products')
props.node.products.push({
props.node.products!.push({
typeProductId: '',
typeProductLabel: '',
familyCode: '',
@@ -911,6 +910,7 @@ const moveItemInPlace = <T,>(list: T[], from: number, to: number) => {
}
const updated = list.slice()
const [item] = updated.splice(from, 1)
if (item === undefined) return
updated.splice(to, 0, item)
list.splice(0, list.length, ...updated)
}