BOD-16 Added pages + routing for courtesy cars
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
import React from "react";
|
||||
import CourtesyCarCreateFormComponent from "../../components/courtesy-car-form/courtesy-car-form.component"
|
||||
|
||||
export default function CourtesyCarCreateComponent() {
|
||||
return <CourtesyCarCreateFormComponent />;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { useMutation } from "@apollo/react-hooks";
|
||||
import { Form, notification } from "antd";
|
||||
import React, { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { INSERT_NEW_COURTESY_CAR } from "../../graphql/courtesy-car.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import CourtesyCarCreateComponent from "./courtesy-car-create.page.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
|
||||
export function CourtesyCarCreateContainer({ bodyshop }) {
|
||||
const [form] = Form.useForm();
|
||||
const [insertCourtesyCar] = useMutation(INSERT_NEW_COURTESY_CAR);
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleFinish = values => {
|
||||
insertCourtesyCar({
|
||||
variables: { courtesycar: { ...values, bodyshopid: bodyshop.id } }
|
||||
})
|
||||
.then(response => {
|
||||
notification["success"]({ message: t("courtesycars.successes.saved") });
|
||||
})
|
||||
.catch(error => console.log("error", error));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
document.title = t("titles.courtesycars-create");
|
||||
}, [t]);
|
||||
|
||||
return (
|
||||
<Form form={form} autoComplete="no" onFinish={handleFinish}>
|
||||
<CourtesyCarCreateComponent />
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
export default connect(mapStateToProps, null)(CourtesyCarCreateContainer);
|
||||
Reference in New Issue
Block a user