From c51ef746f097e0283e4060e2e75f503b7d37c8e5 Mon Sep 17 00:00:00 2001 From: Juanpi92 Date: Fri, 15 Sep 2023 15:03:22 -0300 Subject: [PATCH] feat(EditProduct.jsx) Creating edit product component and functionality --- src/components/AdminProductsList/index.jsx | 8 +- src/components/CartCompras.css | 65 ------- src/components/CartComprasAdmin.css | 6 - src/components/CartComprasAdmin.jsx | 42 ----- src/components/CartItemProductAdmin.jsx | 54 ------ src/components/CartModalComprasAdmin.jsx | 19 -- src/components/CartProductAdmin.css | 8 - src/components/Footer/index.jsx | 30 ++- src/components/Footer/styles.css | 23 ++- src/components/FormAdminProductos.css | 59 ------ src/components/FormAdminProductos.jsx | 113 ------------ src/components/Modal/index.jsx | 14 +- src/components/ModalComprasAdmin.css | 26 --- src/components/ModalComprasAdmin.jsx | 49 ----- src/components/ModalProductAdmin.css | 20 -- src/components/ModalProductAdmin.jsx | 29 --- src/pages/AdminCompras/styles.css | 1 + src/pages/AdminProducts/EditProduct/index.jsx | 174 ++++++++++++++++++ .../AdminProducts/EditProduct/styles.css | 104 +++++++++++ src/pages/AdminProducts/index.jsx | 6 +- src/pages/LoginAdmin/index.jsx | 2 +- src/pages/LoginAdmin/styles.css | 2 + 22 files changed, 332 insertions(+), 522 deletions(-) delete mode 100644 src/components/CartCompras.css delete mode 100644 src/components/CartComprasAdmin.css delete mode 100644 src/components/CartComprasAdmin.jsx delete mode 100644 src/components/CartItemProductAdmin.jsx delete mode 100644 src/components/CartModalComprasAdmin.jsx delete mode 100644 src/components/CartProductAdmin.css delete mode 100644 src/components/FormAdminProductos.css delete mode 100644 src/components/FormAdminProductos.jsx delete mode 100644 src/components/ModalComprasAdmin.css delete mode 100644 src/components/ModalComprasAdmin.jsx delete mode 100644 src/components/ModalProductAdmin.css delete mode 100644 src/components/ModalProductAdmin.jsx create mode 100644 src/pages/AdminProducts/EditProduct/index.jsx create mode 100644 src/pages/AdminProducts/EditProduct/styles.css diff --git a/src/components/AdminProductsList/index.jsx b/src/components/AdminProductsList/index.jsx index a09cabb..bf80022 100644 --- a/src/components/AdminProductsList/index.jsx +++ b/src/components/AdminProductsList/index.jsx @@ -92,11 +92,13 @@ const ProductsActionBar = ({ product, setProductToShow }) => { }; const ProductListItem = ({ product, setDataToEdit }) => { - const { setLoader } = useContext(AppContext); + const { setShowProductModal, setIsAddProduct, setLoader } = + useContext(AppContext); let { id, name, type, portion, price, src } = product; const state = useSelector((state) => state); const userAdmin = state.user; const dispatch = useDispatch(); + const handleDelete = async (id) => { try { const options = { @@ -113,7 +115,7 @@ const ProductListItem = ({ product, setDataToEdit }) => { setLoader(false); } catch (error) { setLoader(false); - console.log(error); + alert("Ocurreu um error"); } }; return ( @@ -127,6 +129,8 @@ const ProductListItem = ({ product, setDataToEdit }) => { className="option_icon" onClick={() => { setDataToEdit(product); + setShowProductModal(true); + setIsAddProduct(false); }} /> { - const dispatch = useDispatch(); - let { id, usuario, cpf, address, totalCart, cart } = data; - return ( - <> - - {usuario} - {cpf} - {address} - R$ {totalCart.toFixed(2)} - -
- - -
- - - - ); -}; - -export default CartComprasAdmin; diff --git a/src/components/CartItemProductAdmin.jsx b/src/components/CartItemProductAdmin.jsx deleted file mode 100644 index 022b2db..0000000 --- a/src/components/CartItemProductAdmin.jsx +++ /dev/null @@ -1,54 +0,0 @@ -import React from "react"; -import { useDispatch } from "react-redux"; -import { delProduct } from "../reducer/shoopingReducer"; - -const CartItemProductAdmin = ({ - product, - $ModalProductAdmin, - SetSrcImagen, - setDataToEdit, -}) => { - let { id, name, portion, price, src } = product; - const dispatch = useDispatch(); - return ( - <> - - {name} - {portion} - R$ {price} - -
- - - - -
- - - - ); -}; - -export default CartItemProductAdmin; diff --git a/src/components/CartModalComprasAdmin.jsx b/src/components/CartModalComprasAdmin.jsx deleted file mode 100644 index 3594cf2..0000000 --- a/src/components/CartModalComprasAdmin.jsx +++ /dev/null @@ -1,19 +0,0 @@ -import React from "react"; -import "./CartCompras.css"; - -const CartModalComprasAdmin = ({ compra }) => { - let { name, quantity, price } = compra; - return ( - <> - - {name} - {quantity} - - R$ {price.toFixed(2)} x {quantity} = R$ {(price * quantity).toFixed(2)} - - - - ); -}; - -export default CartModalComprasAdmin; diff --git a/src/components/CartProductAdmin.css b/src/components/CartProductAdmin.css deleted file mode 100644 index aad4f63..0000000 --- a/src/components/CartProductAdmin.css +++ /dev/null @@ -1,8 +0,0 @@ -.cart_admin_product { - margin: 71px 20px; - margin-bottom: 20px; - background-color: rgba(0, 0, 0, 0.75); - border-radius: 5px; - padding: 10px; - width: 50%; -} diff --git a/src/components/Footer/index.jsx b/src/components/Footer/index.jsx index 150b4fe..a28e589 100644 --- a/src/components/Footer/index.jsx +++ b/src/components/Footer/index.jsx @@ -1,16 +1,22 @@ import React from "react"; import "./styles.css"; import { FacebookOutlined, Instagram, Twitter } from "@mui/icons-material"; +import { useNavigate } from "react-router-dom"; function Footer() { + const navigate = useNavigate(); return ( -