-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ferdig med å legge til inputfelter for søk * begynt på toggle button * begynt på grid * endret daterangepicker til datepicker og lagt til norsk * save before testing tablepaginator * edited table to mui table * fikset row, column issue * ferdig med gui * removed code smells * fjernet codesmell * fix merge conflicts * fjernet date-picker-pro --------- Co-authored-by: Marius Bølset Gisleberg <[email protected]>
- Loading branch information
Showing
10 changed files
with
968 additions
and
222 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
import React, { useState } from "react"; | ||
import Table from "@mui/material/Table"; | ||
import TableBody from "@mui/material/TableBody"; | ||
import TableCell from "@mui/material/TableCell"; | ||
import TableContainer from "@mui/material/TableContainer"; | ||
import TableHead from "@mui/material/TableHead"; | ||
import TableRow from "@mui/material/TableRow"; | ||
import Paper from "@mui/material/Paper"; | ||
import Pagination from "@mui/material/Pagination"; | ||
import styles from "./InternSearch.module.css"; | ||
import ToggleComponent from "./ToggleComponent"; | ||
|
||
const columns = [ | ||
{ id: "album", label: "Album" }, | ||
{ id: "motiv", label: "Motiv" }, | ||
{ id: "dato", label: "Dato" }, | ||
{ id: "type", label: "Type" }, | ||
{ id: "sted", label: "Sted" }, | ||
{ id: "oppslag", label: "Oppslag" }, | ||
{ id: "rettighet", label: "Rettighet" }, | ||
{ id: "scannet", label: "Scannet" }, | ||
{ id: "bilde", label: "Bilde" }, | ||
{ id: "endre", label: "Endre" }, | ||
]; | ||
|
||
const rows = [ | ||
{ | ||
id: 1, | ||
album: "album", | ||
motiv: "motiv", | ||
dato: "dato", | ||
type: "type", | ||
sted: "sted", | ||
oppslag: "oppslag", | ||
rettighet: "boss", | ||
scannet: "nei", | ||
bilde: "url", | ||
endre: "endre/slett", | ||
}, | ||
{ | ||
id: 2, | ||
album: "album", | ||
motiv: "motiv", | ||
dato: "dato", | ||
type: "type", | ||
sted: "sted", | ||
oppslag: "oppslag", | ||
rettighet: "boss", | ||
scannet: "nei", | ||
bilde: "url", | ||
endre: "endre/slett", | ||
}, | ||
{ | ||
id: 3, | ||
album: "album", | ||
motiv: "motiv", | ||
dato: "dato", | ||
type: "type", | ||
sted: "sted", | ||
oppslag: "oppslag", | ||
rettighet: "boss", | ||
scannet: "nei", | ||
bilde: "url", | ||
endre: "endre/slett", | ||
}, | ||
{ | ||
id: 4, | ||
album: "album", | ||
motiv: "motiv", | ||
dato: "dato", | ||
type: "type", | ||
sted: "sted", | ||
oppslag: "oppslag", | ||
rettighet: "boss", | ||
scannet: "nei", | ||
bilde: "url", | ||
endre: "endre/slett", | ||
}, | ||
{ | ||
id: 5, | ||
album: "album", | ||
motiv: "motiv", | ||
dato: "dato", | ||
type: "type", | ||
sted: "sted", | ||
oppslag: "oppslag", | ||
rettighet: "boss", | ||
scannet: "nei", | ||
bilde: "url", | ||
endre: "endre/slett", | ||
}, | ||
{ | ||
id: 6, | ||
album: "album", | ||
motiv: "motiv", | ||
dato: "dato", | ||
type: "type", | ||
sted: "sted", | ||
oppslag: "oppslag", | ||
rettighet: "boss", | ||
scannet: "nei", | ||
bilde: "url", | ||
endre: "endre/slett", | ||
}, | ||
// ... more rows | ||
]; | ||
|
||
const rowsPerPageOptions = [5, 10, 25]; | ||
|
||
const CustomTable = () => { | ||
const [page, setPage] = React.useState(1); | ||
const [rowsPerPage] = React.useState(rowsPerPageOptions[0]); | ||
|
||
const handleChangePage = (event: any, newPage: any) => { | ||
setPage(newPage); | ||
}; | ||
const [isGrid, setIsGrid] = useState(true); | ||
const handleChange = () => { | ||
setIsGrid(!isGrid); | ||
}; | ||
|
||
const emptyRows = Math.max(0, page * rowsPerPage - rows.length); | ||
|
||
return ( | ||
<Paper> | ||
<div className={styles.toggleHeader}> | ||
<div className={styles.pagination}> | ||
<Pagination | ||
count={Math.ceil(rows.length / rowsPerPage)} | ||
page={page} | ||
onChange={handleChangePage} | ||
color="primary" | ||
/> | ||
</div> | ||
<div className={styles.toggleComponent}> | ||
<ToggleComponent | ||
value={isGrid ? "Grid" : "List"} | ||
onChange={handleChange} | ||
/> | ||
</div> | ||
</div> | ||
<TableContainer> | ||
<Table> | ||
<TableHead> | ||
<TableRow> | ||
{columns.map((column) => ( | ||
<TableCell key={column.id}>{column.label}</TableCell> | ||
))} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{rows | ||
.slice((page - 1) * rowsPerPage, page * rowsPerPage) | ||
.map((row) => ( | ||
<TableRow key={row.id}> | ||
{columns.map((column) => ( | ||
<TableCell key={column.id}> | ||
{row[column.id as keyof typeof row]} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
))} | ||
{emptyRows > 0 && ( | ||
<TableRow style={{ height: 53 * emptyRows }}> | ||
<TableCell colSpan={columns.length} /> | ||
</TableRow> | ||
)} | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
<div className={styles.pagination2}> | ||
<Pagination | ||
count={Math.ceil(rows.length / rowsPerPage)} | ||
page={page} | ||
onChange={handleChangePage} | ||
color="primary" | ||
/> | ||
</div> | ||
</Paper> | ||
); | ||
}; | ||
|
||
export default CustomTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.internSearch { | ||
background-color: white; | ||
display: flex; | ||
border-radius: 2rem; | ||
padding: 2rem; | ||
} | ||
.formTextField { | ||
padding: 0.4rem; | ||
} | ||
|
||
.gridDivContainer { | ||
display: grid; | ||
width: 70%; | ||
height: 30%; | ||
order: 2; | ||
margin-right: auto; | ||
padding: 1rem; | ||
} | ||
|
||
.gridContainer { | ||
padding: 0.5rem; | ||
background-color: whitesmoke; | ||
border-radius: 1rem; | ||
} | ||
|
||
.gridBox { | ||
width: 100%; | ||
} | ||
|
||
.toggleHeader { | ||
width: 100%; | ||
border-radius: 1rem; | ||
display: flex; | ||
flex: 1; | ||
} | ||
|
||
.pagination { | ||
width: 100%; | ||
padding: 1rem; | ||
} | ||
|
||
.pagination2 { | ||
width: 100%; | ||
padding: 1rem; | ||
} | ||
|
||
.toggleComponent { | ||
width: 15%; | ||
padding: 1rem; | ||
} |
Oops, something went wrong.