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
5 changes: 4 additions & 1 deletion src/components/Dashboard/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const Dashboard = (props) => {
};

const resetQueueForm = () => {
setPhoneNumber('')
setPhoneNumber('');
return document.getElementById("phone-input-form").reset();
};

Expand All @@ -60,6 +60,9 @@ const Dashboard = (props) => {
if (isOpen) {
dashboard.setAttribute("style", "top: 3vh");
addbutton.innerHTML = "CLOSE";
addbutton.addEventListener('click', function () {
resetQueueForm();
});
addbutton.setAttribute("style", "background: #ff421f; color: white");
addbutton.removeEventListener("click", handleExpand);
addbutton.addEventListener("click", handleCollapse);
Expand Down
44 changes: 43 additions & 1 deletion src/components/WaitList/WaitList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,41 @@ import React from 'react';
import styles from './WaitList.module.scss'
import clock from '../../utils/imgs/clock.png'
import Reservation from '../Reservation';
import { actionUpdateReservation } from '../../actions';
import { connect } from "react-redux";

const WaitList = (props) => {
let {
retailerName,
waitList,
holdList,
handlePlusPartySize,
} = props;

const clearReservations = () => {
let waitLength = waitList.length;
let holdLength = holdList.length;

if (waitLength === 0 && holdLength === 0) {
return alert('No reservations to cancel.');
}
if (waitLength !== 0) {
waitList.forEach((res) => {
let data = { queueStatus: 'cancelled' }
props.dispatchUpdateReservation(data, res.id);
});
alert(`Wait list cleared ${waitLength} reservations.`)
};
if (holdLength !== 0) {
holdList.forEach((res) => {
let data = { queueStatus: 'cancelled' }
props.dispatchUpdateReservation(data, res.id);
})
alert(`Hold list cleared ${holdLength} reservations.`)
}
return
};
Comment on lines +16 to +38
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I don't think this is good. This requires the front end to fire off a request to the backend for every single reservation on the front, that could be a lot of calls. I think we need to create a new backend route that will update the reservations based on what's saved in the retailer's reservation array.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lemme know if you wanna discuss and we can talk about what that might look like.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I'll look into updating multiple documents with one call


return (
<ul className={styles.WaitList}>
<div className={styles.header}>
Expand All @@ -18,8 +45,15 @@ const WaitList = (props) => {
<img src={clock} alt="average wait time" />
<h3>5 Min</h3>
</div>
<button
type="button"
onClick={clearReservations}
>
Clear
</button>
</div>
<div className={styles.listContainer}>
{waitList.length === 0 ? "No Reservations..." : null}
{waitList.map((reservation, index) => {
let replyStatuses = {
confirmed: "#6d9773",
Expand Down Expand Up @@ -48,4 +82,12 @@ const WaitList = (props) => {
);
};

export default WaitList;
const mapDispatchToProps = (dispatch) => {
return {
dispatchUpdateReservation: (data, id) => {
return dispatch(actionUpdateReservation(data, id))
}
}
};

export default connect(null, mapDispatchToProps)(WaitList);
2 changes: 1 addition & 1 deletion src/views/RetailerView/RetailerView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ function RetailerView(props) {
return dispatchFetchOneRetailer(retailer.id);
}
}, [dispatchFetchOneRetailer]);

return (
<>
<div className={styles.RetailerView}>
<WaitList
retailerName={props.retailerName}
waitList={props.waitList}
holdList={props.holdList}
handlePlusPartySize={handlePlusPartySize}
/>
<HoldList
Expand Down