fix(parcel-sync): freshness check only on primary layers (terenuri + cladiri)

Secondary layers (LIMITE_INTRAV, LIMITE_UAT) are synced once and rarely
change. They were causing permanent "1 vechi" badge even after fresh
sync of terenuri+cladiri.

Now canExportLocal and the freshness badge only consider TERENURI_ACTIVE
and CLADIRI_ACTIVE — the layers that actually matter for export.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
AI Assistant
2026-03-26 22:07:15 +02:00
parent 318cb6037e
commit e5da0301de
@@ -143,12 +143,18 @@ export function ExportTab({
const dbTotalFeatures = dbLayersSummary.reduce((sum, l) => sum + l.count, 0); const dbTotalFeatures = dbLayersSummary.reduce((sum, l) => sum + l.count, 0);
// Only check primary layers (terenuri + cladiri) for freshness —
// secondary layers (intravilan, limite UAT) don't affect export readiness
const PRIMARY_LAYERS = ["TERENURI_ACTIVE", "CLADIRI_ACTIVE"];
const primaryLayers = dbLayersSummary.filter((l) =>
PRIMARY_LAYERS.includes(l.id),
);
const allFresh = const allFresh =
dbLayersSummary.length > 0 && dbLayersSummary.every((l) => l.isFresh); primaryLayers.length > 0 && primaryLayers.every((l) => l.isFresh);
const hasData = dbTotalFeatures > 0; const hasData = dbTotalFeatures > 0;
const canExportLocal = allFresh && hasData; const canExportLocal = allFresh && hasData;
const oldestSyncDate = dbLayersSummary.reduce( const oldestSyncDate = primaryLayers.reduce(
(oldest, l) => { (oldest, l) => {
if (!l.lastSynced) return oldest; if (!l.lastSynced) return oldest;
if (!oldest || l.lastSynced < oldest) return l.lastSynced; if (!oldest || l.lastSynced < oldest) return l.lastSynced;
@@ -620,21 +626,22 @@ export function ExportTab({
layere layere
</span> </span>
{(() => { {(() => {
const freshCount = dbLayersSummary.filter( // Check freshness only for primary layers (terenuri + cladiri)
const freshCount = primaryLayers.filter(
(l) => l.isFresh, (l) => l.isFresh,
).length; ).length;
const staleCount = dbLayersSummary.length - freshCount; const staleCount = primaryLayers.length - freshCount;
const oldestSync = dbLayersSummary.reduce( const newestSync = primaryLayers.reduce(
(oldest, l) => { (newest, l) => {
if (!l.lastSynced) return oldest; if (!l.lastSynced) return newest;
if (!oldest || l.lastSynced < oldest) return l.lastSynced; if (!newest || l.lastSynced > newest) return l.lastSynced;
return oldest; return newest;
}, },
null as Date | null, null as Date | null,
); );
return ( return (
<> <>
{staleCount === 0 ? ( {staleCount === 0 && primaryLayers.length > 0 ? (
<Badge <Badge
variant="outline" variant="outline"
className="text-emerald-600 border-emerald-200 dark:text-emerald-400 dark:border-emerald-800" className="text-emerald-600 border-emerald-200 dark:text-emerald-400 dark:border-emerald-800"
@@ -651,9 +658,9 @@ export function ExportTab({
{staleCount} vechi {staleCount} vechi
</Badge> </Badge>
)} )}
{oldestSync && ( {newestSync && (
<span className="text-xs text-muted-foreground"> <span className="text-xs text-muted-foreground">
Ultima sincronizare: {relativeTime(oldestSync)} Ultima sincronizare: {relativeTime(newestSync)}
</span> </span>
)} )}
</> </>