BOD-2 More cleanup after fixing JWT tokens.
This commit is contained in:
@@ -1,43 +1,26 @@
|
||||
import { useQuery } from "@apollo/react-hooks";
|
||||
import { notification } from "antd";
|
||||
import React, { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import AlertComponent from "../../components/alert/alert.component";
|
||||
import { QUERY_BODYSHOP } from "../../graphql/bodyshop.queries";
|
||||
import { setBodyshop } from "../../redux/user/user.actions";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import ManagePage from "./manage.page.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
setBodyshop: bs => dispatch(setBodyshop(bs))
|
||||
});
|
||||
|
||||
function ManagePageContainer({ match, setBodyshop, bodyshop }) {
|
||||
function ManagePageContainer({ match, setBodyshop }) {
|
||||
const { error, data } = useQuery(QUERY_BODYSHOP, {
|
||||
fetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
const { t } = useTranslation();
|
||||
if (error) {
|
||||
notification["error"]({ message: t("bodyshop.errors.loading") });
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (data) setBodyshop(data.bodyshops[0]);
|
||||
}, [data, setBodyshop]);
|
||||
|
||||
if (!bodyshop)
|
||||
return <LoadingSpinner message={t("general.labels.loadingshop")} />;
|
||||
if (error) return <AlertComponent message={error.message} type='error' />;
|
||||
return <ManagePage match={match} />;
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(ManagePageContainer);
|
||||
export default connect(null, mapDispatchToProps)(ManagePageContainer);
|
||||
|
||||
Reference in New Issue
Block a user