Skip to content

Commit

Permalink
Fix error message display in AddReservation component
Browse files Browse the repository at this point in the history
  • Loading branch information
George7h committed Mar 7, 2024
1 parent 6ce119b commit b3405dc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Components/AddReservation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const AddReservation = () => {
const status = useSelector((state) => state.addReservation.status);
const error = useSelector((state) => state.addReservation.error);
const places = useSelector((state) => state.places.places);
const [errorMessage] = useState('');
const [errorMessage, setErrorMessage] = useState('');

useEffect(() => {
if (userId) {
Expand Down Expand Up @@ -58,7 +58,10 @@ const AddReservation = () => {
e.preventDefault();

if (!reservationData.start_date || !reservationData.end_date || !reservationData.place_id) {
alert('Please fill in all fields');
setErrorMessage('Please fill in all fields');
setTimeout(() => {
setErrorMessage('');
}, 5000);
return;
}

Expand Down

0 comments on commit b3405dc

Please sign in to comment.