ok
This commit is contained in:
@@ -402,14 +402,22 @@ export const getReports = async (cafeId, filter) => {
|
||||
);
|
||||
return response.json();
|
||||
};
|
||||
export const getAnalytics = async (filter) => {
|
||||
const response = await fetch(
|
||||
API_BASE_URL + "/transaction/get-analytics" + "?type=" + filter,
|
||||
getHeaders('POST')
|
||||
);
|
||||
|
||||
export const getAnalytics = async (filter, selectedCafeId) => {
|
||||
// Start the URL with the filter type query
|
||||
let url = API_BASE_URL + "/transaction/get-analytics" + "?type=" + filter;
|
||||
|
||||
// Only add selectedCafeId to the query string if it's not null
|
||||
if (selectedCafeId !== null) {
|
||||
url += "&cafeId=" + selectedCafeId;
|
||||
}
|
||||
|
||||
// Fetch with the updated URL
|
||||
const response = await fetch(url, getHeaders('POST'));
|
||||
return response.json();
|
||||
};
|
||||
|
||||
|
||||
export const getIncome = async (cafeId) => {
|
||||
const response = await fetch(
|
||||
`${API_BASE_URL}/transaction/get-income/${cafeId}`,
|
||||
|
||||
@@ -266,9 +266,10 @@
|
||||
border: 1px solid #ccc;
|
||||
margin-top: 5px;
|
||||
margin-bottom: 15px;
|
||||
text-transform: lowercase;
|
||||
text-transform: none; /* Remove lowercase transformation */
|
||||
}
|
||||
|
||||
|
||||
.usernameInputError {
|
||||
width: 250px;
|
||||
height: 55px;
|
||||
|
||||
@@ -127,9 +127,12 @@ const App = ({ forCafe = true, cafeId = -1,
|
||||
try {
|
||||
setLoading(true);
|
||||
// Fetch the analytics data with the selected filter
|
||||
const analyticsData = (selectedCafeId !== '' && selectedCafeId !== 0)
|
||||
let analyticsData = null;
|
||||
if(user.roleId == 1)
|
||||
analyticsData = (selectedCafeId !== '' && selectedCafeId !== 0)
|
||||
? await getReports(selectedCafeId, filter)
|
||||
: await getAnalytics(filter);
|
||||
else analyticsData = await getAnalytics(filter, selectedCafeId);
|
||||
|
||||
console.log(analyticsData);
|
||||
if (analyticsData) setAnalytics(analyticsData);
|
||||
@@ -657,6 +660,44 @@ const App = ({ forCafe = true, cafeId = -1,
|
||||
}
|
||||
</div>
|
||||
}
|
||||
{!forCafe && selectedCafeId == -1 && user.roleId == 1 &&
|
||||
<div style={{
|
||||
textAlign: "center",
|
||||
}}>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexWrap: "wrap",
|
||||
justifyContent: "center",
|
||||
padding: "20px",
|
||||
}}
|
||||
>
|
||||
|
||||
<RoundedRectangle
|
||||
title={"Masukkan nama bisnis"}
|
||||
width="calc(100% - 10px)"
|
||||
>
|
||||
<input
|
||||
value={itemName}
|
||||
onChange={(e) => setItemName(e.target.value)}
|
||||
style={{
|
||||
width: '70%',
|
||||
fontSize: '25px',
|
||||
borderRadius: '7px',
|
||||
border: '1px solid black'
|
||||
}}
|
||||
/>
|
||||
</RoundedRectangle>
|
||||
|
||||
|
||||
<RoundedRectangle
|
||||
title={"Buat Bisnis"}
|
||||
width="calc(100% - 10px)"
|
||||
onClick={handleClick}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
{user?.roleId == 1 &&
|
||||
<>
|
||||
<div className={`${styles.couponContainer}`}>
|
||||
|
||||
Reference in New Issue
Block a user