diff --git a/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx b/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx index b3631cf..d784c8f 100644 --- a/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx +++ b/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx @@ -7,8 +7,13 @@ import { TransactionsAPI, } from "../../API/API"; import CircularProgress from "@mui/material/CircularProgress"; +import moment from "moment"; export default function TechnicianWidgets() { + const todayStartOfDay = moment().startOf("day").format("MM-DD-YYYY hh:mm A"); + const todayEndOfDay = moment().endOf("day").format("MM-DD-YYYY hh:mm A"); + const thisMonthStart = moment().startOf("month").format("MM-DD-YYYY hh:mm A"); + const thisMonthEnd = moment().endOf("month").format("MM-DD-YYYY hh:mm A"); const queries = useQueries({ queries: [ { @@ -230,7 +235,7 @@ export default function TechnicianWidgets() { ...{ float: "left", position: "absolute" }, }} > - Transactions Today + Total Transactions Today
{queries[3].data - ? queries[3].data.filter( - (transactions) => transactions.timestamp == "Available" + ? queries[3].data.filter((transaction) => + moment(transaction.timestamp, "MM-DD-YYYY hh:mm A").isBetween( + todayStartOfDay, + todayEndOfDay + ) ).length : 0}
@@ -265,7 +273,7 @@ export default function TechnicianWidgets() { ...{ float: "left", position: "absolute" }, }} > - Broken Equipments + Total Transactions this Month- {queries[1].data - ? queries[1].data.filter( - (equipment) => equipment.status == "Broken" + {queries[3].data + ? queries[3].data.filter((transaction) => + moment(transaction.timestamp, "MM-DD-YYYY hh:mm A").isBetween( + thisMonthStart, + thisMonthEnd + ) ).length : 0}