v2.1
Ship configurator updates with catalog DB included for server deploy. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -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
|
||||
`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user