Resolve shift clock issues. IO-699
This commit is contained in:
@@ -1,17 +1,20 @@
|
|||||||
import { useMutation } from "@apollo/client";
|
import { useMutation } from "@apollo/client";
|
||||||
import { Button, Form, notification } from "antd";
|
import { Button, Form, notification } from "antd";
|
||||||
import React, { useState } from "react";
|
import axios from "axios";
|
||||||
|
import moment from "moment";
|
||||||
|
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";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { INSERT_NEW_TIME_TICKET } from "../../graphql/timetickets.queries";
|
import { INSERT_NEW_TIME_TICKET } from "../../graphql/timetickets.queries";
|
||||||
import { selectTechnician } from "../../redux/tech/tech.selectors";
|
import { selectTechnician } from "../../redux/tech/tech.selectors";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import {
|
||||||
|
selectBodyshop,
|
||||||
|
selectCurrentUser,
|
||||||
|
} from "../../redux/user/user.selectors";
|
||||||
import TimeTicektShiftComponent from "./time-ticket-shift-form.component";
|
import TimeTicektShiftComponent from "./time-ticket-shift-form.component";
|
||||||
import axios from "axios";
|
|
||||||
import moment from "moment";
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
//currentUser: selectCurrentUser
|
currentUser: selectCurrentUser,
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
technician: selectTechnician,
|
technician: selectTechnician,
|
||||||
});
|
});
|
||||||
@@ -22,6 +25,7 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
export function TimeTicektShiftContainer({
|
export function TimeTicektShiftContainer({
|
||||||
bodyshop,
|
bodyshop,
|
||||||
technician,
|
technician,
|
||||||
|
currentUser,
|
||||||
isTechConsole,
|
isTechConsole,
|
||||||
}) {
|
}) {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -29,6 +33,18 @@ export function TimeTicektShiftContainer({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const employeeId = useMemo(() => {
|
||||||
|
const assoc = bodyshop.associations.filter(
|
||||||
|
(a) => a.useremail === currentUser.email
|
||||||
|
)[0];
|
||||||
|
|
||||||
|
return assoc && assoc.user && assoc.user.employee && assoc.user.employee.id;
|
||||||
|
}, [bodyshop, currentUser.email]);
|
||||||
|
console.log(
|
||||||
|
"🚀 ~ file: time-ticket-shift-form.container.jsx ~ line 42 ~ employeeId",
|
||||||
|
employeeId
|
||||||
|
);
|
||||||
|
|
||||||
const handleFinish = async (values) => {
|
const handleFinish = async (values) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const theTime = moment((await axios.post("/utils/time")).data);
|
const theTime = moment((await axios.post("/utils/time")).data);
|
||||||
@@ -38,9 +54,7 @@ export function TimeTicektShiftContainer({
|
|||||||
timeTicketInput: [
|
timeTicketInput: [
|
||||||
{
|
{
|
||||||
bodyshopid: bodyshop.id,
|
bodyshopid: bodyshop.id,
|
||||||
employeeid: isTechConsole
|
employeeid: isTechConsole ? technician.id : employeeId,
|
||||||
? technician.id
|
|
||||||
: bodyshop.associations[0].user.employee.id,
|
|
||||||
cost_center: "timetickets.labels.shift",
|
cost_center: "timetickets.labels.shift",
|
||||||
clockon: theTime,
|
clockon: theTime,
|
||||||
date: theTime,
|
date: theTime,
|
||||||
|
|||||||
@@ -1,10 +1,13 @@
|
|||||||
import React from "react";
|
|
||||||
import { useQuery } from "@apollo/client";
|
import { useQuery } from "@apollo/client";
|
||||||
|
import React, { useMemo } from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { QUERY_ACTIVE_SHIFT_TIME_TICKETS } from "../../graphql/timetickets.queries";
|
import { QUERY_ACTIVE_SHIFT_TIME_TICKETS } from "../../graphql/timetickets.queries";
|
||||||
import { selectTechnician } from "../../redux/tech/tech.selectors";
|
import { selectTechnician } from "../../redux/tech/tech.selectors";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import {
|
||||||
|
selectBodyshop,
|
||||||
|
selectCurrentUser,
|
||||||
|
} from "../../redux/user/user.selectors";
|
||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from "../alert/alert.component";
|
||||||
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
import LoadingSpinner from "../loading-spinner/loading-spinner.component";
|
||||||
import TimeTicketShiftActive from "../time-ticket-shift-active/time-ticket-shift-active.component";
|
import TimeTicketShiftActive from "../time-ticket-shift-active/time-ticket-shift-active.component";
|
||||||
@@ -13,6 +16,7 @@ import TimeTicketShiftFormContainer from "../time-ticket-shift-form/time-ticket-
|
|||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
technician: selectTechnician,
|
technician: selectTechnician,
|
||||||
|
currentUser: selectCurrentUser,
|
||||||
});
|
});
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||||
@@ -21,15 +25,22 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
export function TimeTicketShiftContainer({
|
export function TimeTicketShiftContainer({
|
||||||
bodyshop,
|
bodyshop,
|
||||||
technician,
|
technician,
|
||||||
|
currentUser,
|
||||||
isTechConsole,
|
isTechConsole,
|
||||||
}) {
|
}) {
|
||||||
|
const employeeId = useMemo(() => {
|
||||||
|
const assoc = bodyshop.associations.filter(
|
||||||
|
(a) => a.useremail === currentUser.email
|
||||||
|
)[0];
|
||||||
|
|
||||||
|
return assoc && assoc.user && assoc.user.employee && assoc.user.employee.id;
|
||||||
|
}, [bodyshop, currentUser.email]);
|
||||||
|
|
||||||
const { loading, error, data, refetch } = useQuery(
|
const { loading, error, data, refetch } = useQuery(
|
||||||
QUERY_ACTIVE_SHIFT_TIME_TICKETS,
|
QUERY_ACTIVE_SHIFT_TIME_TICKETS,
|
||||||
{
|
{
|
||||||
variables: {
|
variables: {
|
||||||
employeeId: isTechConsole
|
employeeId: isTechConsole ? technician && technician.id : employeeId,
|
||||||
? technician.id
|
|
||||||
: bodyshop.associations[0].user.employee.id,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -58,7 +58,12 @@ export const logImEXEvent = (eventName, additionalParams, stateProp = null) => {
|
|||||||
null,
|
null,
|
||||||
...additionalParams,
|
...additionalParams,
|
||||||
};
|
};
|
||||||
console.log("%c[Analytics]", "background: tomato", eventName, eventParams);
|
console.log(
|
||||||
|
"%c[Analytics]",
|
||||||
|
"background-color: green ;font-weight:bold;",
|
||||||
|
eventName,
|
||||||
|
eventParams
|
||||||
|
);
|
||||||
analytics.logEvent(eventName, eventParams);
|
analytics.logEvent(eventName, eventParams);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ Sentry.init({
|
|||||||
"https://fd7e89369b6b4bdc9c6c4c9f22fa4ee4@o492140.ingest.sentry.io/5651027",
|
"https://fd7e89369b6b4bdc9c6c4c9f22fa4ee4@o492140.ingest.sentry.io/5651027",
|
||||||
integrations: [new Integrations.BrowserTracing()],
|
integrations: [new Integrations.BrowserTracing()],
|
||||||
environment: process.env || "development",
|
environment: process.env || "development",
|
||||||
|
enabled: process.env !== "development",
|
||||||
// We recommend adjusting this value in production, or using tracesSampler
|
// We recommend adjusting this value in production, or using tracesSampler
|
||||||
// for finer control
|
// for finer control
|
||||||
tracesSampleRate: 0.5,
|
tracesSampleRate: 0.5,
|
||||||
|
|||||||
Reference in New Issue
Block a user