WIP on several user stories. BOD-10 BOD-52

This commit is contained in:
Patrick Fic
2020-03-23 17:40:48 -07:00
parent f04ba766ad
commit 7d33484294
10 changed files with 63 additions and 94 deletions

View File

@@ -1,20 +1,16 @@
import { useQuery } from "@apollo/react-hooks";
import { notification } from "antd";
import React, { useEffect } from "react";
import { useQuery } from "@apollo/react-hooks";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
import { QUERY_BODYSHOP } from "../../graphql/bodyshop.queries";
import { setBodyshop } from "../../redux/user/user.actions";
import {
selectBodyshop,
selectCurrentUser
} from "../../redux/user/user.selectors";
import { selectBodyshop } from "../../redux/user/user.selectors";
import ManagePage from "./manage.page.component";
const mapStateToProps = createStructuredSelector({
currentUser: selectCurrentUser,
bodyshop: selectBodyshop
});
@@ -22,13 +18,11 @@ const mapDispatchToProps = dispatch => ({
setBodyshop: bs => dispatch(setBodyshop(bs))
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(function ManagePageContainer({ match, setBodyshop, bodyshop }) {
function ManagePageContainer({ match, setBodyshop, bodyshop }) {
const { error, data } = useQuery(QUERY_BODYSHOP, {
fetchPolicy: "network-only"
});
const { t } = useTranslation();
if (error) {
notification["error"]({ message: t("bodyshop.errors.loading") });
@@ -36,10 +30,14 @@ export default connect(
useEffect(() => {
if (data) setBodyshop(data.bodyshops[0]);
return () => {};
}, [data, setBodyshop]);
if (!bodyshop)
return <LoadingSpinner message={t("general.labels.loadingshop")} />;
return <ManagePage match={match} />;
});
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(ManagePageContainer);