From e039fc8acced46ec0b3105bb68644eb7e1bbb99f Mon Sep 17 00:00:00 2001 From: Vassshhh Date: Wed, 27 Aug 2025 02:53:30 +0700 Subject: [PATCH] ok --- src/components/Header.js | 2 +- src/pages/Reports.js | 129 ++++++++------------------------------- 2 files changed, 28 insertions(+), 103 deletions(-) diff --git a/src/components/Header.js b/src/components/Header.js index 141419f..f514d1f 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -108,7 +108,7 @@ const ProfileImage = styled.img` width: 60px; height: 60px; border-radius: 50%; - object-fit: contain; + object-fit: cover; cursor: pointer; z-index: 199; animation: ${(props) => { diff --git a/src/pages/Reports.js b/src/pages/Reports.js index 712f819..11cf692 100644 --- a/src/pages/Reports.js +++ b/src/pages/Reports.js @@ -13,10 +13,6 @@ import MultiSwitch from "react-multi-switch-toggle"; import DailyCharts from '../components/DailyCharts.js'; import PeriodCharts from '../components/PeriodCharts.js'; -import Coupon from "../components/Coupon.js"; - -import CreateCouponPage from "./CreateCoupon.js"; - const RoundedRectangle = ({ onClick, title, @@ -312,7 +308,7 @@ const App = ({ forCafe = true, cafeId = -1, filterTexts[["yesterday", "weekly", "monthly", "yearly"].indexOf(filter)]; const [resetKey, setResetKey] = useState(0); // A key to force re-render - const [texts, setTexts] = useState(['Buat bisnis']); // initially show only first 3 texts + const [texts, setTexts] = useState([]); // 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 @@ -322,27 +318,27 @@ const App = ({ forCafe = true, cafeId = -1, let updatedFullTexts; if (otherCafes.length === 0) { // Only include the role-specific option if user.roleId is 1 - updatedFullTexts = user.roleId == 1 ? [["Buat Bisnis", 0]] : []; + updatedFullTexts = user.roleId == 1 ? [[0]] : []; setSelectedCafeId(-1); } else if (otherCafes.length === 1) { updatedFullTexts = [ [otherCafes[0].cafeIdentifyName || otherCafes[0].username, otherCafes[0].cafeId || otherCafes[0].user_id], - // Only add the "Buat Bisnis" option for user.roleId == 1 - ...(user.roleId == 1 ? [["Buat Bisnis", -1]] : []) + + ...(user.roleId == 1 ? [[-1]] : []) ]; - + setSelectedCafeId(otherCafes[0].cafeId); // Get the cafeId (second part of the pair) } else { updatedFullTexts = [ ["semua", 0], // First entry is "semua" ...otherCafes.map(item => [item.cafeIdentifyName || item.username, item.cafeId || item.user_id]), // Map over cafes to get name and cafeId pairs - // Only add "Buat Bisnis +" option for user.roleId == 1 - ...(user.roleId == 1 ? [["Buat Bisnis +", -1]] : []) + + ...(user.roleId == 1 ? [] : []) ]; - + setSelectedCafeId(0); } - + setFullTexts(updatedFullTexts); // Set fullTexts with the original structure // Set fullTextsVisible to an array of names only @@ -408,24 +404,24 @@ const App = ({ forCafe = true, cafeId = -1, setSelectedCafeId(selectedItem[1]); // Get the cafeId (second part of the pair) } let nextSelectedId = selectedItem[1] - + console.log(analytics) if (user && user.roleId === 0 && analytics) { // Filter the analytics items based on user_id - if(selectedItem[1] != 0 && selectedItem[1] != -1){ - const filteredData = analytics.items.filter( - (data) => data.user_id === nextSelectedId - ); - - // Extract coupons from the filtered data - const couponsToAdd = filteredData.flatMap((data) => data.coupons); - - // Log the coupons to be added - console.log(couponsToAdd); - // Assuming setCouponList is a function that updates the coupon list - setCouponList(couponsToAdd || []); - } - else setCouponList([]) + if (selectedItem[1] != 0 && selectedItem[1] != -1) { + const filteredData = analytics.items.filter( + (data) => data.user_id === nextSelectedId + ); + + // Extract coupons from the filtered data + const couponsToAdd = filteredData.flatMap((data) => data.coupons); + + // Log the coupons to be added + console.log(couponsToAdd); + // Assuming setCouponList is a function that updates the coupon list + setCouponList(couponsToAdd || []); + } + else setCouponList([]) } setResetKey((prevKey) => prevKey + 1); // Increase the key to force re-render @@ -455,8 +451,8 @@ const App = ({ forCafe = true, cafeId = -1, } else { setModal('loading'); const create = await createCafe(itemName); - setModal("message", { - captMessage: create ? 'Berhasil membuat cafe' : 'Gagal membuat cafe' + setModal("message", { + captMessage: create ? 'Berhasil membuat cafe' : 'Gagal membuat cafe' }); // Add a 2-second delay before proceeding @@ -602,7 +598,7 @@ const App = ({ forCafe = true, cafeId = -1, {!forCafe && selectedCafeId != -1 && selectedCafeId != 0 && ( window.location.href = window.location.origin + '/' + otherCafes.find(item => item.cafeId === selectedCafeId).cafeIdentifyName} marginBottom={'0px'} @@ -720,77 +716,6 @@ const App = ({ forCafe = true, cafeId = -1, } } - {!forCafe && selectedCafeId == -1 && user.roleId == 1 && -
-
- - - setItemName(e.target.value)} - style={{ - width: '70%', - fontSize: '25px', - borderRadius: '7px', - border: '1px solid black' - }} - /> - - - - -
-
- } - {!forCafe && - <> -
-
- {!forCafe && -
-
-
-
- Voucher -
-
-
- } -
-
-
- {/*

{couponList.length}

*/} - {couponList && couponList.map((coupon) => { - return - })} - -
- - } ); };