IO-842 Add Time Ticekts to Clock Out button

This commit is contained in:
Patrick Fic
2021-04-07 12:48:22 -07:00
parent d997d535e3
commit bac671ff5c
6 changed files with 104 additions and 75 deletions

View File

@@ -1,5 +1,14 @@
import { useMutation } from "@apollo/client";
import { Button, Card, Form, notification, Popover, Select } from "antd";
import {
Button,
Card,
Col,
Form,
notification,
Popover,
Row,
Select,
} from "antd";
import axios from "axios";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
@@ -11,6 +20,7 @@ import { selectTechnician } from "../../redux/tech/tech.selectors";
import { selectBodyshop } from "../../redux/user/user.selectors";
import InputNumberCalculator from "../form-input-number-calculator/form-input-number-calculator.component";
import TechJobClockoutDelete from "../tech-job-clock-out-delete/tech-job-clock-out-delete.component";
import { LaborAllocationContainer } from "../time-ticket-modal/time-ticket-modal.component";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
@@ -20,6 +30,7 @@ const mapStateToProps = createStructuredSelector({
export function TechClockOffButton({
bodyshop,
technician,
jobId,
timeTicketId,
completedCallback,
isShiftTicket,
@@ -34,8 +45,6 @@ export function TechClockOffButton({
(e) => e.id === (technician && technician.id)
)[0];
console.log(emps && emps.rates);
const handleFinish = async (values) => {
logImEXEvent("tech_clock_out_job");
@@ -80,67 +89,77 @@ export function TechClockOffButton({
: null,
}}
>
{!isShiftTicket ? (
<div>
<Form.Item
label={t("timetickets.fields.actualhrs")}
name="actualhrs"
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<InputNumberCalculator precision={1} />
</Form.Item>
<Form.Item
label={t("timetickets.fields.productivehrs")}
name="productivehrs"
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<InputNumberCalculator precision={1} />
</Form.Item>
</div>
) : null}
<Row gutter={[16, 16]}>
<Col span={!isShiftTicket ? 8 : 24}>
{!isShiftTicket ? (
<div>
<Form.Item
label={t("timetickets.fields.actualhrs")}
name="actualhrs"
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<InputNumberCalculator precision={1} />
</Form.Item>
<Form.Item
label={t("timetickets.fields.productivehrs")}
name="productivehrs"
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<InputNumberCalculator precision={1} />
</Form.Item>
</div>
) : null}
<Form.Item
name="cost_center"
label={t("timetickets.fields.cost_center")}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<Select disabled={isShiftTicket}>
{isShiftTicket ? (
<Select.Option value="timetickets.labels.shift">
{t("timetickets.labels.shift")}
</Select.Option>
) : (
emps &&
emps.rates.map((item) => (
<Select.Option key={item.cost_center}>
{item.cost_center}
</Select.Option>
))
)}
</Select>
</Form.Item>
<Button type="primary" htmlType="submit" loading={loading}>
{t("general.actions.save")}
</Button>
<TechJobClockoutDelete
completedCallback={completedCallback}
timeTicketId={timeTicketId}
/>
<Form.Item
name="cost_center"
label={t("timetickets.fields.cost_center")}
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<Select disabled={isShiftTicket}>
{isShiftTicket ? (
<Select.Option value="timetickets.labels.shift">
{t("timetickets.labels.shift")}
</Select.Option>
) : (
emps &&
emps.rates.map((item) => (
<Select.Option key={item.cost_center}>
{item.cost_center}
</Select.Option>
))
)}
</Select>
</Form.Item>
<Button type="primary" htmlType="submit" loading={loading}>
{t("general.actions.save")}
</Button>
<TechJobClockoutDelete
completedCallback={completedCallback}
timeTicketId={timeTicketId}
/>
</Col>
{!isShiftTicket && (
<Col span={16}>
<LaborAllocationContainer jobid={jobId} />
</Col>
)}
</Row>
</Form>
</div>
</Card>