From 112837b20eab01283b70223c2f7e75154907793d Mon Sep 17 00:00:00 2001 From: frontend perkafean <165241731+frontendperkafean@users.noreply.github.com> Date: Sun, 8 Sep 2024 06:48:45 +0000 Subject: [PATCH] ok --- src/pages/Reports.js | 109 +++++++++++++++++++++++++++++++------------ 1 file changed, 80 insertions(+), 29 deletions(-) diff --git a/src/pages/Reports.js b/src/pages/Reports.js index facfc5c..14439cf 100644 --- a/src/pages/Reports.js +++ b/src/pages/Reports.js @@ -19,14 +19,15 @@ const RoundedRectangle = ({ percentage, fontSize = "15px", loading = false, + children, // Assuming this is a React component or JSX + isChildren, }) => { const containerStyle = { display: "flex", flexDirection: "column", alignItems: "flex-start", justifyContent: "center", - width: "calc(100% / 2 - 10px)", - maxWidth: "250px", + width: !children && !isChildren && "calc(100% / 2 - 10px)", height: "auto", borderRadius: "15px", padding: "20px", @@ -41,7 +42,9 @@ const RoundedRectangle = ({ fontWeight: "bold", marginBottom: "10px", width: "100%", - backgroundColor: loading ? "rgb(85 85 85)" : "inherit", + backgroundColor: loading + ? "rgb(85 85 85)" + : !isChildren && !children && "inherit", color: loading ? "transparent" : "inherit", }; @@ -61,8 +64,8 @@ const RoundedRectangle = ({ color: loading ? "transparent" : "inherit", backgroundColor: loading ? "rgb(85 85 85)" : "transparent", overflow: "hidden", - textOverflow: "ellipsis", // Add ellipsis for overflow text - whiteSpace: "nowrap", // Prevent text from wrapping + textOverflow: "ellipsis", + whiteSpace: "nowrap", }; const percentageStyle = { @@ -80,22 +83,21 @@ const RoundedRectangle = ({ return (
{title}
-
-
{loading ? "Loading..." : value}
-
- {loading ? "" : percentage} - {percentage != undefined && !loading && "%"} - {percentage != undefined && !loading && ( - - {percentage > 0 ? "↗" : percentage === 0 ? "-" : "↘"} - - )} + {!children && ( +
+
{loading ? "Loading..." : value}
+
+ {loading ? "" : percentage} + {percentage != undefined && !loading && "%"} + {percentage != undefined && !loading && ( + + {percentage > 0 ? "↗" : percentage === 0 ? "-" : "↘"} + + )} +
-
+ )} + {children &&
{children}
} {/* Properly render children */}
); }; @@ -188,6 +190,15 @@ const App = ({ cafeId }) => { const filterTexts = ["1 day", "7 days", "30 days", "365 days"]; const comparisonText = filterTexts[["daily", "weekly", "monthly", "yearly"].indexOf(filter)]; + const formatDate = (isoDateString) => { + const date = new Date(isoDateString); + return date.toLocaleDateString("en-US", { + year: "numeric", + month: "long", + day: "numeric", + hour: "numeric", + }); + }; return (
@@ -290,18 +301,58 @@ const App = ({ cafeId }) => {
{filteredItems.map((item, index) => ( - -
-
-
- {item.name} -
-
+
+
+ ★ +
+
{item.name}
+
))}
+ +

Stock changes

+ + {analytics.materialMutations?.length > 0 && + analytics?.materialMutations.map((item, index) => ( + +
+ {item.mutations.map((mutation, mutationIndex) => ( + + ))} +
+
+ ))} );