diff --git a/src/Components/Product/CreateProduct.jsx b/src/Components/Product/CreateProduct.jsx index 999eaec6..765c1cc1 100644 --- a/src/Components/Product/CreateProduct.jsx +++ b/src/Components/Product/CreateProduct.jsx @@ -85,7 +85,7 @@ function CreateProduct() { try { if (!isAdmin) return alert("You're not an admin") setLoading(true) - await axios.post('/api/destroy', { public_id: images.public_id }, { + await axios.post('/api/destroy', { public_id: images.id }, { headers: { Authorization: token } }) @@ -108,7 +108,8 @@ function CreateProduct() { if (!isAdmin) return alert("You're not an admin") if (!images) return alert("No Image Upload") if (onEdit) { - await axios.put(`/api/products/${product._id}`, { ...products, images }, { + console.log(product) + await axios.put(`/api/products/${product._id}`, { ...product, images }, { headers: { Authorization: token } }) @@ -131,6 +132,7 @@ function CreateProduct() { const software = {name:"Software"} const books = {name:"Books"} const categories = [software, books]; + console.log(product) return ( <> diff --git a/src/Components/Product/LoadMore.jsx b/src/Components/Product/LoadMore.jsx new file mode 100644 index 00000000..abc21baf --- /dev/null +++ b/src/Components/Product/LoadMore.jsx @@ -0,0 +1,29 @@ +import React, { useContext, useState } from 'react'; + +import Loading from '../Loading/Loading' +import { GlobalState } from '../../GlobalState'; +import './Products.css'; + +// Load additional Products for pagination +const LoadMore = () => { + + const state = useContext(GlobalState) + const [page, setPage] = state.productsAPI.page + const [result] = state.productsAPI.result + const [loading] = useState(false) + + if (loading) return
+ + return ( + <> +
+ { + result < page * 9 ? "" + : + } +
+ + ) +} + +export default LoadMore;