Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
239 changes: 236 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/AlertDialogSlide.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const AlertDialogSlide = ({ dialog, showDialog, setShowDialog }) => {
<div>
<RedButton onClick={() => {
handleClose()
taskHandler()
//removed taskHandler() that was an additonal undefined function
}}>Yes</RedButton>
</div>
</DialogActions>
Expand Down
19 changes: 12 additions & 7 deletions src/components/Products.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@ import styled from 'styled-components';
import { useDispatch, useSelector } from 'react-redux';
import { addToCart } from '../redux/userSlice';
import { BasicButton } from '../utils/buttonStyles';
import { useNavigate } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import Popup from './Popup';
import { addStuff } from '../redux/userHandle';

const Products = ({}) => {
const navigate=useNavigate(); //used imported hooks to define navigate function
const dispatch = useDispatch();

const itemsPerPage = 9;

const { currentRole, responseSearch } = useSelector();
const { currentRole, responseSearch } = useSelector(state=>state.user); //using updater function
const [currentPage, setCurrentPage] = useState(1);
const [showPopup, setShowPopup] = useState(false);
const [message, setMessage] = useState("");

const indexOfLastItem = currentPage * itemsPerPage;
const indexOfFirstItem = indexOfLastItem + itemsPerPage;
const currentItems = (indexOfFirstItem, indexOfLastItem);
const indexOfFirstItem = indexOfLastItem - itemsPerPage; //corrected logic "+"-->"-"
const currentItems = responseSearch.slice(indexOfFirstItem,indexOfLastItem) //corrected slicing logic

const handleAddToCart = (event, product) => {
event.stopPropagation();
Expand All @@ -39,6 +40,10 @@ const Products = ({}) => {
setShowPopup(true)
};

const handlePageChange=(value)=>{
setCurrentPage(value)
}

if (!responseSearch) {
return <div>Product not found</div>;
}
Expand Down Expand Up @@ -89,14 +94,14 @@ const Products = ({}) => {
count={Math.ceil(productData.length / itemsPerPage)}
page={currentPage}
color="secondary"

onChange={handlePageChange}
/>
</Container>

<Popup message={message} setShowPopup={setShowPopup} showPopup={showPopup} />
{ <Popup message={message} setShowPopup={setShowPopup} showPopup={showPopup} onClick={messageHandler} /> }
</>
)
};
}; //added onClick handler--MessageHandler

export default Products;

Expand Down
9 changes: 5 additions & 4 deletions src/pages/AuthenticationPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ const AuthenticationPage = ({ mode, role }) => {
const [shopNameError, setShopNameError] = useState(false);

const handleSubmit = (event) => {

let email, password;
event.preventDefault(); //prevent default from submission behavior
let email=event.target.email.value; //acceesing value of email and password
let password=event.target.password.value;

if (!password) {
if (!email) setEmailError(true);
if (!password) setPasswordError(true);
if (!email) setEmailError(true);
if (!password) setPasswordError(true);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/pages/Logout.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import { authLogout } from '../redux/userSlice';
import { authLogout } from '../redux/userSlice'; //Ensure authlog is used
import styled from 'styled-components';
import { updateCustomer } from '../redux/userHandle';

Expand All @@ -19,7 +19,7 @@ const Logout = () => {
}, [currentRole, currentUser, dispatch])

const handleLogout = () => {

dispatch(authLogout()); //dispatch logout action here, use of import file authlog
navigate('/');
};

Expand Down
Loading