From 928782d80d7fd36f0b937b6277cfe9b6efe7f020 Mon Sep 17 00:00:00 2001
From: Keannu Bernasol
Date: Fri, 5 Jan 2024 20:43:16 +0800
Subject: [PATCH] Optimized code for technician widget and changed widget to
pending equipments
---
.../Technician/TechnicianWidgets.tsx | 52 ++++++++-----------
1 file changed, 23 insertions(+), 29 deletions(-)
diff --git a/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx b/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx
index 23bcd80..188ea7d 100644
--- a/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx
+++ b/src/Components/DashboardPage/Technician/TechnicianWidgets.tsx
@@ -81,7 +81,7 @@ export default function TechnicianWidgets() {
...{ float: "left", position: "absolute" },
}}
>
- SKUs in Inventory
+ Pending Equipments
- {queries[0].data ? queries[0].data.length : 0}
+ {queries[1].data?.filter(
+ (equipment) => equipment.status == "Pending"
+ ).length || 0}
- {queries[1].data ? queries[1].data.length : 0}
+ {queries[1].data?.length || 0}
@@ -163,11 +165,9 @@ export default function TechnicianWidgets() {
...styles.text_L,
}}
>
- {queries[1].data
- ? queries[1].data.filter(
- (equipment) => equipment.status == "Available"
- ).length
- : 0}
+ {queries[1].data?.filter(
+ (equipment) => equipment.status == "Available"
+ ).length || 0}
- {queries[1].data
- ? queries[1].data.filter(
- (equipment) => equipment.status == "Broken"
- ).length
- : 0}
+ {queries[1].data?.filter(
+ (equipment) => equipment.status == "Broken"
+ ).length || 0}
@@ -244,14 +242,12 @@ export default function TechnicianWidgets() {
...styles.text_L,
}}
>
- {queries[3].data
- ? queries[3].data.filter((transaction) =>
- moment(transaction.timestamp, "MM-DD-YYYY hh:mm A").isBetween(
- todayStartOfDay,
- todayEndOfDay
- )
- ).length
- : 0}
+ {queries[3].data?.filter((transaction) =>
+ moment(transaction.timestamp, "MM-DD-YYYY hh:mm A").isBetween(
+ todayStartOfDay,
+ todayEndOfDay
+ )
+ ).length || 0}
- {queries[3].data
- ? queries[3].data.filter((transaction) =>
- moment(transaction.timestamp, "MM-DD-YYYY hh:mm A").isBetween(
- thisMonthStart,
- thisMonthEnd
- )
- ).length
- : 0}
+ {queries[3].data?.filter((transaction) =>
+ moment(transaction.timestamp, "MM-DD-YYYY hh:mm A").isBetween(
+ thisMonthStart,
+ thisMonthEnd
+ )
+ ).length || 0}