Added shift clock framework + login on tech console BOD-97 BOD-188
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
import React, { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { UPDATE_TIME_TICKET } from "../../graphql/timetickets.queries";
|
||||
|
||||
import axios from "axios";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
@@ -27,6 +27,7 @@ export function TechClockOffButton({
|
||||
technician,
|
||||
timeTicketId,
|
||||
completedCallback,
|
||||
isShiftTicket,
|
||||
otherBtnProps,
|
||||
}) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -40,7 +41,10 @@ export function TechClockOffButton({
|
||||
const result = await updateTimeticket({
|
||||
variables: {
|
||||
timeticketId: timeTicketId,
|
||||
timeticket: { clockoff: new Date(), ...values },
|
||||
timeticket: {
|
||||
clockoff: (await axios.post("/utils/time")).data,
|
||||
...values,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -64,65 +68,76 @@ export function TechClockOffButton({
|
||||
<div>
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
layout='vertical'
|
||||
onFinish={handleFinish}
|
||||
initialValues={{
|
||||
cost_center: technician ? technician.cost_center : null,
|
||||
}}
|
||||
>
|
||||
cost_center: isShiftTicket
|
||||
? "timetickets.labels.shift"
|
||||
: technician
|
||||
? technician.cost_center
|
||||
: null,
|
||||
}}>
|
||||
{!isShiftTicket ? (
|
||||
<div>
|
||||
<Form.Item
|
||||
label={t("timetickets.fields.actualhrs")}
|
||||
name='actualhrs'
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}>
|
||||
<InputNumber precision={1} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("timetickets.fields.productivehrs")}
|
||||
name='productivehrs'
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}>
|
||||
<InputNumber precision={1} />
|
||||
</Form.Item>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<Form.Item
|
||||
label={t("timetickets.fields.actualhrs")}
|
||||
name="actualhrs"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber precision={1} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
label={t("timetickets.fields.productivehrs")}
|
||||
name="productivehrs"
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<InputNumber precision={1} />
|
||||
</Form.Item>
|
||||
<Form.Item
|
||||
name="cost_center"
|
||||
name='cost_center'
|
||||
label={t("timetickets.fields.cost_center")}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: t("general.validation.required"),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Select>
|
||||
{bodyshop.md_responsibility_centers.costs.map((i, idx) => (
|
||||
<Select.Option key={idx} value={i.name}>
|
||||
{i.name}
|
||||
]}>
|
||||
<Select disabled={isShiftTicket}>
|
||||
{isShiftTicket ? (
|
||||
<Select.Option value='timetickets.labels.shift'>
|
||||
{t("timetickets.labels.shift")}
|
||||
</Select.Option>
|
||||
))}
|
||||
) : (
|
||||
bodyshop.md_responsibility_centers.costs.map((i, idx) => (
|
||||
<Select.Option key={idx} value={i.name}>
|
||||
{i.name}
|
||||
</Select.Option>
|
||||
))
|
||||
)}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Button type="primary" htmlType="submit">
|
||||
<Button type='primary' htmlType='submit' loading={loading}>
|
||||
{t("general.actions.save")}
|
||||
</Button>
|
||||
<TechJobClockoutDelete timeTicketId={timeTicketId} />
|
||||
<TechJobClockoutDelete completedCallback={completedCallback} timeTicketId={timeTicketId} />
|
||||
</Form>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
|
||||
return (
|
||||
<Popover content={overlay} trigger="click">
|
||||
<Popover content={overlay} trigger='click'>
|
||||
<Button loading={loading} {...otherBtnProps}>
|
||||
{t("timetickets.actions.clockout")}
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user