v2.1
Ship configurator updates with catalog DB included for server deploy. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
import { DRAWERS, NICHE } from '../../shared/manufacturing.js';
|
||||
import {
|
||||
DRAWERS,
|
||||
NICHE,
|
||||
PLINTH,
|
||||
MAX_PANEL_DIMENSION_MM,
|
||||
MAX_PANEL_SHORT_SIDE_MM,
|
||||
validateHorizontalSpans
|
||||
} from '../../shared/manufacturing.js';
|
||||
|
||||
export function validateConfig(config = {}, settings = {}) {
|
||||
const errors = [];
|
||||
@@ -12,6 +19,53 @@ export function validateConfig(config = {}, settings = {}) {
|
||||
const modules = Array.isArray(config.modules) ? config.modules : [];
|
||||
const allowSliding = String(settings.allow_sliding_doors ?? '0') === '1';
|
||||
const sanitaryGapMm = Number(settings.sanitary_gap_mm || NICHE.sanitaryGapAround);
|
||||
const plinthHeightMm = Number(config.plinthHeightMm ?? 100);
|
||||
const maxPanelLongMm = Number(
|
||||
settings.panel_max_width_mm ??
|
||||
settings.max_panel_width_mm ??
|
||||
settings.max_panel_dimension_mm ??
|
||||
MAX_PANEL_DIMENSION_MM
|
||||
);
|
||||
const maxPanelShortMm = Number(
|
||||
settings.panel_max_short_side_mm ??
|
||||
settings.max_panel_short_side_mm ??
|
||||
MAX_PANEL_SHORT_SIDE_MM
|
||||
);
|
||||
|
||||
if (widthMm > maxPanelLongMm) {
|
||||
errors.push({
|
||||
field: 'widthMm',
|
||||
message: `Largeur maximale ${maxPanelLongMm} mm (capacité CNC).`
|
||||
});
|
||||
}
|
||||
if (depthMm > maxPanelShortMm) {
|
||||
errors.push({
|
||||
field: 'depthMm',
|
||||
message: `Profondeur maximale ${maxPanelShortMm} mm (capacité CNC).`
|
||||
});
|
||||
}
|
||||
|
||||
if (config.horizontalSpans != null && !Array.isArray(config.horizontalSpans)) {
|
||||
errors.push({
|
||||
field: 'horizontalSpans',
|
||||
message: 'Les traverses horizontales doivent être fournies sous forme de tableau.'
|
||||
});
|
||||
} else {
|
||||
validateHorizontalSpans(config, { maxPanelWidthMm: maxPanelLongMm }).forEach((issue) => {
|
||||
errors.push({
|
||||
field: issue.field,
|
||||
code: issue.code,
|
||||
message: issue.message
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (!PLINTH.targetHeightsMm.includes(plinthHeightMm)) {
|
||||
errors.push({
|
||||
field: 'plinthHeightMm',
|
||||
message: `Hauteur AXILO 78 invalide. Valeurs admises : ${PLINTH.targetHeightsMm.join(', ')} mm.`
|
||||
});
|
||||
}
|
||||
|
||||
if (doorType === 'sliding' && !allowSliding) {
|
||||
errors.push({ field: 'doorType', message: 'Portes coulissantes désactivées.' });
|
||||
@@ -35,13 +89,12 @@ export function validateConfig(config = {}, settings = {}) {
|
||||
const drawerDepthStep = Number(settings.drawer_depth_step_mm || DRAWERS.depthStep);
|
||||
|
||||
/** Même logique que `useWardrobeConfig` : pas de 50 mm sur la profondeur utile, puis réserve tiroir caché. */
|
||||
const inferredEffectiveDrawerDepthMm = () => {
|
||||
const inferredEffectiveDrawerDepthMm = (drawerType = config.hardware?.drawerType || 'visible') => {
|
||||
const rawGap = depthMm - NICHE.drawerBackGap;
|
||||
const clamped = Math.max(drawerDepthMin, Math.min(drawerDepthMax, rawGap));
|
||||
const steppedMm = Math.round(clamped / drawerDepthStep) * drawerDepthStep;
|
||||
const rawDt = config.hardware?.drawerType || 'visible';
|
||||
const depthReductionMm =
|
||||
rawDt === 'hidden' || rawDt === 'hidden_with_handle' ? DRAWERS.hiddenHandleDepthReduction : 0;
|
||||
drawerType === 'hidden' || drawerType === 'hidden_with_handle' ? DRAWERS.hiddenHandleDepthReduction : 0;
|
||||
return Math.max(350, steppedMm - depthReductionMm);
|
||||
};
|
||||
|
||||
@@ -53,13 +106,27 @@ export function validateConfig(config = {}, settings = {}) {
|
||||
if (m.hasRod && heightMm < 1200) {
|
||||
errors.push({ field: `modules[${index}]`, message: 'Tringle autorisée à partir de 1200 mm de hauteur armoire.' });
|
||||
}
|
||||
if (isDrawerCol) {
|
||||
const moduleDepth = inferredEffectiveDrawerDepthMm(m.drawerType ?? config.hardware?.drawerType);
|
||||
if (moduleDepth < 350 || moduleDepth > drawerDepthMax) {
|
||||
errors.push({
|
||||
field: `modules[${index}].drawerType`,
|
||||
message: `Profondeur tiroir utile hors bornes (350-${drawerDepthMax} mm) pour ce block.`
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Profondeur utile tiroir — alignée sur useWardrobeConfig (pas de 50 sur prof. caisse puis −40 si caché).
|
||||
* Ne pas exiger un multiple de 50 sur la valeur finale : ex. 550 − 40 = 510 mm est valide.
|
||||
*/
|
||||
const canonicalEffectiveDrawerDepthMm = inferredEffectiveDrawerDepthMm();
|
||||
const drawerModules = modules.filter((m) => (m.drawers || 0) > 0 || m.type === 'tiroirs');
|
||||
const canonicalDrawerDepths = drawerModules.map((m) =>
|
||||
inferredEffectiveDrawerDepthMm(m.drawerType ?? config.hardware?.drawerType)
|
||||
);
|
||||
const canonicalEffectiveDrawerDepthMm =
|
||||
canonicalDrawerDepths[0] ?? inferredEffectiveDrawerDepthMm();
|
||||
const effectiveDrawerMinMm = 350;
|
||||
if (
|
||||
canonicalEffectiveDrawerDepthMm < effectiveDrawerMinMm ||
|
||||
@@ -75,6 +142,7 @@ export function validateConfig(config = {}, settings = {}) {
|
||||
if (
|
||||
Number.isFinite(explicitEff) &&
|
||||
explicitEff > 0 &&
|
||||
canonicalDrawerDepths.every((depth) => depth === canonicalEffectiveDrawerDepthMm) &&
|
||||
Math.abs(explicitEff - canonicalEffectiveDrawerDepthMm) > 2
|
||||
) {
|
||||
warnings.push({
|
||||
|
||||
Reference in New Issue
Block a user