From 5a2b9b2f860d75978748d87d305d6eda3efac4f5 Mon Sep 17 00:00:00 2001 From: zadit <75159257+insvrgent@users.noreply.github.com> Date: Wed, 30 Oct 2024 03:32:48 +0700 Subject: [PATCH] ok banget --- src/App.js | 3 +- src/components/Item.js | 4 +- src/components/Item.module.css | 6 +- src/components/ItemLister.js | 108 ++++++++++++++++++--- src/components/ItemTypeLister.js | 2 +- src/components/Modal.js | 6 +- src/config.js | 2 +- src/helpers/materialMutationHelpers.js | 1 + src/helpers/transactionHelpers.js | 4 +- src/pages/GuidePage.js | 4 +- src/pages/MaterialList.js | 63 +++++++++--- src/pages/MaterialMutationsPage.js | 4 +- src/pages/Reports.js | 127 ++++++++++--------------- src/pages/Transactions.js | 10 +- src/pages/WelcomePage.css | 4 + src/pages/WelcomePage.js | 20 +++- src/pages/WelcomePageEditor.css | 2 +- src/pages/WelcomePageEditor.js | 4 +- 18 files changed, 244 insertions(+), 130 deletions(-) diff --git a/src/App.js b/src/App.js index 90f51b5..57a460f 100644 --- a/src/App.js +++ b/src/App.js @@ -96,7 +96,6 @@ function App() { if (response.status === 200) { setShop(cafe); setShopItems(data); - // Filter out unavailable items const filteredData = data .map((itemType) => ({ @@ -220,7 +219,7 @@ function App() { localStorage.getItem("settings") ) setModal("complete_account"); - if (data.data.user.cafeId == shopId) { + if (data.data.user.cafeId == shopId || data.data.isTheOwner) { const connectedGuestSides = await getConnectedGuestSides(); setGuestSides(connectedGuestSides.sessionDatas); console.log("getting guest side"); diff --git a/src/components/Item.js b/src/components/Item.js index 874de52..5769a80 100644 --- a/src/components/Item.js +++ b/src/components/Item.js @@ -8,6 +8,7 @@ const Item = ({ price: initialPrice, qty: initialQty, imageUrl, + imageFile, id, onPlusClick, onNegativeClick, @@ -17,7 +18,7 @@ const Item = ({ isAvailable, isBeingEdit, }) => { - const [selectedImage, setSelectedImage] = useState(null); + const [selectedImage, setSelectedImage] = useState(imageFile); const [previewUrl, setPreviewUrl] = useState(imageUrl); const [itemQty, setItemQty] = useState(blank ? 0 : initialQty); const [itemName, setItemName] = useState(initialName); @@ -219,6 +220,7 @@ const Item = ({ style={{ backgroundColor: "white", width: "150px", + color: '#73a585' }} onClick={isBeingEdit ? handleUpdate : handleCreate} > diff --git a/src/components/Item.module.css b/src/components/Item.module.css index 0634860..e005257 100644 --- a/src/components/Item.module.css +++ b/src/components/Item.module.css @@ -143,12 +143,15 @@ .itemQty { display: flex; - align-items: center; + align-items: end; font-size: 0.9rem; margin-left: 5px; + color: rgb(115, 165, 133); + fill: rgb(115, 165, 133); } .itemQtyValue { + margin-bottom: 8px; font-family: "Poppins", sans-serif; font-style: normal; font-weight: 600; @@ -174,7 +177,6 @@ background-color: #ffffff; border: 2px solid #73a585; /* border: none; */ - color: #73a585; display: inline-block; font-size: 16px; font-weight: 600; diff --git a/src/components/ItemLister.js b/src/components/ItemLister.js index 18daa01..005a575 100644 --- a/src/components/ItemLister.js +++ b/src/components/ItemLister.js @@ -188,6 +188,7 @@ const ItemLister = ({ : item ) ); + setisEditItem(0); }; const onUpdateItem = (itemId, name, price, image) => { if (isEdit) @@ -350,17 +351,41 @@ const ItemLister = ({ isEdit ? styles.border : styles.noborder }`} value={editedTypeName} + placeholder="type name" onChange={(e) => setEditedTypeName(e.target.value)} disabled={!isEdit} /> {isEditMode && !isEdit && ( - <> - + <>
+ + + + + + + + +
+ )} @@ -562,11 +587,37 @@ const ItemLister = ({ /> )}

