diff --git a/src/actions/index.js b/src/actions/index.js
index 854ecb1..21ede51 100644
--- a/src/actions/index.js
+++ b/src/actions/index.js
@@ -61,7 +61,7 @@ export const searchRetailersByName = (data) => async (dispatch) => {
});
};
-export const fetchOneRetailer = (id) => async (dispatch) => {
+export const actionFetchOneRetailer = (id) => async (dispatch) => {
// needs to be replaced later with dynamically generated ids
await Axios.get(`/api/retailers/${id}`)
.then((retailer) => {
@@ -103,7 +103,7 @@ export const actionUpdateReservation = (data, id) => async (dispatch) => {
});
};
-export const notifyCustomer = (data) => async (dispatch) => {
+export const actionNotifyCustomer = (data) => async (dispatch) => {
await Axios.post("/api/sms/send", data)
.then((response) => {
dispatch({
@@ -179,7 +179,7 @@ export const actionFindRetailers = () => async (dispatch) => {
});
};
-export const actionSearchingRetailers = (searchTerm) => async (dispatch) => {
+export const actionSearchRetailers = (searchTerm) => async (dispatch) => {
await Axios.get("/api/customers/search?searchTerm=" + searchTerm)
.then((retailers) => {
dispatch({
diff --git a/src/components/Modal/Modal.jsx b/src/components/Modal/Modal.jsx
index e490c88..2bda5cd 100644
--- a/src/components/Modal/Modal.jsx
+++ b/src/components/Modal/Modal.jsx
@@ -1,18 +1,10 @@
-import React, { Component } from "react";
+import React from "react";
import styles from "./Modal.module.scss";
-class Modal extends Component {
- constructor(props) {
- super(props);
- this.state = {};
- }
- render() {
- return (
-
{/* Needs to be connected to a button to access retailer profile. */}
- {/*
*/}
+ {/*
*/}
>
);
}
-const mapStateToProps = (state) => {
- return {
- waitList: state.currentRetailer.reservations.filter((res) => {
- return res.queueStatus === "wait";
- }),
- holdList: state.currentRetailer.reservations.filter((res) => {
- return res.queueStatus === "hold";
- }),
- retailerName: state.currentRetailer
- ? state.currentRetailer.retailerName
- : null,
- retailer: state.currentRetailer,
- };
-};
-
-const mapDispatchToProps = (dispatch) => {
- return {
- dispatchFetchOneRetailer: (id) => {
- dispatch(fetchOneRetailer(id));
- },
- changeCustomersInStore: (data, id) => {
- dispatch(actionUpdateRetailer(data, id, true));
- },
- };
-};
-export default connect(mapStateToProps, mapDispatchToProps)(RetailerView);
+export default RetailerView;
diff --git a/src/views/UserView/UserView.jsx b/src/views/UserView/UserView.jsx
index 8d0f812..b37ccb7 100644
--- a/src/views/UserView/UserView.jsx
+++ b/src/views/UserView/UserView.jsx
@@ -1,29 +1,25 @@
import React from "react";
import styles from "./UserView.module.scss";
import magGlass from "../../utils/imgs/magGlass.png";
-import { connect } from "react-redux";
-import { actionFindRetailers, actionSearchingRetailers } from "../../actions";
+import { useDispatch, useSelector } from "react-redux";
+import { actionFindRetailers, actionSearchRetailers } from "../../actions";
import RetailerCard from "../../components/RetailerCard/RetailerCard";
import { useEffect, useState } from "react";
function UserView(props) {
+ const dispatch = useDispatch();
+ const customerSearchRetailer = useSelector(state=> state.customerSearchRetailer);
const [searchTerm, setSearchTerm] = useState('');
- const [foundRetailers, setFoundRetailers] = useState([]);
//on mount find all retailers
- let {dispatchFindRetailers} = props
useEffect(() => {
- return dispatchFindRetailers();
- }, [dispatchFindRetailers]);
-
- useEffect(() => {
- return setFoundRetailers(props.customerSearchRetailer);
- }, [props.customerSearchRetailer]);
+ dispatch(actionFindRetailers());
+ }, []);
const handleSearchSubmit = (e) => {
e.preventDefault();
if (searchTerm !== '') {
- props.dispatchSearchingRetailers(searchTerm);
+ dispatch(actionSearchRetailers(searchTerm));
}
return setSearchTerm('');
};
@@ -51,9 +47,9 @@ function UserView(props) {

- {foundRetailers.length === 0 ?
{"No search results"}
: null}
+ {customerSearchRetailer.length === 0 ?
{"No search results"}
: null}
- {foundRetailers.map((store, index) => {
+ {customerSearchRetailer.map((store, index) => {
return (
{
- return {
- customerSearchRetailer: [...state.customerSearchRetailer],
- };
-};
-const mapDispatchToProps = (dispatch) => {
- return {
- dispatchFindRetailers: () => {
- return dispatch(actionFindRetailers());
- },
- dispatchSearchingRetailers: (term) => {
- return dispatch(actionSearchingRetailers(term));
- },
- };
-};
-export default connect(mapStateToProps, mapDispatchToProps)(UserView);
+export default UserView;