diff --git a/src/Components/InventoryPage/StockRenderer/StockRenderer.tsx b/src/Components/InventoryPage/StockRenderer/StockRenderer.tsx index af64fa6..0bd983b 100644 --- a/src/Components/InventoryPage/StockRenderer/StockRenderer.tsx +++ b/src/Components/InventoryPage/StockRenderer/StockRenderer.tsx @@ -30,9 +30,7 @@ export default function StockRenderer(product: Product) { quantity: stock, }); if (stock > product.quantity) { - dispatch( - this_session_increment_added(Math.abs(stock - product.quantity)) - ); + dispatch(this_session_increment_added(stock - product.quantity)); } else { dispatch( this_session_increment_removed(Math.abs(stock - product.quantity)) diff --git a/src/Components/LogsPage/RowRenderer/RowRenderer.tsx b/src/Components/LogsPage/RowRenderer/RowRenderer.tsx deleted file mode 100644 index 16196fd..0000000 --- a/src/Components/LogsPage/RowRenderer/RowRenderer.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import * as React from "react"; -import { - OldSessionState, - ProductLogEntry, -} from "../../../Interfaces/Interfaces"; -import styles from "../../../styles"; -import { TableBody, TableRow, TableCell } from "@mui/material"; -import { GetProduct, QueryUser } from "../../Api/Api"; -import { useState } from "react"; -import { useSelector } from "react-redux"; -import { useQuery } from "react-query"; - -export default function RowRenderer(props: ProductLogEntry) { - const old_session_checked = useSelector( - (state: OldSessionState) => state.old_session_checked.value - ); - const { - data: user, - isLoading, - error, - } = useQuery({ - queryKey: ["user_select_id_" + props.Product.id, props.Product.id], - queryFn: () => QueryUser(props.Product.id), - }); - if (isLoading || !old_session_checked) { - - - {props.Product.history_id} - - - {props.Product.id} - - - {props.Product.name} - - - {props.Product.quantity} - - - Loading... - - - {props.Product.history_date} - - ; - } else if (error) { - - - {props.Product.history_id} - - - {props.Product.id} - - - {props.Product.name} - - - {props.Product.quantity} - - - Loading... - - - {props.Product.history_date} - - ; - } - return ( - - - {props.Product.history_id} - - - {props.Product.id} - - - {props.Product.name} - - - {props.Product.quantity} - - - {isLoading || user.username} - - - {props.Product.history_date} - - - ); -} diff --git a/src/Features/Redux/Slices/TransactionsThisSessionSlice/TransactionsThisSessionSlice.tsx b/src/Features/Redux/Slices/TransactionsThisSessionSlice/TransactionsThisSessionSlice.tsx index df6f458..eb600cf 100644 --- a/src/Features/Redux/Slices/TransactionsThisSessionSlice/TransactionsThisSessionSlice.tsx +++ b/src/Features/Redux/Slices/TransactionsThisSessionSlice/TransactionsThisSessionSlice.tsx @@ -8,10 +8,10 @@ export const TransactionsThisSessionSlice = createSlice({ }, reducers: { this_session_increment_added: (state, action) => { - state.added = action.payload; + state.added += action.payload; }, this_session_increment_removed: (state, action) => { - state.removed = action.payload; + state.removed += action.payload; }, }, }); diff --git a/src/Interfaces/Interfaces.tsx b/src/Interfaces/Interfaces.tsx index 70025c2..d544f44 100644 --- a/src/Interfaces/Interfaces.tsx +++ b/src/Interfaces/Interfaces.tsx @@ -21,6 +21,7 @@ export interface ProductLogEntry { quantity: string; history_date: string; history_user_id: number; + changed_by: string; }; } @@ -31,6 +32,7 @@ export interface ProductLog { quantity: string; history_date: string; history_user_id: number; + changed_by: string; } // Redux Interfaces diff --git a/src/Routes/Logs/Logs.tsx b/src/Routes/Logs/Logs.tsx index 90a86ac..59803e6 100644 --- a/src/Routes/Logs/Logs.tsx +++ b/src/Routes/Logs/Logs.tsx @@ -15,7 +15,6 @@ import { useQuery } from "react-query"; import { GetLogs, UserInfo } from "../../Components/Api/Api"; import { OldSessionState, ProductLog } from "../../Interfaces/Interfaces"; import { useState } from "react"; -import RowRenderer from "../../Components/LogsPage/RowRenderer/RowRenderer"; import { useSelector } from "react-redux"; export default function Logs() { @@ -92,7 +91,29 @@ export default function Logs() { {logs.data.map((row: ProductLog, index: number) => ( - + + + {row.history_id} + + + {row.id} + + + {row.name} + + + {row.quantity} + + + {row.changed_by} + + + {row.history_date} + + ))}