79 lines
2.4 KiB
JavaScript
79 lines
2.4 KiB
JavaScript
import { Divider, Form, Select } from "antd";
|
|
import React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { connect } from "react-redux";
|
|
import { createStructuredSelector } from "reselect";
|
|
import { selectTechnician } from "../../redux/tech/tech.selectors";
|
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
|
import JobSearchSelect from "../job-search-select/job-search-select.component";
|
|
import JobsDetailLaborContainer from "../jobs-detail-labor/jobs-detail-labor.container";
|
|
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
|
|
|
const mapStateToProps = createStructuredSelector({
|
|
bodyshop: selectBodyshop,
|
|
technician: selectTechnician,
|
|
});
|
|
|
|
export function TechClockInComponent({ form, bodyshop, technician }) {
|
|
const { t } = useTranslation();
|
|
const emps = bodyshop.employees.filter((e) => e.id === technician.id)[0];
|
|
return (
|
|
<div>
|
|
<LayoutFormRow grow noDivider>
|
|
<Form.Item
|
|
name="jobid"
|
|
label={t("jobs.fields.ro_number")}
|
|
rules={[
|
|
{
|
|
required: true,
|
|
//message: t("general.validation.required"),
|
|
},
|
|
]}
|
|
>
|
|
<JobSearchSelect
|
|
convertedOnly={!bodyshop.tt_allow_post_to_invoiced}
|
|
notExported={!bodyshop.tt_allow_post_to_invoiced}
|
|
/>
|
|
</Form.Item>
|
|
|
|
<Form.Item
|
|
name="cost_center"
|
|
label={t("timetickets.fields.cost_center")}
|
|
rules={[
|
|
{
|
|
required: true,
|
|
//message: t("general.validation.required"),
|
|
},
|
|
]}
|
|
>
|
|
<Select>
|
|
{emps &&
|
|
emps.rates.map((item) => (
|
|
<Select.Option key={item.cost_center}>
|
|
{item.cost_center}
|
|
</Select.Option>
|
|
))}
|
|
</Select>
|
|
</Form.Item>
|
|
</LayoutFormRow>
|
|
<Divider />
|
|
<Form.Item
|
|
shouldUpdate={(prevValues, curValues) =>
|
|
prevValues.jobid !== curValues.jobid
|
|
}
|
|
>
|
|
{() => {
|
|
if (!form.getFieldValue("jobid")) return null;
|
|
return (
|
|
<JobsDetailLaborContainer
|
|
jobId={form.getFieldValue("jobid")}
|
|
techConsole
|
|
/>
|
|
);
|
|
}}
|
|
</Form.Item>
|
|
</div>
|
|
);
|
|
}
|
|
export default connect(mapStateToProps, null)(TechClockInComponent);
|