BOD-58 WIP For testing classes. No success.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import JobsCreateComponent from "./jobs-create.component";
|
||||
import { Form } from "antd";
|
||||
import { Form, notification } from "antd";
|
||||
import JobCreateContext from "./jobs-create.context";
|
||||
import { useMutation, useLazyQuery } from "@apollo/react-hooks";
|
||||
import { INSERT_NEW_JOB } from "../../graphql/jobs.queries";
|
||||
@@ -8,19 +8,26 @@ import { QUERY_OWNER_FOR_JOB_CREATION } from "../../graphql/owners.queries";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
});
|
||||
export default connect(mapStateToProps, null)(JobsCreateContainer);
|
||||
|
||||
function JobsCreateContainer({ bodyshop }) {
|
||||
const { t } = useTranslation();
|
||||
const contextState = useState({
|
||||
vehicle: { new: false, search: "", selectedid: null },
|
||||
owner: { new: false, search: "", selectedid: null },
|
||||
job: null
|
||||
job: null,
|
||||
created: false,
|
||||
error: null,
|
||||
newJobId: null,
|
||||
newJobEstNum: null
|
||||
});
|
||||
const [form] = Form.useForm();
|
||||
const [state] = contextState;
|
||||
const [state, setState] = contextState;
|
||||
const [insertJob] = useMutation(INSERT_NEW_JOB);
|
||||
const [loadOwner, RemoteOwnerData] = useLazyQuery(
|
||||
QUERY_OWNER_FOR_JOB_CREATION
|
||||
@@ -37,7 +44,22 @@ function JobsCreateContainer({ bodyshop }) {
|
||||
|
||||
const runInsertJob = job => {
|
||||
console.log("Job To Save", job);
|
||||
insertJob({ variables: { job: job } });
|
||||
insertJob({ variables: { job: job } })
|
||||
.then(resp => {
|
||||
setState({
|
||||
...state,
|
||||
created: true,
|
||||
error: null,
|
||||
newJobId: resp.data.insert_jobs.returning[0].id,
|
||||
newJobEstNum: resp.data.insert_jobs.returning[0].est_number
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.creating", { error: error })
|
||||
});
|
||||
setState({ ...state, error: error });
|
||||
});
|
||||
};
|
||||
|
||||
const handleFinish = values => {
|
||||
|
||||
Reference in New Issue
Block a user