Time Ticket modal update fix + add ticket list IO-682 IO-683
This commit is contained in:
@@ -1,11 +1,15 @@
|
|||||||
|
import { useQuery } from "@apollo/react-hooks";
|
||||||
import { Form, Input, InputNumber, Select } from "antd";
|
import { Form, Input, InputNumber, Select } from "antd";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { GET_LINE_TICKET_BY_PK } from "../../graphql/jobs-lines.queries";
|
||||||
import EmployeeSearchSelect from "../employee-search-select/employee-search-select.component";
|
import EmployeeSearchSelect from "../employee-search-select/employee-search-select.component";
|
||||||
import FormDatePicker from "../form-date-picker/form-date-picker.component";
|
import FormDatePicker from "../form-date-picker/form-date-picker.component";
|
||||||
import JobSearchSelect from "../job-search-select/job-search-select.component";
|
import JobSearchSelect from "../job-search-select/job-search-select.component";
|
||||||
import LaborAllocationsTable from "../labor-allocations-table/labor-allocations-table.component";
|
import LaborAllocationsTable from "../labor-allocations-table/labor-allocations-table.component";
|
||||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||||
|
import LoadingSkeleton from "../loading-skeleton/loading-skeleton.component";
|
||||||
|
import TimeTicketList from "../time-ticket-list/time-ticket-list.component";
|
||||||
|
|
||||||
export default function TimeTicketModalComponent({
|
export default function TimeTicketModalComponent({
|
||||||
form,
|
form,
|
||||||
@@ -29,16 +33,7 @@ export default function TimeTicketModalComponent({
|
|||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<JobSearchSelect
|
<JobSearchSelect options={roAutoCompleteOptions} />
|
||||||
options={roAutoCompleteOptions}
|
|
||||||
onBlur={() => {
|
|
||||||
if (form.getFieldValue("jobid") !== null) {
|
|
||||||
loadLineTicketData({
|
|
||||||
variables: { id: form.getFieldValue("jobid") },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("timetickets.fields.date")}
|
label={t("timetickets.fields.date")}
|
||||||
@@ -141,15 +136,37 @@ export default function TimeTicketModalComponent({
|
|||||||
<Input disabled />
|
<Input disabled />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
<Form.Item shouldUpdate>
|
<Form.Item dependencies={["jobid"]}>
|
||||||
{() => (
|
{() => (
|
||||||
<LaborAllocationsTable
|
<LaborAllocationContainer
|
||||||
jobId={form.getFieldValue("jobid")}
|
jobid={form.getFieldValue("jobid") || null}
|
||||||
joblines={lineTicketData.joblines}
|
|
||||||
timetickets={lineTicketData.timetickets}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function LaborAllocationContainer({ jobid }) {
|
||||||
|
console.log("jobid", jobid);
|
||||||
|
const { loading, data: lineTicketData } = useQuery(GET_LINE_TICKET_BY_PK, {
|
||||||
|
variables: { id: jobid },
|
||||||
|
skip: !jobid,
|
||||||
|
});
|
||||||
|
if (loading) return <LoadingSkeleton />;
|
||||||
|
if (!lineTicketData) return null;
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<LaborAllocationsTable
|
||||||
|
jobId={jobid}
|
||||||
|
joblines={lineTicketData.joblines}
|
||||||
|
timetickets={lineTicketData.timetickets}
|
||||||
|
/>
|
||||||
|
<TimeTicketList
|
||||||
|
loading={loading}
|
||||||
|
timetickets={lineTicketData.timetickets}
|
||||||
|
techConsole
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useLazyQuery, useMutation, useQuery } from "@apollo/react-hooks";
|
import { useMutation, useQuery } from "@apollo/react-hooks";
|
||||||
import { Button, Form, Modal, notification } from "antd";
|
import { Button, Form, Modal, notification } from "antd";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
@@ -6,7 +6,6 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { QUERY_ACTIVE_EMPLOYEES } from "../../graphql/employees.queries";
|
import { QUERY_ACTIVE_EMPLOYEES } from "../../graphql/employees.queries";
|
||||||
import { GET_LINE_TICKET_BY_PK } from "../../graphql/jobs-lines.queries";
|
|
||||||
import {
|
import {
|
||||||
INSERT_NEW_TIME_TICKET,
|
INSERT_NEW_TIME_TICKET,
|
||||||
UPDATE_TIME_TICKET,
|
UPDATE_TIME_TICKET,
|
||||||
@@ -39,10 +38,6 @@ export function TimeTicketModalContainer({
|
|||||||
skip: !timeTicketModal.visible,
|
skip: !timeTicketModal.visible,
|
||||||
});
|
});
|
||||||
|
|
||||||
const [loadLineTicketData, { data: lineTicketData }] = useLazyQuery(
|
|
||||||
GET_LINE_TICKET_BY_PK
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleFinish = (values) => {
|
const handleFinish = (values) => {
|
||||||
const emps = EmployeeAutoCompleteData.employees.filter(
|
const emps = EmployeeAutoCompleteData.employees.filter(
|
||||||
(e) => e.id === values.employeeid
|
(e) => e.id === values.employeeid
|
||||||
@@ -215,10 +210,6 @@ export function TimeTicketModalContainer({
|
|||||||
employeeAutoCompleteOptions={
|
employeeAutoCompleteOptions={
|
||||||
EmployeeAutoCompleteData && EmployeeAutoCompleteData.employees
|
EmployeeAutoCompleteData && EmployeeAutoCompleteData.employees
|
||||||
}
|
}
|
||||||
loadLineTicketData={loadLineTicketData}
|
|
||||||
lineTicketData={
|
|
||||||
lineTicketData ? lineTicketData : { joblines: [], timetickets: [] }
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|||||||
Reference in New Issue
Block a user