Ship configurator updates with catalog DB included for server deploy.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
lejay
2026-10-07 17:13:03 +02:00
co-authored by Cursor
parent 6c0d7e47b8
commit 30921aade6
75 changed files with 15618 additions and 1300 deletions
+14 -4
View File
@@ -1,15 +1,25 @@
import pool from '../db/index.js';
const CONFIGURATOR_MATERIAL_FILTER = `
active = 1
AND NOT (
supplier_id = (SELECT id FROM suppliers WHERE code = 'haefele')
OR LOWER(COALESCE(collection, '')) = 'hafele'
OR formex_code LIKE 'HAF-%'
)
`;
/**
* GET /api/finishes
* Returns active Formex materials as finishes for the configurator
* Returns active panel materials as finishes for the configurator
* Falls back to legacy finishes if no Formex materials exist
*/
export async function getFinishes(req, res) {
try {
// Check if we have active Formex materials
// Hardware suppliers can share formex_materials for catalog synchronization,
// but their products must never be offered as panel finishes.
const formexResult = await pool.query(
`SELECT COUNT(*) as count FROM formex_materials WHERE active = 1`
`SELECT COUNT(*) as count FROM formex_materials WHERE ${CONFIGURATOR_MATERIAL_FILTER}`
);
const hasFormexMaterials = (formexResult.rows[0]?.count || 0) > 0;
@@ -32,7 +42,7 @@ export async function getFinishes(req, res) {
dominant_color as hexColor,
'formex' as source
FROM formex_materials
WHERE active = 1
WHERE ${CONFIGURATOR_MATERIAL_FILTER}
ORDER BY collection, name
`);