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

@@ -5,6 +5,7 @@ import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { createStructuredSelector } from "reselect"; import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors";
import { selectTechnician } from "../../redux/tech/tech.selectors";
import { alphaSort } from "../../utils/sorters"; import { alphaSort } from "../../utils/sorters";
import LaborAllocationsAdjustmentEdit from "../labor-allocations-adjustment-edit/labor-allocations-adjustment-edit.component"; import LaborAllocationsAdjustmentEdit from "../labor-allocations-adjustment-edit/labor-allocations-adjustment-edit.component";
import "./labor-allocations-table.styles.scss"; import "./labor-allocations-table.styles.scss";
@@ -12,6 +13,7 @@ import { CalculateAllocationsTotals } from "./labor-allocations-table.utility";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop, bodyshop: selectBodyshop,
technician: selectTechnician,
}); });
export function LaborAllocationsTable({ export function LaborAllocationsTable({
@@ -20,6 +22,7 @@ export function LaborAllocationsTable({
timetickets, timetickets,
bodyshop, bodyshop,
adjustments, adjustments,
technician,
}) { }) {
const { t } = useTranslation(); const { t } = useTranslation();
const [totals, setTotals] = useState([]); const [totals, setTotals] = useState([]);
@@ -83,13 +86,15 @@ export function LaborAllocationsTable({
render: (text, record) => ( render: (text, record) => (
<Space wrap> <Space wrap>
{record.adjustments.toFixed(1)} {record.adjustments.toFixed(1)}
<LaborAllocationsAdjustmentEdit {!technician && (
jobId={jobId} <LaborAllocationsAdjustmentEdit
adjustments={adjustments} jobId={jobId}
mod_lbr_ty={record.opcode} adjustments={adjustments}
> mod_lbr_ty={record.opcode}
<EditFilled /> >
</LaborAllocationsAdjustmentEdit> <EditFilled />
</LaborAllocationsAdjustmentEdit>
)}
</Space> </Space>
), ),
}, },

View File

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

View File

@@ -67,6 +67,7 @@ export function TechClockedInList({ technician }) {
} }
actions={[ actions={[
<TechClockOffButton <TechClockOffButton
jobId={ticket.jobid}
timeTicketId={ticket.id} timeTicketId={ticket.id}
completedCallback={refetch} completedCallback={refetch}
/>, />,

View File

@@ -145,7 +145,7 @@ export default function TimeTicketModalComponent({
); );
} }
function LaborAllocationContainer({ jobid }) { export function LaborAllocationContainer({ jobid }) {
const { loading, data: lineTicketData } = useQuery(GET_LINE_TICKET_BY_PK, { const { loading, data: lineTicketData } = useQuery(GET_LINE_TICKET_BY_PK, {
variables: { id: jobid }, variables: { id: jobid },
skip: !jobid, skip: !jobid,

View File

@@ -32,17 +32,20 @@ export default function TimeTicketShiftActive({ timetickets, refetch }) {
title={t(ticket.memo)} title={t(ticket.memo)}
actions={[ actions={[
<TechClockOffButton <TechClockOffButton
jobId={ticket.jobid}
timeTicketId={ticket.id} timeTicketId={ticket.id}
completedCallback={refetch} completedCallback={refetch}
isShiftTicket isShiftTicket
/>, />,
]}> ]}
>
<DataLabel label={t("timetickets.fields.clockon")}> <DataLabel label={t("timetickets.fields.clockon")}>
<DateTimeFormatter>{ticket.clockon}</DateTimeFormatter> <DateTimeFormatter>{ticket.clockon}</DateTimeFormatter>
</DataLabel> </DataLabel>
</Card> </Card>
</List.Item> </List.Item>
)}></List> )}
></List>
</div> </div>
) : null} ) : null}
</div> </div>

View File

@@ -10,6 +10,7 @@ export const QUERY_TICKETS_BY_JOBID = gql`
productivehrs productivehrs
id id
memo memo
jobid
employee { employee {
employee_number employee_number
first_name first_name
@@ -116,9 +117,9 @@ export const QUERY_ACTIVE_TIME_TICKETS = gql`
clockon clockon
memo memo
cost_center cost_center
jobid
job { job {
id id
ownr_fn ownr_fn
ownr_ln ownr_ln
ownr_co_nm ownr_co_nm
@@ -146,9 +147,9 @@ export const QUERY_ACTIVE_SHIFT_TIME_TICKETS = gql`
id id
clockon clockon
memo memo
jobid
job { job {
id id
ownr_fn ownr_fn
ownr_ln ownr_ln
ownr_co_nm ownr_co_nm