diff --git a/src/pages/Join.module.css b/src/pages/Join.module.css
index 6ca4c93..4f8dca6 100644
--- a/src/pages/Join.module.css
+++ b/src/pages/Join.module.css
@@ -68,7 +68,7 @@
font-weight: 400;
line-height: 1.5rem;
font-size: 14px;
- font-family: 'poppins';
+ font-family: "Plus Jakarta Sans", sans-serif;
color: black;
margin-bottom: 1.5rem;
}
@@ -77,7 +77,7 @@
font-weight: 400;
line-height: 1.5rem;
font-size: 14px;
- font-family: 'poppins';
+ font-family: "Plus Jakarta Sans", sans-serif;
color: transparent;
margin-bottom: -2.5rem;
}
diff --git a/src/pages/LinktreePage.module.css b/src/pages/LinktreePage.module.css
index bcbc000..77db6eb 100644
--- a/src/pages/LinktreePage.module.css
+++ b/src/pages/LinktreePage.module.css
@@ -150,7 +150,7 @@
font-weight: 400;
line-height: 1.5rem;
font-size: 14px;
- font-family: 'poppins';
+ font-family: "Plus Jakarta Sans", sans-serif;
color: black;
margin-bottom: 1.5rem;
}
diff --git a/src/pages/Login.module.css b/src/pages/Login.module.css
index 4f84aa3..d223193 100644
--- a/src/pages/Login.module.css
+++ b/src/pages/Login.module.css
@@ -77,7 +77,7 @@
font-weight: 400;
line-height: 1.5rem;
font-size: 14px;
- font-family: 'poppins';
+ font-family: "Plus Jakarta Sans", sans-serif;
color: black;
margin-bottom: 1.5rem;
}
diff --git a/src/pages/Reports.js b/src/pages/Reports.js
index e1dd2fd..68233bd 100644
--- a/src/pages/Reports.js
+++ b/src/pages/Reports.js
@@ -1,6 +1,7 @@
import React, { useEffect, useState } from "react";
import {
getReports,
+ getAnalytics
} from "../helpers/transactionHelpers.js";
import CircularDiagram from "./CircularDiagram";
import styles from "./Transactions.module.css";
@@ -20,13 +21,14 @@ const RoundedRectangle = ({
loading = false,
children, // Assuming this is a React component or JSX
isChildren,
+ width='calc(100% / 2 - 10px)'
}) => {
const containerStyle = {
display: "flex",
flexDirection: "column",
alignItems: "flex-start",
justifyContent: "center",
- width: !children && !isChildren && "calc(100% / 2 - 10px)",
+ width: !children && !isChildren && width,
height: "auto",
borderRadius: "15px",
padding: "20px",
@@ -102,17 +104,22 @@ const RoundedRectangle = ({
);
};
-const App = ({ cafeId,
+const App = ({ forCafe = true, cafeId="",
handleClose, otherCafes }) => {
+ const [selectedCafeId, setSelectedCafeId] = useState(cafeId);
const [analytics, setAnalytics] = useState({});
const [loading, setLoading] = useState(true);
const [filter, setFilter] = useState("yesterday");
const fetchData = async (filter) => {
+ if(selectedCafeId == '-1') return;
try {
setLoading(true);
// Fetch the analytics data with the selected filter
- const analyticsData = await getReports(cafeId, filter);
+ const analyticsData = (selectedCafeId !== '' && selectedCafeId !== 0)
+ ? await getReports(selectedCafeId, filter)
+ : await getAnalytics(filter);
+
console.log(analyticsData);
if (analyticsData) setAnalytics(analyticsData);
} catch (error) {
@@ -122,9 +129,13 @@ const App = ({ cafeId,
}
};
+ useEffect(() => {
+ setSelectedCafeId(cafeId)
+ }, [cafeId]);
+
useEffect(() => {
fetchData(filter); // Fetch data when filter changes
- }, [filter]);
+ }, [filter, selectedCafeId]);
const filteredItems = analytics.itemSales || [];
@@ -193,6 +204,7 @@ const App = ({ cafeId,
const [texts, setTexts] = useState(['buat kedai']); // initially show only first 3 texts
const [fullTexts, setFullTexts] = useState(null); // initially show only first 3 texts
const [fullTextsVisible, setFullTextsVisible] = useState(null); // initially show only first 3 texts
+
useEffect(() => {
if (otherCafes != null) {
let updatedFullTexts;
@@ -204,6 +216,8 @@ const App = ({ cafeId,
[otherCafes[0].name, otherCafes[0].cafeId],
["buat kedai", -1]
];
+
+ setSelectedCafeId(otherCafes[0].cafeId); // Get the cafeId (second part of the pair)
} else {
updatedFullTexts = [
["semua", 0], // First entry is "semua"
@@ -231,15 +245,15 @@ const App = ({ cafeId,
const [selectedSwitch, setSelectedSwitch] = useState(0);
const onItemToggle = (index) => {
- let selectedCafeId = null;
// When user clicks the last visible option (index === 2 in the current view)
if (index === 2) {
console.log(fullTexts);
- if (fullTexts.indexOf(texts[2]) < fullTexts.length - 1) {
+ if (fullTexts.findIndex(item => item[0] === texts[2]) < fullTexts.length - 1) {
setTexts((prevTexts) => {
const newTexts = [...prevTexts];
- const nextText = fullTexts[prevTexts.length]; // Get the next item in the full list
+ console.log(prevTexts.length)
+ const nextText = fullTexts[fullTexts.findIndex(item => item[0] === texts[2])+1][0]; // Get the next item in the full list
newTexts.shift(); // Remove the first element
newTexts.push(nextText); // Add the next item to the end
setSelectedSwitch(1); // Change the selected index
@@ -256,7 +270,7 @@ const App = ({ cafeId,
const newTexts = [...prevTexts];
const prevText = fullTexts[fullTexts.findIndex(item => item[0] === newTexts[0]) - 1]; // Get the previous item
newTexts.pop(); // Remove the last element
- newTexts.unshift(prevText); // Add the previous item to the start
+ newTexts.unshift(prevText[0]); // Add the previous item to the start
setSelectedSwitch(1); // Change the selected index
return newTexts;
});
@@ -270,11 +284,9 @@ const App = ({ cafeId,
const selectedText = texts[index]; // Get the selected name from the texts array
const selectedItem = fullTexts.find(item => item[0] === selectedText); // Find the corresponding full item
if (selectedItem) {
- selectedCafeId = selectedItem[1]; // Get the cafeId (second part of the pair)
+ setSelectedCafeId(selectedItem[1]); // Get the cafeId (second part of the pair)
}
- console.log('Selected cafeId:', selectedCafeId); // Log the selected cafeId
-
setResetKey((prevKey) => prevKey + 1); // Increase the key to force re-render
};
@@ -285,19 +297,22 @@ const App = ({ cafeId,
return (
-
-
Laporan
+
+ {forCafe &&
}
+
Laporan
- {otherCafes &&
)}
+ {!forCafe && selectedCafeId != -1 && selectedCafeId != 0 && (
+
window.location.href = window.location.origin + '/' + otherCafes.find(item => item.cafeId === selectedCafeId).cafeIdentifyName}
+ />
+ )}
ⓘ
-
+
Persentase pertumbuhan dihitung dengan membandingkan {" "}
{comparisonText} hari terakhir dengan {comparisonText} hari sebelumnya.
@@ -428,12 +451,11 @@ const App = ({ cafeId,
{filter == 'yesterday' || filter == 'weekly' ?
-
+
:
}
-
);
};
diff --git a/src/pages/WelcomePage.css b/src/pages/WelcomePage.css
index 3f04067..4dc61a3 100644
--- a/src/pages/WelcomePage.css
+++ b/src/pages/WelcomePage.css
@@ -30,7 +30,7 @@
.welcoming-text {
font-size: 24px;
margin-bottom: 20px;
- font-family: poppins;
+ font-family: "Plus Jakarta Sans", sans-serif;
}
.get-started-button {
@@ -42,7 +42,7 @@
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
- font-family: poppins;
+ font-family: "Plus Jakarta Sans", sans-serif;
}
.get-started-button:hover {