-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
product : testimonilal authslice udpate.
- Loading branch information
1 parent
21ea910
commit de602e8
Showing
18 changed files
with
272 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
frontend/src/pages/admin-dashboard/body/list-of-products/ListOfProducts.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { getAllProduct } from '../../../../redux/auth/authSlice'; | ||
import UserTable from './ProductsTable'; | ||
import { FiMaximize } from 'react-icons/fi'; | ||
import { FaMinus } from 'react-icons/fa'; | ||
|
||
const ListOfProducts = () => { | ||
const { allProduct } = useSelector((state) => state.auth); | ||
const dispatch = useDispatch(); | ||
useEffect(() => { | ||
if (!allProduct) { | ||
dispatch(getAllProduct()); | ||
} | ||
}, [allProduct, dispatch]); | ||
const [isOpen, setIsOpen] = useState(true); | ||
|
||
const handleToggle = () => { | ||
setIsOpen((val) => !val); | ||
}; | ||
return ( | ||
<div | ||
className={`${isOpen ? 'list__of__product' : 'list__of__users__close'}`} | ||
> | ||
<div className="header"> | ||
<p>All Products</p> | ||
{isOpen ? ( | ||
<FaMinus onClick={handleToggle} /> | ||
) : ( | ||
<FiMaximize onClick={handleToggle} /> | ||
)} | ||
</div> | ||
<article> | ||
{allProduct && <UserTable k data={allProduct} isOpen={isOpen} />} | ||
</article> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ListOfProducts; |
41 changes: 41 additions & 0 deletions
41
frontend/src/pages/admin-dashboard/body/list-of-products/ProductsTable.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
|
||
const ProductsTable = ({ data, isOpen }) => { | ||
console.log(data); | ||
return ( | ||
<div className={`${isOpen === true ? 'user__table' : 'table_hide'}`}> | ||
<table> | ||
<tr className="t-head"> | ||
<th className="first">Name</th> | ||
<th>Description</th> | ||
<th>Price</th> | ||
<th>Rating</th> | ||
<th>Image</th> | ||
<th>Category</th> | ||
<th>Stock</th> | ||
<th>Reviews</th> | ||
<th className="last">Created At</th> | ||
</tr> | ||
<tr> | ||
{data.map((prod) => ( | ||
<div key={prod._id} className="t-body"> | ||
<td>{prod.name}</td> | ||
<td>{prod.description}</td> | ||
<td>{prod.price}</td> | ||
<td>{prod.rating}</td> | ||
<td className="prod__image"> | ||
<img src={prod.images[0].url} alt={prod.name} /> | ||
</td> | ||
<td>{prod.category}</td> | ||
<td>{prod.stock}</td> | ||
<td>{prod.reviews}</td> | ||
<td>{prod.createdAt}</td> | ||
</div> | ||
))} | ||
</tr> | ||
</table> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ProductsTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.