Added vehicle and owner pages/routes.
This commit is contained in:
@@ -1,6 +1,34 @@
|
||||
import React from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import ManagePage from "./manage.page";
|
||||
import { useQuery } from "react-apollo";
|
||||
import { QUERY_BODYSHOP } from "../../graphql/bodyshop.queries";
|
||||
import { setBodyshop } from "../../redux/user/user.actions";
|
||||
import { connect } from "react-redux";
|
||||
import { notification } from "antd";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
export default function ManagePageContainer() {
|
||||
return <ManagePage />;
|
||||
}
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
setBodyshop: bs => dispatch(setBodyshop(bs))
|
||||
});
|
||||
|
||||
export default connect(
|
||||
null,
|
||||
mapDispatchToProps
|
||||
)(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]);
|
||||
return () => {
|
||||
//
|
||||
};
|
||||
}, [data]);
|
||||
|
||||
return <ManagePage match={match} />;
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { BackTop, Layout, notification } from "antd";
|
||||
import React, { lazy, Suspense, useEffect } from "react";
|
||||
import { useQuery } from "react-apollo";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
//This page will handle all routing for the entire application.
|
||||
import { connect } from "react-redux";
|
||||
@@ -10,7 +10,6 @@ import FooterComponent from "../../components/footer/footer.component";
|
||||
//Component Imports
|
||||
import HeaderContainer from "../../components/header/header.container";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import { QUERY_BODYSHOP } from "../../graphql/bodyshop.queries";
|
||||
//const WhiteBoardPage = lazy(() => import("../white-board/white-board.page"));
|
||||
import { setBodyshop } from "../../redux/user/user.actions";
|
||||
import "./manage.page.styles.scss";
|
||||
@@ -35,29 +34,21 @@ const ChatWindowContainer = lazy(() =>
|
||||
const ScheduleContainer = lazy(() =>
|
||||
import("../schedule/schedule.page.container")
|
||||
);
|
||||
|
||||
const VehiclesContainer = lazy(() =>
|
||||
import("../vehicles/vehicles.page.container")
|
||||
);
|
||||
const VehiclesDetailContainer = lazy(() =>
|
||||
import("../vehicles-detail/vehicles-detail.page.container")
|
||||
);
|
||||
const OwnersContainer = lazy(() => import("../owners/owners.page.container"));
|
||||
const OwnersDetailContainer = lazy(() =>
|
||||
import("../owners-detail/owners-detail.page.container")
|
||||
);
|
||||
const { Header, Content, Footer } = Layout;
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
setBodyshop: bs => dispatch(setBodyshop(bs))
|
||||
});
|
||||
export default connect(
|
||||
null,
|
||||
mapDispatchToProps
|
||||
)(function Manage({ match, setBodyshop }) {
|
||||
export default function Manage({ match }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const { error, data } = useQuery(QUERY_BODYSHOP, {
|
||||
fetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
if (error) {
|
||||
notification["error"]({ message: t("bodyshop.errors.loading") });
|
||||
}
|
||||
if (data) {
|
||||
setBodyshop(data.bodyshops[0]);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
document.title = t("titles.app");
|
||||
}, [t]);
|
||||
@@ -96,7 +87,26 @@ export default connect(
|
||||
path={`${match.path}/profile`}
|
||||
component={ProfilePage}
|
||||
/>
|
||||
|
||||
<Route
|
||||
exact
|
||||
path={`${match.path}/vehicles`}
|
||||
component={VehiclesContainer}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${match.path}/vehicles/:vehId`}
|
||||
component={VehiclesDetailContainer}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${match.path}/owners`}
|
||||
component={OwnersContainer}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${match.path}/owners/:ownerId`}
|
||||
component={OwnersDetailContainer}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={`${match.path}/schedule`}
|
||||
@@ -118,4 +128,4 @@ export default connect(
|
||||
<BackTop />
|
||||
</Layout>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import React from "react";
|
||||
|
||||
export default function OwnersDetailComponent() {
|
||||
return <div>Owner Detail</div>;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import React from "react";
|
||||
import OwnersDetailComponent from "./owners-detail.page.component";
|
||||
|
||||
export default function OwnersDetailContainer({ match }) {
|
||||
const { ownerId } = match.params;
|
||||
console.log("ownerId", ownerId);
|
||||
return <OwnersDetailComponent />;
|
||||
}
|
||||
9
client/src/pages/owners/owners.page.component.jsx
Normal file
9
client/src/pages/owners/owners.page.component.jsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from 'react'
|
||||
|
||||
export default function OwnersPageComponent() {
|
||||
return (
|
||||
<div>
|
||||
Owners Page
|
||||
</div>
|
||||
)
|
||||
}
|
||||
8
client/src/pages/owners/owners.page.container.jsx
Normal file
8
client/src/pages/owners/owners.page.container.jsx
Normal file
@@ -0,0 +1,8 @@
|
||||
import React from 'react'
|
||||
import OwnersPageComponent from './owners.page.component'
|
||||
|
||||
export default function OwnersPageContainer() {
|
||||
return (
|
||||
<OwnersPageComponent />
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import React from "react";
|
||||
|
||||
export default function VehicleDetailComponent({ vehicle }) {
|
||||
return (
|
||||
<div>
|
||||
Veh detail <span>{vehicle.v_vin}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import React from "react";
|
||||
import VehicleDetailComponent from "./vehicles-detail.page.component";
|
||||
import { useQuery } from "react-apollo";
|
||||
import { QUERY_VEHICLE_BY_ID } from "../../graphql/vehicles.queries";
|
||||
import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component";
|
||||
import AlertComponent from "../../components/alert/alert.component";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
export default function VehicleDetailContainer({ match }) {
|
||||
const { vehId } = match.params;
|
||||
const { t } = useTranslation();
|
||||
const { loading, data, error, refetch } = useQuery(QUERY_VEHICLE_BY_ID, {
|
||||
variables: { id: vehId },
|
||||
fetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
if (loading) return <LoadingSpinner />;
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
|
||||
console.log("vehId", vehId);
|
||||
|
||||
if (data.vehicles[0])
|
||||
return <VehicleDetailComponent vehicle={data.vehicles[0]} />;
|
||||
else
|
||||
return (
|
||||
<AlertComponent message={t("vehicles.errors.noaccess")} type="error" />
|
||||
);
|
||||
}
|
||||
9
client/src/pages/vehicles/vehicles.page.component.jsx
Normal file
9
client/src/pages/vehicles/vehicles.page.component.jsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import React from 'react'
|
||||
|
||||
export default function VehiclesPageComponent() {
|
||||
return (
|
||||
<div>
|
||||
Vehiculos
|
||||
</div>
|
||||
)
|
||||
}
|
||||
6
client/src/pages/vehicles/vehicles.page.container.jsx
Normal file
6
client/src/pages/vehicles/vehicles.page.container.jsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import React from "react";
|
||||
import VehiclesPageComponent from "./vehicles.page.component";
|
||||
|
||||
export default function VehiclesPageContainer() {
|
||||
return <VehiclesPageComponent />;
|
||||
}
|
||||
Reference in New Issue
Block a user