From 92be2f1e5ab220cd625c3ae8e54185b91bfb2924 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Tue, 6 Jan 2026 16:00:44 +0000 Subject: [PATCH] save filter sanity - make it look pretty --- src/app/api/properties/route.ts | 2 +- .../[slug]/components/PropertyFilters.tsx | 4 +-- .../[slug]/components/PropertyTable.tsx | 2 +- src/app/portfolio/[slug]/utils.ts | 32 ++++++------------- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/app/api/properties/route.ts b/src/app/api/properties/route.ts index 68c5fb7..f8148b3 100644 --- a/src/app/api/properties/route.ts +++ b/src/app/api/properties/route.ts @@ -17,7 +17,7 @@ export async function POST(req: NextRequest) { console.log("filters", filters); const properties = await getProperties( portfolioId, - 1000, + 10000, 0, filters ); diff --git a/src/app/portfolio/[slug]/components/PropertyFilters.tsx b/src/app/portfolio/[slug]/components/PropertyFilters.tsx index d99ea8f..f06106e 100644 --- a/src/app/portfolio/[slug]/components/PropertyFilters.tsx +++ b/src/app/portfolio/[slug]/components/PropertyFilters.tsx @@ -105,7 +105,7 @@ export default function PropertyFilters({ epcIndex(epc) <= epcIndex(expectedEpc) } > - {epc} or worse + {epc} or below ))} @@ -128,7 +128,7 @@ export default function PropertyFilters({ epcIndex(epc) >= epcIndex(currentEpc) } > - {epc} or better + {epc} or above ))} diff --git a/src/app/portfolio/[slug]/components/PropertyTable.tsx b/src/app/portfolio/[slug]/components/PropertyTable.tsx index 472082c..885c214 100644 --- a/src/app/portfolio/[slug]/components/PropertyTable.tsx +++ b/src/app/portfolio/[slug]/components/PropertyTable.tsx @@ -44,7 +44,7 @@ export function parsePropertyFilters( parsed.push({ field: "expectedEpc", operator: "epc_at_least", - value: filters.expected_epc_at_least.toUpperCase(), + value: filters.expected_epc_at_least, }); } console.log(parsed) diff --git a/src/app/portfolio/[slug]/utils.ts b/src/app/portfolio/[slug]/utils.ts index 3874589..0903bae 100644 --- a/src/app/portfolio/[slug]/utils.ts +++ b/src/app/portfolio/[slug]/utils.ts @@ -457,32 +457,20 @@ export async function getProperties( break; } case "expectedEpc": { + const minSap = + EPC_TO_SAP_MIN[filter.value as keyof typeof EPC_TO_SAP_MIN]; + if (minSap === undefined) break; + if (filter.operator === "epc_at_least") { - whereClauses.push(sql` - CASE t.epc::text - WHEN 'A' THEN 7 - WHEN 'B' THEN 6 - WHEN 'C' THEN 5 - WHEN 'D' THEN 4 - WHEN 'E' THEN 3 - WHEN 'F' THEN 2 - WHEN 'G' THEN 1 - END - >= - CASE ${filter.value} - WHEN 'A' THEN 7 - WHEN 'B' THEN 6 - WHEN 'C' THEN 5 - WHEN 'D' THEN 4 - WHEN 'E' THEN 3 - WHEN 'F' THEN 2 - WHEN 'G' THEN 1 - END - `); + whereClauses.push( + sql` + pl.post_sap_points IS NOT NULL + AND pl.post_sap_points >= ${minSap} + ` + ); } break; } - } }