Added shift clock framework + login on tech console BOD-97 BOD-188

This commit is contained in:
Patrick Fic
2020-07-16 10:17:23 -07:00
parent bf74d9a042
commit 6a8b59c7e6
67 changed files with 1791 additions and 217 deletions

View File

@@ -1,5 +1,6 @@
import { Button, Form, notification, Card } from "antd";
import React from "react";
import { Button, Card, Form, notification } from "antd";
import axios from "axios";
import React, { useState } from "react";
import { useMutation } from "react-apollo";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
@@ -16,29 +17,35 @@ const mapStateToProps = createStructuredSelector({
export function TechClockInContainer({ technician, bodyshop }) {
const [form] = Form.useForm();
const [loading, setLoading] = useState(false);
const [insertTimeTicket] = useMutation(INSERT_NEW_TIME_TICKET, {
refetchQueries: ["QUERY_ACTIVE_TIME_TICKETS"],
});
const { t } = useTranslation();
const handleFinish = async (values) => {
setLoading(true);
const theTime = (await axios.post("/utils/time")).data;
const result = await insertTimeTicket({
variables: {
timeTicketInput: {
employeeid: technician.id,
date: new Date(),
clockon: new Date(),
jobid: values.jobid,
cost_center: technician.cost_center,
ciecacode: Object.keys(
bodyshop.md_responsibility_centers.defaults.costs
).find((key) => {
return (
bodyshop.md_responsibility_centers.defaults.costs[key] ===
values.cost_center
);
}),
},
timeTicketInput: [
{
bodyshopid: bodyshop.id,
employeeid: technician.id,
date: theTime,
clockon: theTime,
jobid: values.jobid,
cost_center: technician.cost_center,
ciecacode: Object.keys(
bodyshop.md_responsibility_centers.defaults.costs
).find((key) => {
return (
bodyshop.md_responsibility_centers.defaults.costs[key] ===
values.cost_center
);
}),
},
],
},
});
@@ -53,13 +60,14 @@ export function TechClockInContainer({ technician, bodyshop }) {
message: t("timetickets.successes.clockedin"),
});
}
setLoading(false);
};
return (
<div>
<Card title={t("timetickets.labels.clockintojob")}>
<Form form={form} layout="vertical" onFinish={handleFinish}>
<Button type="primary" htmlType="submit">
<Form form={form} layout='vertical' onFinish={handleFinish}>
<Button type='primary' htmlType='submit' loading={loading}>
{t("timetickets.actions.clockin")}
</Button>
<TechClockInComponent form={form} />