diff --git a/firm/src/App.js b/firm/src/App.js
index a162782..2857841 100644
--- a/firm/src/App.js
+++ b/firm/src/App.js
@@ -6,6 +6,8 @@ import ZarzadzanieProduktami from './components/ZarzadzanieProduktami';
import Transakcje from './components/Transakcje';
import NavBar from './components/NavBar'
import Sidebar from './components/Sidebar';
+import Wydatki from './components/Wydatki';
+import Raporty from './components/Raporty';
const App = () => {
return (
@@ -21,6 +23,8 @@ const App = () => {
} />
} />
} />
+ } />
+ } />
diff --git a/firm/src/components/Raporty.js b/firm/src/components/Raporty.js
new file mode 100644
index 0000000..d8eea7b
--- /dev/null
+++ b/firm/src/components/Raporty.js
@@ -0,0 +1,101 @@
+import React, { useState, useEffect } from 'react';
+import axios from 'axios';
+import koszIcon from "../icons/kosz.png";
+
+const Raporty = () => {
+ const [fromDate, setFromDate] = useState('');
+ const [toDate, setToDate] = useState('');
+ const [reports, setReports] = useState([]);
+
+ const fetchReports = async () => {
+ try {
+ const response = await axios.get('https://localhost:7039/api/Report');
+ setReports(response.data);
+ } catch (error) {
+ console.error('Błąd podczas pobierania raportów:', error);
+ }
+ };
+
+ useEffect(() => {
+ fetchReports();
+ }, []);
+
+ const handleGenerateReport = async () => {
+ try {
+ const response = await axios.post('https://localhost:7039/api/Report', {
+ fromDate,
+ toDate
+ });
+ const newReport = response.data;
+ setReports([...reports, newReport]);
+ } catch (error) {
+ console.error('Błąd podczas generowania raportu:', error);
+ }
+ };
+
+ const handleDeleteReport = async (reportId) => {
+ try {
+ await axios.delete(`https://localhost:7039/api/Report/${reportId}`);
+ fetchReports();
+ } catch (error) {
+ console.error('Błąd podczas usuwania raportu:', error);
+ }
+ };
+
+ const formatDate = (dateString) => {
+ const options = { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' };
+ const date = new Date(dateString);
+ return date.toLocaleDateString('pl-PL', options).replace(",", "");
+ };
+
+ return (
+
+
+
+ Generowanie raportów
+
+
+
+
+ setFromDate(e.target.value)} className="mr-5" />
+
+ setToDate(e.target.value)} className="mr-5" />
+
+
+
+
Raporty
+
+
+
+ ID |
+ Data od |
+ Data do |
+ Suma dochodów |
+ Suma wydatków |
+ Bilans |
+ |
+
+
+
+ {reports.map(report => (
+
+ {report.id} |
+ {formatDate(report.fromDate)} |
+ {formatDate(report.toDate)} |
+ {report.totalIncome} |
+ {report.totalExpenses} |
+ {report.totalBalance} |
+
+
+ |
+
+ ))}
+
+
+
+
+ );
+};
+
+export default Raporty;
diff --git a/firm/src/components/Sidebar.js b/firm/src/components/Sidebar.js
index 643682e..2d9f4f3 100644
--- a/firm/src/components/Sidebar.js
+++ b/firm/src/components/Sidebar.js
@@ -4,6 +4,8 @@ import adminIcon from "../icons/panel.png";
import produktIcon from "../icons/produkty.png";
import transakcjeIcon from "../icons/transkacje.png";
import harmonogramIcon from "../icons/harmonogram.png";
+import wydatkiIcon from "../icons/wydatki.png";
+import raportyIcon from "../icons/raport.png";
const Sidebar = () => {
return (
@@ -29,6 +31,16 @@ const Sidebar = () => {
Harmonogram
+
+
+
+ Wydatki
+
+
+
+
+ Raporty
+
);
diff --git a/firm/src/components/Transakcje.js b/firm/src/components/Transakcje.js
index ea8a15a..348b61f 100644
--- a/firm/src/components/Transakcje.js
+++ b/firm/src/components/Transakcje.js
@@ -7,14 +7,16 @@ import plusIcon from "../icons/plus.png";
const Transakcje = () => {
const [transactions, setTransactions] = useState([]);
const [isModalOpen, setIsModalOpen] = useState(false);
+ const [isEditModalOpen, setIsEditModalOpen] = useState(false);
+ const [editTransaction, setEditTransaction] = useState(null);
const [newTransaction, setNewTransaction] = useState({
- id: 1,
+ id: 2,
date: "",
employeeId: "",
transactionProducts: [
{
id: 0,
- transactionId: 0,
+ transactionId: 2,
productID: "",
quantity:""
}
@@ -40,17 +42,19 @@ const Transakcje = () => {
const handleAddTransaction = async () => {
try {
+ console.log('Nowa transakcja:', newTransaction);
await axios.post('https://localhost:7039/api/Transaction', newTransaction);
+
fetchTransactions();
setIsModalOpen(false);
setNewTransaction({
- id: 1,
+ id: 2,
date: "",
employeeId: "",
transactionProducts: [
{
id: 0,
- transactionId: 0,
+ transactionId: 2,
productID: "",
quantity: ""
}
@@ -65,6 +69,60 @@ const Transakcje = () => {
}
};
+
+ const formatDate = (dateString) => {
+ const options = { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' };
+ const date = new Date(dateString);
+ return date.toLocaleDateString('pl-PL', options).replace(",", "");
+ };
+
+ const handleAddProduct = () => {
+ setNewTransaction({
+ ...newTransaction,
+ transactionProducts: [
+ ...newTransaction.transactionProducts,
+ {
+ id: 0,
+ transactionId: 2,
+ productID: "",
+ quantity: ""
+ }
+ ]
+ });
+ };
+
+ const handleRemoveProduct = (index) => {
+ const updatedTransactionProducts = [...newTransaction.transactionProducts];
+ updatedTransactionProducts.splice(index, 1);
+ setNewTransaction({
+ ...newTransaction,
+ transactionProducts: updatedTransactionProducts
+ });
+ };
+
+ const handleDeleteTransaction = async (transactionId) => {
+ try {
+ await axios.delete(`https://localhost:7039/api/Transaction/${transactionId}`);
+ fetchTransactions();
+ } catch (error) {
+ console.error('Błąd podczas usuwania transakcji:', error);
+ }
+ };
+ const handleEditTransaction = (transaction) => {
+ setEditTransaction(transaction);
+ setIsEditModalOpen(true);
+ };
+ const handleSaveEditedTransaction = async () => {
+ try {
+ await axios.put(`https://localhost:7039/api/Transaction/${editTransaction.id}`, editTransaction);
+ fetchTransactions();
+ setIsEditModalOpen(false);
+ } catch (error) {
+ console.error('Błąd podczas edycji transakcji:', error);
+ }
+ };
+
+
return (
@@ -75,6 +133,97 @@ const Transakcje = () => {
Dodaj
+ {isEditModalOpen && editTransaction && (
+
+ )}
+
+
{isModalOpen && (
+ ))}
+
+
setNewTransaction({ ...newTransaction, paymentType: e.target.value })}
+ placeholder="Sposób płatności"
+ className="block w-full mb-4 px-4 py-2 border border-gray-300 rounded-lg"
+ />
+
setNewTransaction({ ...newTransaction, discount: e.target.value })}
+ placeholder="Rabat"
+ className="block w-full mb-4 px-4 py-2 border border-gray-300 rounded-lg"
+ />
+
setNewTransaction({ ...newTransaction, description: e.target.value })}
+ placeholder="Opis"
+ className="block w-full mb-4 px-4 py-2 border border-gray-300 rounded-lg"
+ />
+
+
+
+
+ )}
+
+
+
+
+
+ ID |
+ Data |
+ Produkt |
+ Ilość |
+ Kwota |
+ Sposób płatności |
+ Nr. Pracownika |
+ |
+ |
+
+
+
+ {transactions.map(transaction => (
+
+ {transaction.id} |
+ {formatDate(transaction.date)} |
+
+ {transaction.transactionProducts.map(product => (
+ {product.product.name}
+ ))}
+ |
+
+ {transaction.transactionProducts.map(product => (
+ {product.quantity}
+ ))}
+ |
+ {transaction.totalPrice} |
+ {transaction.paymentType} |
+ {transaction.employeeId} |
+ |
+ |
+
+ ))}
+
+
+
+
- )}
-
-
-
-
-
- ID |
- Data |
- Produkt |
- Ilość |
- Sposób płatności |
- Nr. Pracownika |
-
-
-
- {transactions.map(transaction => (
-
- {transaction.id} |
- {transaction.date} |
-
- {transaction.transactionProducts.map(product => (
- {product.product.name}
- ))}
- |
-
- {transaction.transactionProducts.map(product => (
- {product.quantity}
- ))}
- |
- {transaction.paymentType} |
- {transaction.employeeId} |
-
- ))}
-
-
-
-
-
-
-
-
- );
-}
-
-export default Transakcje;
+ );
+ }
+
+ export default Transakcje
+
+
+
+
+
+
diff --git a/firm/src/components/Wydatki.js b/firm/src/components/Wydatki.js
new file mode 100644
index 0000000..5b03e61
--- /dev/null
+++ b/firm/src/components/Wydatki.js
@@ -0,0 +1,146 @@
+import React, { useState, useEffect } from 'react';
+import axios from 'axios';
+import koszIcon from "../icons/kosz.png";
+import plusIcon from "../icons/plus.png";
+
+const Wydatki = () => {
+ const [expenses, setExpenses] = useState([]);
+ const [showModal, setShowModal] = useState(false);
+ const [newExpense, setNewExpense] = useState({
+ date: '',
+ value: '',
+ description: ''
+ });
+
+ const fetchExpenses = async () => {
+ try {
+ const response = await axios.get('https://localhost:7039/api/Expenses');
+ setExpenses(response.data);
+ } catch (error) {
+ console.error('Błąd podczas pobierania wydatków:', error);
+ }
+ };
+
+ useEffect(() => {
+ fetchExpenses();
+ }, []);
+
+ const handleAddExpense = async () => {
+ try {
+ const response = await axios.post('https://localhost:7039/api/Expenses', newExpense);
+ const addedExpense = response.data;
+ setExpenses([...expenses, addedExpense]);
+ setNewExpense({
+ date: '',
+ value: '',
+ description: ''
+ });
+ setShowModal(false);
+ } catch (error) {
+ console.error('Błąd podczas dodawania wydatku:', error);
+ }
+ };
+
+ const handleDeleteExpense = async (expenseId) => {
+ try {
+ await axios.delete(`https://localhost:7039/api/Expenses/${expenseId}`);
+ fetchExpenses();
+ } catch (error) {
+ console.error('Błąd podczas usuwania wydatku:', error);
+ }
+ };
+
+ const formatDate = (dateString) => {
+ const options = { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' };
+ const date = new Date(dateString);
+ return date.toLocaleDateString('pl-PL', options).replace(",", "");
+ };
+
+ return (
+
+
+
+ Zarządzanie wydatkami
+
+
+
+
+
+
Wydatki
+
+
+
+
+
+ ID |
+ Data |
+ Wartość |
+ Opis |
+ |
+
+
+
+ {expenses.map(expense => (
+
+ {expense.id} |
+ {formatDate(expense.date)} |
+ {expense.value} |
+ {expense.description} |
+
+
+ |
+
+ ))}
+
+
+
+ {showModal && (
+
+
+
+
+
+
Dodaj nowy wydatek
+
+
+
+
+
+ setNewExpense({ ...newExpense, date: e.target.value })} className="mt-1 border py-1 px-3 block w-full shadow-sm sm:text-sm rounded-md" />
+
+
+
+
+ setNewExpense({ ...newExpense, value: e.target.value })} className="mt-1 border py-1 px-3 block w-full shadow-sm sm:text-sm rounded-md" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )}
+
+ );
+};
+
+export default Wydatki;
+
diff --git a/firm/src/components/ZarzadzanieProduktami.js b/firm/src/components/ZarzadzanieProduktami.js
index 7beaa68..9c783ce 100644
--- a/firm/src/components/ZarzadzanieProduktami.js
+++ b/firm/src/components/ZarzadzanieProduktami.js
@@ -7,6 +7,7 @@ import plusIcon from "../icons/plus.png";
const ZarzadzanieProduktami = () => {
const [products, setProducts] = useState([]);
const [isModalOpen, setIsModalOpen] = useState(false);
+ const [isEditModalOpen, setIsEditModalOpen] = useState(false);
const [newProduct, setNewProduct] = useState({
name: "",
description: "",
@@ -14,6 +15,7 @@ const ZarzadzanieProduktami = () => {
type: "",
availability: ""
});
+ const [editProduct, setEditProduct] = useState(null);
const fetchProducts = async () => {
try {
@@ -37,7 +39,7 @@ const ZarzadzanieProduktami = () => {
try {
const config = {
headers: {
- 'Content-Type': 'text/json'
+ 'Content-Type': 'application/json'
}
};
await axios.post('https://localhost:7039/api/Products', newProduct, config);
@@ -47,67 +49,207 @@ const ZarzadzanieProduktami = () => {
name: "",
availability: "",
price: "",
- type: ""
+ type: "",
+ description: ""
});
} catch (error) {
console.error('Błąd podczas dodawania produktu:', error);
}
};
+ const handleEditProduct = (product) => {
+ setEditProduct(product);
+ setIsEditModalOpen(true);
+ };
+
+ const handleSaveEditedProduct = async () => {
+ try {
+ await axios.put(`https://localhost:7039/api/Products/${editProduct.id}`, editProduct);
+ fetchProducts();
+ setIsEditModalOpen(false);
+ } catch (error) {
+ console.error('Błąd podczas edycji produktu:', error);
+ }
+ };
+
+ const handleDeleteProduct = async (productId) => {
+ try {
+ await axios.delete(`https://localhost:7039/api/Products/${productId}`);
+ fetchProducts();
+ } catch (error) {
+ console.error('Błąd podczas usuwania produktu:', error);
+ }
+ };
+
return (
Katalog Produktów
-
+
+ {isEditModalOpen && editProduct && (
+
+ )}
{isModalOpen && (
-
-
+
)}
-
+
-
+
+ ID |
Produkt |
Opis |
Cena |
Kategoria |
Dostępność |
+ |
+ |
{products.map(product => (
+ {product.id} |
{product.name} |
{product.description} |
{product.price} |
{product.type} |
{product.availability} |
+ |
+
+ |
))}
-
-
-
-
);
-}
+};
export default ZarzadzanieProduktami;
diff --git a/firm/src/icons/raport.png b/firm/src/icons/raport.png
new file mode 100644
index 0000000..ccf2b06
Binary files /dev/null and b/firm/src/icons/raport.png differ
diff --git a/firm/src/icons/wydatki.png b/firm/src/icons/wydatki.png
new file mode 100644
index 0000000..99ce08b
Binary files /dev/null and b/firm/src/icons/wydatki.png differ