Merged in feature/IO-2392-Ticket-Date-UTCOffset (pull request #965)

IO-2392 Ticket Date UTCOffset
This commit is contained in:
Allan Carr
2023-09-08 00:22:28 +00:00
2 changed files with 18 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ import { useMutation } from "@apollo/client";
import { Button, Card, Form, notification, Space } from "antd"; import { Button, Card, Form, notification, Space } from "antd";
import axios from "axios"; import axios from "axios";
import moment from "moment"; import moment from "moment";
import momenttz from "moment-timezone";
import React, { useState } from "react"; import React, { useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
@@ -49,14 +50,20 @@ export function TechClockInContainer({
const handleFinish = async (values) => { const handleFinish = async (values) => {
setLoading(true); setLoading(true);
const theTime = (await axios.post("/utils/time")).data; const theTime = (await axios.post("/utils/time")).data;
const result = await insertTimeTicket({ const result = await insertTimeTicket({
variables: { variables: {
timeTicketInput: [ timeTicketInput: [
{ {
bodyshopid: bodyshop.id, bodyshopid: bodyshop.id,
employeeid: technician.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), clockon: moment(theTime),
jobid: values.jobid, jobid: values.jobid,
cost_center: values.cost_center, cost_center: values.cost_center,

View File

@@ -2,6 +2,7 @@ import { useMutation } from "@apollo/client";
import { Button, Form, Space, notification } from "antd"; import { Button, Form, Space, notification } from "antd";
import axios from "axios"; import axios from "axios";
import moment from "moment"; import moment from "moment";
import momenttz from "moment-timezone";
import React, { useMemo, useState } from "react"; import React, { useMemo, useState } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { connect } from "react-redux"; import { connect } from "react-redux";
@@ -68,7 +69,14 @@ export function TimeTicektShiftContainer({
employeeid: isTechConsole ? technician.id : employeeId, employeeid: isTechConsole ? technician.id : employeeId,
cost_center: "timetickets.labels.shift", cost_center: "timetickets.labels.shift",
clockon: theTime, 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, memo: values.memo,
created_by: isTechConsole created_by: isTechConsole
? currentUser.email.concat( ? currentUser.email.concat(