diff --git a/client/src/components/tech-job-clock-in-form/tech-job-clock-in-form.container.jsx b/client/src/components/tech-job-clock-in-form/tech-job-clock-in-form.container.jsx index b3f3046f4..3d7c88635 100644 --- a/client/src/components/tech-job-clock-in-form/tech-job-clock-in-form.container.jsx +++ b/client/src/components/tech-job-clock-in-form/tech-job-clock-in-form.container.jsx @@ -2,6 +2,7 @@ import { useMutation } from "@apollo/client"; import { Button, Card, Form, notification, Space } from "antd"; import axios from "axios"; import moment from "moment"; +import momenttz from "moment-timezone"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -49,14 +50,20 @@ export function TechClockInContainer({ const handleFinish = async (values) => { setLoading(true); const theTime = (await axios.post("/utils/time")).data; - const result = await insertTimeTicket({ variables: { timeTicketInput: [ { bodyshopid: bodyshop.id, employeeid: technician.id, - date: moment(theTime).format("YYYY-MM-DD"), + date: + typeof bodyshop.timezone === "string" + ? momenttz.tz(theTime, bodyshop.timezone).format("YYYY-MM-DD") + : typeof bodyshop.timezone === "number" + ? moment(theTime) + .format("YYYY-MM-DD") + .utcOffset(bodyshop.timezone) + : moment(theTime).format("YYYY-MM-DD"), clockon: moment(theTime), jobid: values.jobid, cost_center: values.cost_center, diff --git a/client/src/components/time-ticket-shift-form/time-ticket-shift-form.container.jsx b/client/src/components/time-ticket-shift-form/time-ticket-shift-form.container.jsx index 6e2fc0b9b..8c3c3cd0d 100644 --- a/client/src/components/time-ticket-shift-form/time-ticket-shift-form.container.jsx +++ b/client/src/components/time-ticket-shift-form/time-ticket-shift-form.container.jsx @@ -2,6 +2,7 @@ import { useMutation } from "@apollo/client"; import { Button, Form, Space, notification } from "antd"; import axios from "axios"; import moment from "moment"; +import momenttz from "moment-timezone"; import React, { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -68,7 +69,14 @@ export function TimeTicektShiftContainer({ employeeid: isTechConsole ? technician.id : employeeId, cost_center: "timetickets.labels.shift", clockon: theTime, - date: theTime, + date: + typeof bodyshop.timezone === "string" + ? momenttz.tz(theTime, bodyshop.timezone).format("YYYY-MM-DD") + : typeof bodyshop.timezone === "number" + ? moment(theTime) + .utcOffset(bodyshop.timezone) + .format("YYYY-MM-DD") + : moment(theTime).format("YYYY-MM-DD"), memo: values.memo, created_by: isTechConsole ? currentUser.email.concat(