diff --git a/src/routes/viewer/Table/index.tsx b/src/routes/viewer/Table/index.tsx index 92ea932..20c412b 100644 --- a/src/routes/viewer/Table/index.tsx +++ b/src/routes/viewer/Table/index.tsx @@ -38,6 +38,21 @@ interface TableProps extends React.HTMLAttributes { } function makeHas(rows: StudentResult[]): Record { + if (rows.length === 0) + return { + englishCorrectAnswers: true, + sectionsResults: true, + positionAbsolute: true, + positionCourse: true, + birthDate: true, + result: true, + ofa: true, + enrollStatus: true, + enrollAllowed: true, + enrollCourse: true, + id: true, + }; + function checkKey(key: StudentResultKeys): boolean { const isThereAny = rows.some((r) => r[key]); if (!isThereAny) return false; @@ -74,11 +89,10 @@ type ColumnVisibility = { }; export default function Table({ table: _table, csvFilename }: TableProps) { - const { rows } = _table; - const has = makeHas(rows); + const has = makeHas(_table.rows); const [columnVisibility, setColumnVisibility] = useState(has); - const columns = getColumns(rows); + const columns = getColumns(_table.rows); const [pagination, setPagination] = useState({ pageSize: 15, pageIndex: 0, @@ -86,7 +100,7 @@ export default function Table({ table: _table, csvFilename }: TableProps) { const [columnFilters, setColumnFilters] = useState([]); const table = useReactTable({ - data: rows, + data: _table.rows, columns, state: { columnVisibility, @@ -169,12 +183,12 @@ export default function Table({ table: _table, csvFilename }: TableProps) { ) : ( - {rows.length > 0 - ? "Nessuna riga trovata" - : "Nessun dato disponibile"} + {_table.rows.length > 0 + ? "La ricerca ha restituito nessun risultato" + : "La tabella di questo corso non contiene righe"} )} diff --git a/src/routes/viewer/index.tsx b/src/routes/viewer/index.tsx index 4a8ed2b..64fbba7 100644 --- a/src/routes/viewer/index.tsx +++ b/src/routes/viewer/index.tsx @@ -160,7 +160,6 @@ export const viewerRoute = new Route({ [selectedCourse, selectedLocation, store], ); - console.log({ ranking, selectedPhaseLink }); return (