Added tech routing paths and basic structure of landing page + sign in + reducers BOD-95

This commit is contained in:
Patrick Fic
2020-06-29 13:39:17 -07:00
parent 0009f7d3bb
commit 2edfadce3a
24 changed files with 662 additions and 24 deletions

View File

@@ -0,0 +1,30 @@
import { useQuery } from "@apollo/react-hooks";
import React, { useEffect } from "react";
import { connect } from "react-redux";
import AlertComponent from "../../components/alert/alert.component";
import { QUERY_BODYSHOP } from "../../graphql/bodyshop.queries";
import { setBodyshop } from "../../redux/user/user.actions";
import TechPage from "./tech.page.component";
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
import { useTranslation } from "react-i18next";
const mapDispatchToProps = (dispatch) => ({
setBodyshop: (bs) => dispatch(setBodyshop(bs)),
});
export function TechPageContainer({ setBodyshop, match }) {
const { loading, error, data } = useQuery(QUERY_BODYSHOP, {
fetchPolicy: "network-only",
});
const { t } = useTranslation();
useEffect(() => {
if (data) setBodyshop(data.bodyshops[0]);
}, [data, setBodyshop]);
if (loading)
return <LoadingSpinner message={t("general.labels.loadingshop")} />;
if (error) return <AlertComponent message={error.message} type='error' />;
return <TechPage match={match} />;
}
export default connect(null, mapDispatchToProps)(TechPageContainer);