Resolve merge conflict App.tsx

This commit is contained in:
keannu125 2023-03-02 20:37:06 +08:00
commit e508733c5f
24 changed files with 97 additions and 7 deletions

View file

@ -2,11 +2,11 @@ import React from "react";
import Dashboard from "./Routes/Dashboard/Dashboard";
import Error from "./Routes/Error/Error";
import Products from "./Routes/Products/Products";
import Logs from "./Routes/Logs/Logs";
import Container from "./Components/Container/Container";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import Store from "./Plugins/Redux/Store/Store";
import { Provider } from "react-redux";
import Inventory from "./Routes/Inventory/Inventory";
import AddProduct from "./Routes/Products/AddProduct/AddProduct";
import EditProduct from "./Routes/Products/EditProduct/EditProduct";
@ -33,10 +33,10 @@ const router = createBrowserRouter([
),
},
{
path: "/Inventory",
path: "/Logs",
element: (
<Container>
<Inventory />
<Logs />
</Container>
),
},

View file

@ -3,6 +3,7 @@ import { useSelector, useDispatch } from "react-redux";
import { toggle } from "../../Features/Login/LoginSlice";
import { Button } from "@mui/material";
import styles from "../../styles";
import { useNavigate } from "react-router-dom";
export interface state {
logged_in: {
@ -16,16 +17,17 @@ export interface props {
export default function Logout(props: props) {
const logged_in = useSelector((state: state) => state.logged_in.value);
const dispatch = useDispatch();
const navigate = useNavigate();
async function login() {
async function logout() {
await dispatch(toggle());
await console.log("test " + logged_in);
navigate("/");
}
return (
<div style={{ paddingTop: "40vh" }}>
<Button
onClick={login}
onClick={logout}
value="Log out"
variant="contained"
style={styles.logout_button}

78
src/Routes/Logs/Logs.tsx Normal file
View 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>
);
}

View file

@ -37,6 +37,16 @@ const styles: { [key: string]: React.CSSProperties } = {
color: "white",
fontWeight: "bold",
},
text_red: {
fontSize: "1.3vw",
color: "#a44141",
fontWeight: "bold",
},
text_green: {
fontSize: "1.3vw",
color: "#80b28a",
fontWeight: "bold",
},
logo_title: {
color: "#80b38b",
fontSize: 26,
@ -129,7 +139,7 @@ const styles: { [key: string]: React.CSSProperties } = {
flex_row: {
display: "flex",
flexDirection: "row",
alignItems: "stretch",
alignItems: "center",
},
flex_column: {
display: "flex",