From cc6dfe5ced23371e36ea77b707fa71cd7c9cf9a7 Mon Sep 17 00:00:00 2001 From: mbjelobrk1 <148221673+mbjelobrk1@users.noreply.github.com> Date: Sat, 24 May 2025 16:50:01 +0200 Subject: [PATCH 1/3] Tax/revenue prikaz --- src/api/api.js | 11 +++++++++++ src/components/StoreCard.jsx | 38 +++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/api/api.js b/src/api/api.js index d89aafb..5149cee 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -515,6 +515,17 @@ export const apiGetAllStoresAsync = async () => { } }; +export const apiGetMonthlyStoreRevenueAsync = async (id) => { + apiSetAuthHeader(); + const formData = { + id: id, + from: firstDayOfMonth.toISOString(), // Convert to ISO string and remove the time part + to: lastDayOfMonth.toISOString() // Convert to ISO string and remove the time part + } + const rev = await axios.get(`${baseApiUrl}/api/Admin/store/${id}/income`); + return rev; + +}; // DELETE product category export const apiDeleteProductCategoryAsync = async (categoryId) => { if (API_ENV_DEV === API_FLAG) { diff --git a/src/components/StoreCard.jsx b/src/components/StoreCard.jsx index 87061fe..0c1effe 100644 --- a/src/components/StoreCard.jsx +++ b/src/components/StoreCard.jsx @@ -19,6 +19,7 @@ import { apiExportProductsToCSVAsync, apiExportProductsToExcelAsync, apiCreateProductAsync, + apiGetMonthlyStoreRevenueAsync } from '@api/api'; import AddProductModal from '@components/NewProductModal'; import LocationOnIcon from '@mui/icons-material/LocationOn'; @@ -38,12 +39,14 @@ const StoreCard = ({ store }) => { const [updating, setUpdating] = useState(false); const fileInputRef = useRef(); const [parsedProducts, setParsedProducts] = useState([]); - + const [revenue, setRevenue] = useState(0); const openStatus = Boolean(anchorEl); const openMenu = Boolean(menuAnchor); useEffect(() => { apiGetStoreCategoriesAsync().then(setCategories); + const rez = apiGetMonthlyStoreRevenueAsync(store.id); + setRevenue(rez); }, []); const handleStatusClick = (e) => setAnchorEl(e.currentTarget); @@ -257,6 +260,39 @@ const StoreCard = ({ store }) => { > {store.description} + + + Tax: {store.tax} + + + + Total monthly income: {revenue.totalIncome} + + + + Taxed monthly income: {revenue.taxedIncome} + {/* Buttons */} From 1bb5843b19fc66fdcef543c410ab42ef4dc06a03 Mon Sep 17 00:00:00 2001 From: PC Date: Sat, 24 May 2025 18:53:11 +0200 Subject: [PATCH 2/3] EditStoreModal-dodavanje editabilnog polja --- src/components/EditStoreModal.jsx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/components/EditStoreModal.jsx b/src/components/EditStoreModal.jsx index a8f5e94..18415d2 100644 --- a/src/components/EditStoreModal.jsx +++ b/src/components/EditStoreModal.jsx @@ -19,6 +19,7 @@ const StoreEditModal = ({ open, onClose, store, onStoreUpdated }) => { const [categoryId, setCategoryId] = useState(''); const [description, setDescription] = useState(''); const [address, setAddress] = useState(''); + const [tax, setTax] = useState(''); const [categories, setCategories] = useState([]); const [loading, setLoading] = useState(false); @@ -34,6 +35,7 @@ const StoreEditModal = ({ open, onClose, store, onStoreUpdated }) => { setCategoryId(store.categoryId || ''); setDescription(store.description || ''); setAddress(store.address || ''); + setTax(store.tax?.toString() || ''); } }, [store]); @@ -47,6 +49,7 @@ const StoreEditModal = ({ open, onClose, store, onStoreUpdated }) => { address, categoryId, description, + tax: parseFloat(tax), isActive: store.isOnline ?? true, }; @@ -142,7 +145,23 @@ const StoreEditModal = ({ open, onClose, store, onStoreUpdated }) => { margin='normal' required /> - + setTax(e.target.value)} + margin='normal' + required + inputProps={{ + min: 0, + step: 0.01, + style: { + backgroundColor: 'white', + color: 'black', + }, + }} + />