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);
// 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 =
dbLayersSummary.length > 0 && dbLayersSummary.every((l) => l.isFresh);
primaryLayers.length > 0 && primaryLayers.every((l) => l.isFresh);
const hasData = dbTotalFeatures > 0;
const canExportLocal = allFresh && hasData;
const oldestSyncDate = dbLayersSummary.reduce(
const oldestSyncDate = primaryLayers.reduce(
(oldest, l) => {
if (!l.lastSynced) return oldest;
if (!oldest || l.lastSynced < oldest) return l.lastSynced;
@@ -620,21 +626,22 @@ export function ExportTab({
layere
</span>
{(() => {
const freshCount = dbLayersSummary.filter(
// Check freshness only for primary layers (terenuri + cladiri)
const freshCount = primaryLayers.filter(
(l) => l.isFresh,
).length;
const staleCount = dbLayersSummary.length - freshCount;
const oldestSync = dbLayersSummary.reduce(
(oldest, l) => {
if (!l.lastSynced) return oldest;
if (!oldest || l.lastSynced < oldest) return l.lastSynced;
return oldest;
const staleCount = primaryLayers.length - freshCount;
const newestSync = primaryLayers.reduce(
(newest, l) => {
if (!l.lastSynced) return newest;
if (!newest || l.lastSynced > newest) return l.lastSynced;
return newest;
},
null as Date | null,
);
return (
<>
{staleCount === 0 ? (
{staleCount === 0 && primaryLayers.length > 0 ? (
<Badge
variant="outline"
className="text-emerald-600 border-emerald-200 dark:text-emerald-400 dark:border-emerald-800"
@@ -651,9 +658,9 @@ export function ExportTab({
{staleCount} vechi
</Badge>
)}
{oldestSync && (
{newestSync && (
<span className="text-xs text-muted-foreground">
Ultima sincronizare: {relativeTime(oldestSync)}
Ultima sincronizare: {relativeTime(newestSync)}
</span>
)}
</>