diff --git a/firm/src/components/DodawanieTransakcji.js b/firm/src/components/DodawanieTransakcji.js index c7b1176..f3821dd 100644 --- a/firm/src/components/DodawanieTransakcji.js +++ b/firm/src/components/DodawanieTransakcji.js @@ -190,14 +190,6 @@ const DodawanieTransakcji = () => { - {/**/}
{isLoading ? ( diff --git a/firm/src/components/EdycjaTransakcji.js b/firm/src/components/EdycjaTransakcji.js index 8ed9939..ed2f094 100644 --- a/firm/src/components/EdycjaTransakcji.js +++ b/firm/src/components/EdycjaTransakcji.js @@ -1,6 +1,7 @@ import React, { useState, useEffect } from "react"; import axios from "axios"; import { useParams, useNavigate } from "react-router-dom"; +import {ReactComponent as MinusIcon} from "../icons/minus-icon.svg" import Select from "react-select"; const EdycjaTransakcji = () => { @@ -204,111 +205,154 @@ const EdycjaTransakcji = () => { return (
-

Edycja Transakcji

+

Edytuj transakcję

+ {error &&

{error}

} -
- - {errors.date && {errors.date}} -
- -
- - {errors.employeeId && {errors.employeeId}} -
- - {transaction.transactionProducts.map((product, index) => ( -
- - {errors[`productID_${index}`] && ( - {errors[`productID_${index}`]} - )} + {errors.date && {errors.date}} +
+
+
+ handleQuantityChange(index, e.target.value)} - placeholder="Ilość" - className="block w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500" + name="employeeId" + value={transaction.employeeId} + onChange={handleInputChange} + placeholder="Nr pracownika" + className="flex mb-4 px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500" /> - {errors[`quantity_${index}`] && ( - {errors[`quantity_${index}`]} - )} - + {errors.employeeId && {errors.employeeId}}
- ))} - + +
+ {transaction.transactionProducts.map((product, index) => ( +
+ handleQuantityChange(index, e.target.value)} + placeholder="Ilość" + className="w-24 px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500" + /> + +
+ ))} + +
-
+
+
+ +
+ + + +
+
+ +
+ + +
+
+ +
+ - {errors.paymentType && {errors.paymentType}}
-
- - {errors.discount && {errors.discount}} -
- ); + ); }; export default EdycjaTransakcji; diff --git a/firm/src/components/ListaProduktów.js b/firm/src/components/ListaProduktów.js index 1f1f19f..4b71dbf 100644 --- a/firm/src/components/ListaProduktów.js +++ b/firm/src/components/ListaProduktów.js @@ -1,7 +1,7 @@ import React, { useState, useEffect } from 'react'; import axios from 'axios'; -import editIcon from '../icons/edit.png'; -import koszIcon from '../icons/kosz.png'; +import {ReactComponent as EditIcon} from '../icons/edit.svg'; +import {ReactComponent as KoszIcon} from '../icons/delete.svg'; import { useNavigate } from 'react-router-dom'; const ListaProduktow = ({ onAdd }) => { @@ -26,6 +26,11 @@ const ListaProduktow = ({ onAdd }) => { fetchProducts(); }, []); + const openDeleteConfirmation = (productId) => { + setDeleteProductId(productId); + setShowModal(true); + }; + const handleDeleteProduct = async () => { const token = localStorage.getItem('token'); if (!token) { @@ -76,7 +81,7 @@ const ListaProduktow = ({ onAdd }) => { {products.map((product) => ( - + {product.id} {product.name} {product.description} @@ -84,25 +89,20 @@ const ListaProduktow = ({ onAdd }) => { {product.type === 0 ? "" : product.availability} - - - - +
+ + +
))} diff --git a/firm/src/components/ListaTransakcji.js b/firm/src/components/ListaTransakcji.js index 2c04d8e..3fc2909 100644 --- a/firm/src/components/ListaTransakcji.js +++ b/firm/src/components/ListaTransakcji.js @@ -1,7 +1,5 @@ import React, { useState, useEffect } from 'react'; import axios from 'axios'; -//import editIcon from '../icons/edit.png'; -//import koszIcon from '../icons/kosz.png'; import {ReactComponent as EditIcon} from '../icons/edit.svg'; import {ReactComponent as KoszIcon} from '../icons/delete.svg'; import { useNavigate } from 'react-router-dom'; @@ -133,14 +131,12 @@ const ListaTransakcji = ({ onAdd}) => {
-
+
-
+
- +
setToDate(e.target.value)} + onChange={handleToDateChange} className="w-full px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent" />
@@ -133,10 +158,17 @@ const Raporty = () => { > Generuj raport + + {error && ( +
+ {error} +
+ )}
+
@@ -147,47 +179,34 @@ const Raporty = () => { - + {reports.map((report) => ( - + - + ))}
Suma dochodów Suma wydatków BilansUsuń
{report.id} {formatDate(report.fromDate)} {formatDate(report.toDate)} {report.totalIncome} {report.totalExpenses} {report.totalBalance} - - +
+ +
+
- {error && ( -
-
-

Błąd

-

{error}

- -
-
- )} - {showDeleteModal && (
diff --git a/firm/src/components/Wydatki.js b/firm/src/components/Wydatki.js index 8b2eabe..ed82995 100644 --- a/firm/src/components/Wydatki.js +++ b/firm/src/components/Wydatki.js @@ -1,10 +1,10 @@ import React, { useState, useEffect } from 'react'; import axios from 'axios'; -import koszIcon from "../icons/kosz.png"; +import { ReactComponent as KoszIcon } from '../icons/delete.svg'; const Wydatki = () => { const [expenses, setExpenses] = useState([]); - const [showModal, setShowModal] = useState(false); + const [fromDate, setFromDate] = useState(''); const [showDeleteModal, setShowDeleteModal] = useState(false); const [error, setError] = useState(null); const [deleteExpenseId, setDeleteExpenseId] = useState(null); @@ -40,6 +40,11 @@ const Wydatki = () => { return; } + if (newExpense.value <= 0) { + setError('Wartość wydatku musi być liczbą dodatnią.'); + return; + } + const token = localStorage.getItem('token'); try { const response = await axios.post('https://localhost:7039/api/Expenses', newExpense, { @@ -48,7 +53,6 @@ const Wydatki = () => { const addedExpense = response.data; setExpenses([...expenses, addedExpense]); setNewExpense({ date: '', value: '', description: '' }); - setShowModal(false); } catch (error) { console.error('Błąd podczas dodawania wydatku:', error); setError('Wystąpił błąd podczas dodawania wydatku.'); @@ -62,7 +66,6 @@ const Wydatki = () => { headers: { Authorization: `Bearer ${token}` }, }); - // Optimistically update the local state by filtering out the deleted expense setExpenses(expenses.filter(expense => expense.id !== deleteExpenseId)); setDeleteExpenseId(null); setShowDeleteModal(false); @@ -87,19 +90,80 @@ const Wydatki = () => { return date.toLocaleDateString('pl-PL', options).replace(",", ""); }; + const handleDateChange = (e) => { + setNewExpense({ ...newExpense, date: e.target.value }); + }; + + const handleValueChange = (e) => { + setNewExpense({ ...newExpense, value: e.target.value }); + }; + + const handleDescriptionChange = (e) => { + setNewExpense({ ...newExpense, description: e.target.value }); + }; + return (
-
-
-
Wydatki
- +
+

Wydatki

+
+ +
+
+
+
+
+ + +
+ +
+ + +
+
+ +
+ +