- {item.availability ? "available" : "unavailable"} +  {item.availability ? "available" : "unavailable"}  

- +
editItem(item.itemId)} + > + + + + + + + + +
)} @@ -578,6 +629,7 @@ const ItemLister = ({ price={item.price} qty={item.qty} imageUrl={item.image} + imageFile={item.selectedImage} onPlusClick={() => handlePlusClick(item.itemId)} onNegativeClick={() => handleNegativeClick(item.itemId)} onRemoveClick={() => handleRemoveClick(item.itemId)} @@ -614,11 +666,37 @@ const ItemLister = ({ /> )}

- {item.availability ? "available" : "unavailable"} +  {item.availability ? "available" : "unavailable"} 

- +
editItem(item.itemId)} + > + + + + + + + + +
)} diff --git a/src/components/ItemTypeLister.js b/src/components/ItemTypeLister.js index 0544267..e48b727 100644 --- a/src/components/ItemTypeLister.js +++ b/src/components/ItemTypeLister.js @@ -114,7 +114,7 @@ const ItemTypeLister = ({ shopId={shopId} shopOwnerId={shopOwnerId} user={user} - typeName={"add new"} + typeName={""} itemList={items} isEditMode={true} handleCreateItem={(itemTypeId, name, price, selectedImage) => createItem(shopId, name, price, selectedImage,itemTypeId)} diff --git a/src/components/Modal.js b/src/components/Modal.js index bcc9236..08dfd79 100644 --- a/src/components/Modal.js +++ b/src/components/Modal.js @@ -62,13 +62,13 @@ const Modal = ({ shop, isOpen, onClose, modalContent, setModal }) => { )} {modalContent === "add_material" && ( - + )} {modalContent === "update_stock" && ( - + )} {modalContent === "welcome_config" && } - {modalContent === "reports" && } + {modalContent === "reports" && } ); diff --git a/src/config.js b/src/config.js index 967c5ce..6cf67cc 100644 --- a/src/config.js +++ b/src/config.js @@ -1,5 +1,5 @@ // src/config.js -const API_BASE_URL = 'https://api.kedaimaster.com'; +const API_BASE_URL = 'https://dev.api.kedaimaster.com'; export default API_BASE_URL; diff --git a/src/helpers/materialMutationHelpers.js b/src/helpers/materialMutationHelpers.js index 9cf799d..f9a1744 100644 --- a/src/helpers/materialMutationHelpers.js +++ b/src/helpers/materialMutationHelpers.js @@ -26,6 +26,7 @@ export const createMaterialMutation = async (materialId, data) => { body: JSON.stringify({ newStock: data.get("newStock"), reason: data.get("reason"), + priceAtp: data.get("priceAtp"), }), } ); diff --git a/src/helpers/transactionHelpers.js b/src/helpers/transactionHelpers.js index c31f34f..b23b1bb 100644 --- a/src/helpers/transactionHelpers.js +++ b/src/helpers/transactionHelpers.js @@ -173,11 +173,11 @@ export async function getMyTransactions(shopId, demand) { console.error("Error:", error); } } -export async function getTransactions(shopId, demand) { +export async function getTransactionsFromCafe(shopId, demand) { try { const token = getLocalStorage("auth"); const response = await fetch( - `${API_BASE_URL}/transaction/get-transactions/${shopId}?demandLength=${demand}`, + `${API_BASE_URL}/transaction/get-transactions-from-cafe/${shopId}?demandLength=${demand}`, { method: "GET", headers: { diff --git a/src/pages/GuidePage.js b/src/pages/GuidePage.js index 6b3ca9d..1376b79 100644 --- a/src/pages/GuidePage.js +++ b/src/pages/GuidePage.js @@ -1,6 +1,6 @@ import React from 'react'; import './GuidePage.css'; - +import API_BASE_URL from '../config.js'; const GuidePage = ({ guideType }) => { const renderGuideContent = () => { switch (guideType) { @@ -10,7 +10,7 @@ const GuidePage = ({ guideType }) => {

Setup Guide

1. Turn on edit mode and create item type