diff --git a/src/app/(modules)/rgi-test/page.tsx b/src/app/(modules)/rgi-test/page.tsx index 92a012b..a5cb90c 100644 --- a/src/app/(modules)/rgi-test/page.tsx +++ b/src/app/(modules)/rgi-test/page.tsx @@ -210,9 +210,11 @@ const ALL_COLUMNS: ColumnDef[] = [ function IssuedDocsPanel({ applicationPk, workspaceId, + dueDate, }: { applicationPk: number; workspaceId: number; + dueDate: number; }) { const [docs, setDocs] = useState(null); const [loading, setLoading] = useState(true); @@ -258,12 +260,22 @@ function IssuedDocsPanel({ ); } + const isLocked = dueDate > Date.now(); + return (
-

- {docs.length} document{docs.length > 1 ? "e" : ""} eliberat - {docs.length > 1 ? "e" : ""}: -

+
+

+ {docs.length} document{docs.length > 1 ? "e" : ""} eliberat + {docs.length > 1 ? "e" : ""} +

+ {isLocked && ( + + + Disponibile de la {fmtTs(dueDate)} + + )} +
{docs.map((doc, i) => (
- {/* Server-side download (works when fileVisibility returns OK) */} - + {isLocked ? ( + + + {fmtTs(dueDate)} + + ) : ( + + )}
))} @@ -330,7 +343,7 @@ export default function RgiTestPage() { const [error, setError] = useState(""); const [applications, setApplications] = useState([]); const [totalCount, setTotalCount] = useState(0); - const [filterSolved, setFilterSolved] = useState(true); + // filterSolved removed — replaced by filterMode const [expandedPk, setExpandedPk] = useState(null); const [showColumnPicker, setShowColumnPicker] = useState(false); @@ -390,14 +403,19 @@ export default function RgiTestPage() { setLoading(false); }, [workspaceId, orgUnitId, year]); + const [filterMode, setFilterMode] = useState<"all" | "ready" | "pending">("ready"); + // Client-side filter const filtered = useMemo(() => { - if (!filterSolved) return applications; + if (filterMode === "all") return applications; const now = Date.now(); - return applications.filter( - (a) => a.hasSolution === 1 && a.dueDate > now, - ); - }, [applications, filterSolved]); + return applications.filter((a) => { + if (a.hasSolution !== 1) return false; + if (filterMode === "ready") return a.dueDate <= now; // termen trecut = descarcabil + if (filterMode === "pending") return a.dueDate > now; // termen viitor = blocat + return true; + }); + }, [applications, filterMode]); return (
@@ -477,16 +495,28 @@ export default function RgiTestPage() { )} {/* Filter toggle */} -
- +
+
+ {([ + { id: "ready" as const, label: "Descarcabile acum", desc: "solutionate + termen trecut" }, + { id: "pending" as const, label: "In asteptare", desc: "solutionate + termen viitor (blocate)" }, + { id: "all" as const, label: "Toate", desc: "" }, + ]).map((opt) => ( + + ))} +
{applications.length > 0 && ( {filtered.length} din {applications.length} lucrari @@ -542,6 +572,7 @@ export default function RgiTestPage() { const pk = app.applicationPk; const isExpanded = expandedPk === pk; const solved = app.hasSolution === 1; + const downloadable = solved && app.dueDate <= Date.now(); return ( @@ -554,9 +585,11 @@ export default function RgiTestPage() { setExpandedPk(isExpanded ? null : pk) } > - - {solved ? ( - + + {downloadable ? ( + + ) : solved ? ( + ) : ( )} @@ -610,6 +643,7 @@ export default function RgiTestPage() { @@ -629,12 +663,10 @@ export default function RgiTestPage() { -

Nicio lucrare {filterSolved ? "solutionata cu termen viitor" : ""} gasita.

- {filterSolved && ( -

- Debifati filtrul pentru a vedea toate lucrarile. -

- )} +

Nicio lucrare gasita pentru filtrul selectat.

+

+ Schimba filtrul pentru a vedea alte lucrari. +

)}