Clean up CC save function.
This commit is contained in:
@@ -3,17 +3,16 @@ import { Form, notification } from "antd";
|
|||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
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 CourtesyCarFormComponent from "../../components/courtesy-car-form/courtesy-car-form.component";
|
|
||||||
|
|
||||||
import { useHistory } from "react-router-dom";
|
import { useHistory } from "react-router-dom";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import CourtesyCarFormComponent from "../../components/courtesy-car-form/courtesy-car-form.component";
|
||||||
|
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
||||||
|
import { INSERT_NEW_COURTESY_CAR } from "../../graphql/courtesy-car.queries";
|
||||||
import {
|
import {
|
||||||
setBreadcrumbs,
|
setBreadcrumbs,
|
||||||
setSelectedHeader,
|
setSelectedHeader,
|
||||||
} from "../../redux/application/application.actions";
|
} from "../../redux/application/application.actions";
|
||||||
import RbacWrapper from "../../components/rbac-wrapper/rbac-wrapper.component";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -37,12 +36,20 @@ export function CourtesyCarCreateContainer({
|
|||||||
variables: { courtesycar: { ...values, bodyshopid: bodyshop.id } },
|
variables: { courtesycar: { ...values, bodyshopid: bodyshop.id } },
|
||||||
});
|
});
|
||||||
|
|
||||||
notification["success"]({ message: t("courtesycars.successes.saved") });
|
if (!!result.errors) {
|
||||||
history.push(
|
notification["error"]({
|
||||||
`/manage/courtesycars/${result.data.insert_courtesycars.returning[0].id}`
|
message: t("courtesycars.errors.saving", {
|
||||||
);
|
message: JSON.stringify(result.errors),
|
||||||
|
}),
|
||||||
console.log("error");
|
});
|
||||||
|
} else {
|
||||||
|
form.resetFields();
|
||||||
|
form.resetFields();
|
||||||
|
notification["success"]({ message: t("courtesycars.successes.saved") });
|
||||||
|
history.push(
|
||||||
|
`/manage/courtesycars/${result.data.insert_courtesycars.returning[0].id}`
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user