Removed enter to submit detail page. Added filtering for jobs lines.
This commit is contained in:
@@ -1,52 +1,83 @@
|
||||
import React from "react";
|
||||
import JobLinesComponent from "./job-lines.component";
|
||||
import { useQuery } from "@apollo/react-hooks";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import { Form, notification } from "antd";
|
||||
import { GET_JOB_LINES_BY_PK } from "../../graphql/jobs-lines.queries";
|
||||
import { notification } from "antd";
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { GET_JOB_LINES_BY_PK } from "../../graphql/jobs-lines.queries";
|
||||
import AlertComponent from "../alert/alert.component";
|
||||
import JobLinesComponent from "./job-lines.component";
|
||||
|
||||
export default Form.create({ name: "JobsDetailJobLines" })(
|
||||
function JobLinesContainer({ jobId, form }) {
|
||||
const { loading, error, data } = useQuery(GET_JOB_LINES_BY_PK, {
|
||||
variables: { id: jobId },
|
||||
fetchPolicy: "network-only"
|
||||
//export default Form.create({ name: "JobsDetailJobLines" })(
|
||||
|
||||
export default function JobLinesContainer({ jobId, form }) {
|
||||
const { loading, error, data } = useQuery(GET_JOB_LINES_BY_PK, {
|
||||
variables: { id: jobId },
|
||||
fetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
const [searchText, setSearchText] = useState("");
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleSubmit = e => {
|
||||
e.preventDefault();
|
||||
|
||||
form.validateFieldsAndScroll((err, values) => {
|
||||
if (err) {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.validationtitle"),
|
||||
description: t("jobs.errors.validation")
|
||||
});
|
||||
}
|
||||
if (!err) {
|
||||
console.log("Save the est lines!", values);
|
||||
// mutationUpdateJob({
|
||||
// variables: { jobId: data.jobs_by_pk.id, job: values }
|
||||
// }).then(r => {
|
||||
// notification["success"]({
|
||||
// message: t("jobs.successes.savetitle")
|
||||
// });
|
||||
// //TODO: Better way to reset the field decorators?
|
||||
// refetch().then(r => form.resetFields());
|
||||
// });
|
||||
}
|
||||
});
|
||||
const { t } = useTranslation();
|
||||
const handleSubmit = e => {
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
form.validateFieldsAndScroll((err, values) => {
|
||||
if (err) {
|
||||
notification["error"]({
|
||||
message: t("jobs.errors.validationtitle"),
|
||||
description: t("jobs.errors.validation")
|
||||
});
|
||||
}
|
||||
if (!err) {
|
||||
console.log("Save the est lines!", values);
|
||||
// mutationUpdateJob({
|
||||
// variables: { jobId: data.jobs_by_pk.id, job: values }
|
||||
// }).then(r => {
|
||||
// notification["success"]({
|
||||
// message: t("jobs.successes.savetitle")
|
||||
// });
|
||||
// //TODO: Better way to reset the field decorators?
|
||||
// refetch().then(r => form.resetFields());
|
||||
// });
|
||||
}
|
||||
});
|
||||
};
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
|
||||
if (error) return <AlertComponent message={error.message} type="error" />;
|
||||
|
||||
return (
|
||||
<JobLinesComponent
|
||||
loading={loading}
|
||||
jobLines={data && data.joblines ? data.joblines : null}
|
||||
handleSubmit={handleSubmit}
|
||||
form={form}
|
||||
/>
|
||||
);
|
||||
}
|
||||
);
|
||||
return (
|
||||
<JobLinesComponent
|
||||
loading={loading}
|
||||
jobLines={
|
||||
data && data.joblines
|
||||
? searchText
|
||||
? data.joblines.filter(
|
||||
jl =>
|
||||
jl.unq_seq
|
||||
?.toString()
|
||||
.toLowerCase()
|
||||
.includes(searchText.toLowerCase()) ||
|
||||
jl.line_desc
|
||||
?.toLowerCase()
|
||||
.includes(searchText.toLowerCase()) ||
|
||||
jl.part_type
|
||||
?.toLowerCase()
|
||||
.includes(searchText.toLowerCase()) ||
|
||||
jl.oem_partno
|
||||
?.toLowerCase()
|
||||
.includes(searchText.toLowerCase()) ||
|
||||
jl.op_code_desc
|
||||
?.toLowerCase()
|
||||
.includes(searchText.toLowerCase()) ||
|
||||
jl.db_price?.toString().includes(searchText.toLowerCase()) ||
|
||||
jl.act_price?.toString().includes(searchText.toLowerCase())
|
||||
)
|
||||
: data.joblines
|
||||
: null
|
||||
}
|
||||
handleSubmit={handleSubmit}
|
||||
form={form}
|
||||
setSearchText={setSearchText}
|
||||
/>
|
||||
);
|
||||
}
|
||||
//);
|
||||
|
||||
Reference in New Issue
Block a user