diff --git a/package-lock.json b/package-lock.json index da7e347..960a3b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2836,6 +2836,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-4.1.0.tgz", "integrity": "sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==", + "license": "MIT", "funding": { "type": "github", "url": "https://github.com/sponsors/kossnocorp" diff --git a/src/api/api.js b/src/api/api.js index d89aafb..12b1baa 100644 --- a/src/api/api.js +++ b/src/api/api.js @@ -11,6 +11,7 @@ import axios from 'axios'; import * as XLSX from 'xlsx'; import ads from '../data/ads.js'; import sha256 from 'crypto-js/sha256'; +import { format } from 'date-fns'; //import { GET } from 'superagent'; const baseApiUrl = import.meta.env.VITE_API_BASE_URL; const API_FLAG = import.meta.env.VITE_API_FLAG; @@ -497,6 +498,7 @@ export const apiUpdateStoreAsync = async (store) => { categoryId: store.categoryId, description: store.description, isActive: store.isActive, + tax: store.tax }); } }; @@ -510,11 +512,23 @@ export const apiGetAllStoresAsync = async () => { } else { apiSetAuthHeader(); const stores = await axios.get(`${baseApiUrl}/api/Admin/stores`); - console.log(stores); return stores.data; } }; +export const apiGetMonthlyStoreRevenueAsync = async (id) => { + apiSetAuthHeader(); + const now = new Date(); + const firstDayOfMonth = new Date(now.getFullYear(), now.getMonth(), 1); // ✅ define it here + const lastDayOfMonth = new Date(now.getFullYear(), now.getMonth() + 1, 0); // ✅ and here + const from = format(firstDayOfMonth, 'yyyy-MM-dd'); + const to = format(lastDayOfMonth, 'yyyy-MM-dd'); + + const rev = await axios.get(`${baseApiUrl}/api/Admin/store/${id}/income?from=${from}&to=${to}`); + console.log(rev); + return rev.data; + +}; // DELETE product category export const apiDeleteProductCategoryAsync = async (categoryId) => { if (API_ENV_DEV === API_FLAG) { @@ -1675,6 +1689,5 @@ export const apiFetchDeliveryAddressByIdAsync = async (addressId) => { const res = await axios.get( `${baseApiUrl}/api/user-profile/address/${addressId}` ); - console.log('RESPONSE Adrese: ', res); return res.data; // Vraća objekat adrese }; 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', + }, + }} + />