-
Sede
+
Sede
{locations.length >= 2 ? (
isMobile ? (
LocationCombobox(props)
diff --git a/src/routes/viewer/PhaseSelect/GroupSelect/index.tsx b/src/routes/viewer/PhaseSelect/GroupSelect/index.tsx
index 1918331f..df12e6ae 100644
--- a/src/routes/viewer/PhaseSelect/GroupSelect/index.tsx
+++ b/src/routes/viewer/PhaseSelect/GroupSelect/index.tsx
@@ -11,7 +11,7 @@ export default function GroupSelect(props: GroupSelectProps) {
const { groups, isCombobox, selectedGroup, groupOpen, onChange } = props;
return (
-
Fase
+
Fase
{groups.size >= 2 ? (
isCombobox ? (
- Lingua
+ Lingua
{canChoose ? (
- Graduatoria
+ Graduatoria
{phases.length >= 2 ? (
isCombobox ? (
({
>
- {option.icon && (
-
- )}
+ {option.icon &&
}
{option.label}
{facet && (
diff --git a/src/routes/viewer/Table/Toolbar.tsx b/src/routes/viewer/Table/Toolbar.tsx
index 7ff49ca5..367d223a 100644
--- a/src/routes/viewer/Table/Toolbar.tsx
+++ b/src/routes/viewer/Table/Toolbar.tsx
@@ -6,6 +6,10 @@ import { FilterBtn } from "./FilterBtn";
import { enrollStatusOpts, enrollAllowedOpts } from "./columns";
import { StudentResultKeys } from ".";
import StudentResult from "@/utils/types/data/parsed/Ranking/StudentResult";
+import { sha256 } from "@/utils/strings/crypto";
+import { useState } from "react";
+import { LuXCircle } from "react-icons/lu";
+import { Removable } from "@/components/custom-ui/Removable";
type Props = {
has: Record;
@@ -16,20 +20,89 @@ type Props = {
export function Toolbar({ has, onCsvClick, table }: Props) {
const enrollStatusCol = table.getColumn("enrollStatus");
const enrollAllowedCol = table.getColumn("enrollAllowed");
+ const [matricolaFilter, setMatricolaFilter] = useState("");
+ const [matricolaFilterSubmitted, setMatricolaFilterSubmitted] =
+ useState(false);
+ const { rows: filteredRows } = table.getFilteredRowModel();
+
+ function clearMatricolaTableFilter() {
+ table.getColumn("id")?.setFilterValue(undefined);
+ }
+
+ function handleClearMatricolaFilter() {
+ setMatricolaFilter("");
+ clearMatricolaTableFilter();
+ setMatricolaFilterSubmitted(false);
+ }
+
+ function handleMatricolaFilterChange(
+ event: React.ChangeEvent,
+ ) {
+ if (matricolaFilterSubmitted) clearMatricolaTableFilter();
+ const input = event.target.value;
+ setMatricolaFilter(input);
+ setMatricolaFilterSubmitted(false);
+ }
+
+ async function handleMatricolaFilterSubmit(
+ e: React.FormEvent,
+ ) {
+ e.preventDefault();
+
+ if (matricolaFilter.length === 0) handleClearMatricolaFilter();
+ else {
+ const hash = await sha256(matricolaFilter);
+ table.getColumn("id")?.setFilterValue(hash);
+ setMatricolaFilterSubmitted(true);
+ }
+ }
return (
-
+
{table.getColumn("id") && (
-
- table.getColumn("id")?.setFilterValue(event.target.value)
- }
- />
+
+
Matricola
+ {filteredRows.length > 0 && matricolaFilterSubmitted ? (
+
+ {matricolaFilter}
+
+ ) : (
+ <>
+
+ {matricolaFilterSubmitted && (
+
+ Matricola non trovata, ricontrolla.
+
+ )}
+ >
+ )}
+
)}
-
+
{has.enrollAllowed && enrollAllowedCol && (
)}
-
+
);