Skip to content

Commit

Permalink
forgot (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Sicat authored Dec 15, 2023
2 parents b43891d + d38696b commit b5c0848
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions frontend/app/components/data_grid.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import * as React from "react";
import Box from "@mui/material/Box";
import { DataGrid, GridColDef, GridValueGetterParams } from "@mui/x-data-grid";
import {useEffect, useState} from "react";
import { DataGrid, GridColDef } from "@mui/x-data-grid";
import { useEffect, useState } from "react";

interface Reservation {
id: number;
userID: number;
username: string;
startTime: string;
endTime: string;
ReservationID: number;
Seat: string;
StartTime: string;
EndTime: string;
Username: string;
}

const columns: GridColDef[] = [
{ field: "id", headerName: "ID", width: 90 },
{ field: "userID", headerName: "User ID", width: 120 },
{ field: "username", headerName: "Username", width: 150 },
{ field: "startTime", headerName: "Start Time", width: 200 },
{ field: "endTime", headerName: "End Time", width: 200 },
{ field: "ReservationID", headerName: "ID", width: 120 },
{ field: "Seat", headerName: "Seat", width: 110 },
{ field: "Username", headerName: "Username", width: 150 },
{ field: "StartTime", headerName: "Start Time", width: 200 },
{ field: "EndTime", headerName: "End Time", width: 200 },
];


export default function DataGridDemo() {

const [rows, setRows] = useState<Reservation[]>([]);

useEffect(() => {
fetch("http://localhost:5000/api/get-reservations")
.then((response) => response.json())
Expand All @@ -34,19 +33,16 @@ export default function DataGridDemo() {
});
}, []);

// Specify the getRowId function
const getRowId = (row: Reservation) => row.ReservationID.toString();

return (
<Box sx={{ height: 400, width: "100%", backgroundColor: "#FFFAF6" }}>
<DataGrid
rows={rows}
columns={columns}
initialState={{
pagination: {
paginationModel: {
pageSize: 5,
},
},
}}
getRowId={getRowId}
pageSize={5}
pageSizeOptions={[5]}
checkboxSelection
disableRowSelectionOnClick
Expand Down

0 comments on commit b5c0848

Please sign in to comment.