diff --git a/frontend/cypress/e2e/pages/overview.cy.ts b/frontend/cypress/e2e/pages/overview.cy.ts index de0cf03..058f0fc 100644 --- a/frontend/cypress/e2e/pages/overview.cy.ts +++ b/frontend/cypress/e2e/pages/overview.cy.ts @@ -204,4 +204,27 @@ describe("DataTable component displays data correctly", () => { cy.get("table tbody tr").as("rows").should("have.length", 6); }); + + it("navigates to new page when clicked on row", () => { + // Find the index for the case number column + cy.get("table thead th").then(($headers) => { + const caseNumberIndex = + [...$headers].findIndex((header) => + header.innerText.includes("Saksnummer"), + ) + 1; + // Get the case number of the first row + cy.get(`table tbody tr td:nth-child(${caseNumberIndex})`) + .first() + .invoke("text") + .then((caseNumber) => { + // Click on the first + cy.get("table tbody tr").first().click(); + // Check that the URL has changed to the correct case number + cy.url().should( + "include", + `/mottakskontroll/dine-saker/dashbord/${caseNumber}`, + ); + }); + }); + }); }); diff --git a/frontend/src/app/mottakskontroll/dine-saker/DataTable.tsx b/frontend/src/app/mottakskontroll/dine-saker/DataTable.tsx index 88bd47d..2fdf3ef 100644 --- a/frontend/src/app/mottakskontroll/dine-saker/DataTable.tsx +++ b/frontend/src/app/mottakskontroll/dine-saker/DataTable.tsx @@ -23,6 +23,7 @@ import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react"; import { useEffect, useState } from "react"; import { type Application } from "~/types/application"; import FilterDropdown from "../../_components/FilterDropdown"; +import { useRouter } from "next/navigation"; interface DataTableProps { columns: ColumnDef[]; @@ -33,6 +34,8 @@ const DataTable = ({ columns, data, }: DataTableProps) => { + const router = useRouter(); + const [sorting, setSorting] = useState([]); const [filteredData, setFilteredData] = useState(data); const [selectedMunicipalities, setSelectedMunicipalities] = useState< @@ -155,7 +158,11 @@ const DataTable = ({ console.log(row.original)} + onClick={() => + router.push( + `/mottakskontroll/dine-saker/dashbord/${row.original.id}`, + ) + } > {row.getVisibleCells().map((cell) => ( diff --git a/frontend/src/app/mottakskontroll/dine-saker/dashbord/[caseNumber]/page.tsx b/frontend/src/app/mottakskontroll/dine-saker/dashbord/[caseNumber]/page.tsx new file mode 100644 index 0000000..0876da3 --- /dev/null +++ b/frontend/src/app/mottakskontroll/dine-saker/dashbord/[caseNumber]/page.tsx @@ -0,0 +1,16 @@ +"use client"; + +import { useParams } from "next/navigation"; +import React from "react"; + +const CaseDashboard: React.FC = () => { + const { caseNumber } = useParams(); + + return ( +
+

Dashbord for saksnummer: {caseNumber}

+
+ ); +}; + +export default CaseDashboard;