mirror of
https://github.com/lemeow125/Ivy-Frontend.git
synced 2024-11-17 06:39:25 +08:00
Merge pull request #2 from lemeow125/feature/logspage
Merge Feature/logspage
This commit is contained in:
commit
3fd7e953a8
3 changed files with 98 additions and 1 deletions
|
@ -2,6 +2,7 @@ import React from "react";
|
||||||
import Dashboard from "./Routes/Dashboard/Dashboard";
|
import Dashboard from "./Routes/Dashboard/Dashboard";
|
||||||
import Error from "./Routes/Error/Error";
|
import Error from "./Routes/Error/Error";
|
||||||
import Products from "./Routes/Products/Products";
|
import Products from "./Routes/Products/Products";
|
||||||
|
import Logs from "./Routes/Logs/Logs";
|
||||||
import Container from "./Components/Container/Container";
|
import Container from "./Components/Container/Container";
|
||||||
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
||||||
import Store from "./Plugins/Redux/Store/Store";
|
import Store from "./Plugins/Redux/Store/Store";
|
||||||
|
@ -29,6 +30,14 @@ const router = createBrowserRouter([
|
||||||
</Container>
|
</Container>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/Logs",
|
||||||
|
element: (
|
||||||
|
<Container>
|
||||||
|
<Logs />
|
||||||
|
</Container>
|
||||||
|
),
|
||||||
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
|
|
78
src/Routes/Logs/Logs.tsx
Normal file
78
src/Routes/Logs/Logs.tsx
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
import * as React from "react";
|
||||||
|
import LogsIcon from "../../Components/Icons/LogsIcon/LogsIcon";
|
||||||
|
import styles from "../../styles";
|
||||||
|
import {
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableContainer,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
} from "@mui/material";
|
||||||
|
|
||||||
|
function createData(
|
||||||
|
id: number,
|
||||||
|
p_id: number,
|
||||||
|
p_name: string,
|
||||||
|
amount_changed: number,
|
||||||
|
timestamp: string
|
||||||
|
) {
|
||||||
|
return { id, p_id, p_name, amount_changed, timestamp };
|
||||||
|
}
|
||||||
|
|
||||||
|
const sample_data = [
|
||||||
|
createData(1, 1, "Zidanes Water", -5, "2/24/2023 10:05AM"),
|
||||||
|
createData(2, 1, "Zidanes Water", +10, "2/24/2023 1:05PM"),
|
||||||
|
createData(3, 2, "Dans Beefed Corn", +25, "2/25/2023 4:05PM"),
|
||||||
|
createData(4, 2, "Dans Beefed Corn", -15, "2/26/2023 3:35PM"),
|
||||||
|
];
|
||||||
|
|
||||||
|
export default function Logs() {
|
||||||
|
function change_color(amount: number) {
|
||||||
|
if (amount > 0) {
|
||||||
|
return <TableCell style={styles.text_green}>{amount}</TableCell>;
|
||||||
|
} else {
|
||||||
|
return <TableCell style={styles.text_red}>{amount}</TableCell>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div style={{ margin: 32, height: "100%" }}>
|
||||||
|
<div style={styles.flex_row}>
|
||||||
|
<LogsIcon size={8} color="white" />
|
||||||
|
<h1 style={styles.text_large}>Logs</h1>
|
||||||
|
</div>
|
||||||
|
<TableContainer
|
||||||
|
style={{
|
||||||
|
backgroundColor: "#1d3b33",
|
||||||
|
borderRadius: 8,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Table sx={{ minWidth: 650 }} aria-label="simple table">
|
||||||
|
<TableHead>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell style={styles.text}>Log ID</TableCell>
|
||||||
|
<TableCell style={styles.text}>Product ID</TableCell>
|
||||||
|
<TableCell style={styles.text}>Product</TableCell>
|
||||||
|
<TableCell style={styles.text}>Amount Change</TableCell>
|
||||||
|
<TableCell style={styles.text}>Timestamp</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableHead>
|
||||||
|
<TableBody>
|
||||||
|
{sample_data.map((row) => (
|
||||||
|
<TableRow
|
||||||
|
key={row.id}
|
||||||
|
sx={{ "&:last-child td, &:last-child th": { border: 0 } }}
|
||||||
|
>
|
||||||
|
<TableCell style={styles.text}>{row.id}</TableCell>
|
||||||
|
<TableCell style={styles.text}>{row.p_id}</TableCell>
|
||||||
|
<TableCell style={styles.text}>{row.p_name}</TableCell>
|
||||||
|
{change_color(row.amount_changed)}
|
||||||
|
<TableCell style={styles.text}>{row.timestamp}</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
|
@ -37,6 +37,16 @@ const styles: { [key: string]: React.CSSProperties } = {
|
||||||
color: "white",
|
color: "white",
|
||||||
fontWeight: "bold",
|
fontWeight: "bold",
|
||||||
},
|
},
|
||||||
|
text_red: {
|
||||||
|
fontSize: "1.3vw",
|
||||||
|
color: "#a44141",
|
||||||
|
fontWeight: "bold",
|
||||||
|
},
|
||||||
|
text_green: {
|
||||||
|
fontSize: "1.3vw",
|
||||||
|
color: "#80b28a",
|
||||||
|
fontWeight: "bold",
|
||||||
|
},
|
||||||
logo_title: {
|
logo_title: {
|
||||||
color: "#80b38b",
|
color: "#80b38b",
|
||||||
fontSize: 26,
|
fontSize: 26,
|
||||||
|
@ -129,7 +139,7 @@ const styles: { [key: string]: React.CSSProperties } = {
|
||||||
flex_row: {
|
flex_row: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
alignItems: "stretch",
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
flex_column: {
|
flex_column: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
|
Loading…
Reference in a new issue