update files
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Formik } from "formik";
|
||||
import React, { useEffect, useState, useRef, useCallback } from "react";
|
||||
import React, { useState, useRef, useCallback } from "react";
|
||||
import { StyleSheet, Text, View, ScrollView, FlatList } from "react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -8,8 +8,6 @@ import {
|
||||
Button,
|
||||
TextInput,
|
||||
Card,
|
||||
Headline,
|
||||
Subheading,
|
||||
} from "react-native-paper";
|
||||
import CostCenterSelect from "../Selects/select-cost-center";
|
||||
import {
|
||||
@@ -26,14 +24,9 @@ import { useMutation } from "@apollo/client";
|
||||
import { selectCurrentTmTicketJobId } from "../../redux/app/app.selectors";
|
||||
import ErrorDisplay from "../error-display/error-display.component";
|
||||
import { timeTicketClockOutStart } from "../../redux/timetickets/timetickets.actions";
|
||||
import { logImEXEvent } from "../../firebase/firebase.analytics";
|
||||
import axios from "axios";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import styles from "../styles";
|
||||
import StyleRepeater from "../style-repeater/style-repeater";
|
||||
// import { selectCurrentTimeTicketJobId } from "../../redux/timetickets/timetickets.selectors";
|
||||
|
||||
import { QUERY_ACTIVE_TIME_TICKETS } from "../../graphql/timetickets.queries";
|
||||
|
||||
import { RefreshControl } from "react-native";
|
||||
|
||||
@@ -57,17 +50,11 @@ export function TimeTicketClockOff({
|
||||
route,
|
||||
}) {
|
||||
const costCenterDiff = useRef(0);
|
||||
|
||||
const setCostCenterDiff = (value) => {
|
||||
countRef.current = val;
|
||||
// console.log(`Button clicked ${countRef.current} times`);
|
||||
};
|
||||
|
||||
const navigation = useNavigation();
|
||||
const { timeTicketId } = route.params;
|
||||
// console.log("TimeTicketClockOff, timeTicketId :", timeTicketId);
|
||||
// console.log( "TimeTicketClockOff, handleOnDone :", handleOnDone );
|
||||
|
||||
const { t } = useTranslation();
|
||||
const [loadingClockOut, setLoadingClockOut] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -79,30 +66,23 @@ export function TimeTicketClockOff({
|
||||
});
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
logImEXEvent("TimeTicketClockOff_handleFinish");
|
||||
|
||||
if (
|
||||
!!values.actualhours &&
|
||||
!!values.productivehours &&
|
||||
!!currentSCC?.value
|
||||
) {
|
||||
if (isNaN(values.actualhours) | isNaN(values.productivehours)) {
|
||||
// console.log("actual hours is NAN!");
|
||||
setLoadingClockOut(false);
|
||||
setError({ message: t("timeticketclockoff.errors.nan") });
|
||||
return;
|
||||
}
|
||||
setError(null);
|
||||
// console.log("all have values:");
|
||||
} else {
|
||||
// console.log("missing values!");
|
||||
setLoadingClockOut(false);
|
||||
setLoadingClockOut(false);
|
||||
setError({ message: t("timeticketclockoff.errors.missingvalues") });
|
||||
return;
|
||||
}
|
||||
// console.log("TimeTicketClockOff, currentRestrictClaimableHoursFlag :", currentRestrictClaimableHoursFlag);
|
||||
if (!!currentRestrictClaimableHoursFlag) {
|
||||
// console.log("TimeTicketClockOff, currentRestrictClaimableHoursFlag I am here:", currentRestrictClaimableHoursFlag);
|
||||
if (values.productivehours > costCenterDiff.current) {
|
||||
setLoadingClockOut(false);
|
||||
setError({
|
||||
@@ -145,23 +125,15 @@ export function TimeTicketClockOff({
|
||||
},
|
||||
},
|
||||
};
|
||||
// console.log("TimeTicketClockOff, tempcallobj :", tempcallobj);
|
||||
|
||||
//after obj is good add below to make call
|
||||
|
||||
setLoadingClockOut(true);
|
||||
const result = await updateTimeticket(tempcallobj);
|
||||
|
||||
//after call results are retuning add handling below for cases
|
||||
// console.log("updateTimeticket, result :", result);
|
||||
setLoadingClockOut(false);
|
||||
if (!!result.errors) {
|
||||
// console.log("updateTimeticket, result.error :", result.errors);
|
||||
setError(JSON.stringify(result.errors));
|
||||
} else {
|
||||
// console.log("updateTimeticket, result :", result.data);
|
||||
navigation.goBack();
|
||||
}
|
||||
//if (completedCallback) completedCallback();
|
||||
};
|
||||
|
||||
const onRefresh = useCallback(() => {
|
||||
@@ -169,7 +141,7 @@ export function TimeTicketClockOff({
|
||||
// refetch();
|
||||
setTimeout(() => {
|
||||
setLoading(false);
|
||||
}, 1000);
|
||||
}, 500);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { Formik } from "formik";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { StyleSheet, Text, View, ScrollView, RefreshControl } from "react-native";
|
||||
import React, { useRef, useState,useCallback } from "react";
|
||||
import { StyleSheet, Text, View, ScrollView, RefreshControl,FlatList } from "react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { Button, TextInput, Card } from "react-native-paper";
|
||||
import CostCenterSelect from "../Selects/select-cost-center";
|
||||
import { JobIdSearchSelect } from "../Selects/select-job-id";
|
||||
import DateTimePickerModal from "react-native-modal-datetime-picker";
|
||||
import {
|
||||
selectCurrentEmployee,
|
||||
@@ -17,21 +16,15 @@ import {
|
||||
selectBodyshop,
|
||||
selectRestrictClaimableHoursFlag,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import { useCallback } from "react";
|
||||
// import LaborAllocationsTable from "../labor-allocations-table/labor-allocations-table.component";
|
||||
import LaborAllocationsTable from "../labor-allocations-table/labor-allocations-table.component";
|
||||
|
||||
import ErrorDisplay from "../error-display/error-display.component";
|
||||
import { INSERT_NEW_TIME_TICKET } from "../../graphql/timetickets.queries";
|
||||
import { useMutation } from "@apollo/client";
|
||||
import axios from "axios";
|
||||
import { logImEXEvent } from "../../firebase/firebase.analytics";
|
||||
import moment from "moment";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
|
||||
import styles from "../styles";
|
||||
import StyleRepeater from "../style-repeater/style-repeater";
|
||||
import { FlatList } from "react-native";
|
||||
import JobSearchAndSelectModal from "../Modals/JobSearchAndSelectModal";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
@@ -41,7 +34,6 @@ const mapStateToProps = createStructuredSelector({
|
||||
currentEmployeeFullName: selectEmployeeFullName,
|
||||
currentRestrictClaimableHoursFlag: selectRestrictClaimableHoursFlag,
|
||||
});
|
||||
// const mapDispatchToProps = (dispatch) => ({});
|
||||
|
||||
export function TimeTicketCreate({
|
||||
currentEmployee,
|
||||
@@ -76,15 +68,8 @@ export function TimeTicketCreate({
|
||||
const [insertTicket] = useMutation(INSERT_NEW_TIME_TICKET);
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
logImEXEvent("handleFinish_called_in_TimeTicketCreate");
|
||||
// console.log("handleFinish called in TimeTicketCreate");
|
||||
setError(null);
|
||||
setLoadingCreate(true);
|
||||
|
||||
// console.log("insertTicket, currentSCC :", currentSCC);
|
||||
// console.log("insertTicket, currentSCC :", currentSJobId);
|
||||
// console.log("insertTicket, values :", values);
|
||||
|
||||
if (
|
||||
!!currentSCC?.value &&
|
||||
!!curSelClockIntoJob?.id &&
|
||||
@@ -110,7 +95,6 @@ export function TimeTicketCreate({
|
||||
}
|
||||
|
||||
if (!!currentRestrictClaimableHoursFlag) {
|
||||
// console.log("TimeTicketClockOff, currentRestrictClaimableHoursFlag I am here:", currentRestrictClaimableHoursFlag);
|
||||
if (values.productivehours > costCenterDiff.current) {
|
||||
setLoadingCreate(false);
|
||||
setError({
|
||||
@@ -119,7 +103,7 @@ export function TimeTicketCreate({
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const tempVariablesObj = {
|
||||
variables: {
|
||||
timeTicketInput: [
|
||||
@@ -157,19 +141,8 @@ export function TimeTicketCreate({
|
||||
],
|
||||
},
|
||||
};
|
||||
// clockoff: undefined,
|
||||
// clockon: undefined,
|
||||
// memo: undefined,
|
||||
|
||||
// console.log("insertTicket, tempVariablesObj. :", tempVariablesObj?.variables?.timeTicketInput[0]);
|
||||
|
||||
//after obj is good add below to make call
|
||||
|
||||
const result = await insertTicket(tempVariablesObj); //.catch(handleMutationError);
|
||||
|
||||
// console.log(" result : ", result);
|
||||
// //after call results are retuning add handling below for cases
|
||||
// console.log("insertTicket, result :", result?.data?.insert_timetickets?.returning[0]);
|
||||
const result = await insertTicket(tempVariablesObj);
|
||||
setLoadingCreate(false);
|
||||
if (!!result.errors) {
|
||||
// console.log("insertTicket, result.error :", result.errors);
|
||||
@@ -185,7 +158,7 @@ export function TimeTicketCreate({
|
||||
// refetch();
|
||||
setTimeout(() => {
|
||||
setLoading(false);
|
||||
}, 1000);
|
||||
}, 500);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
@@ -206,20 +179,13 @@ export function TimeTicketCreate({
|
||||
>
|
||||
{({ handleChange, handleBlur, handleSubmit, values }) => (
|
||||
<View style={localStyles.topTimeTicketContainer}>
|
||||
{/* <JobIdSearchSelect
|
||||
currentValue={currentSJobId}
|
||||
onJobSelected={setCurrentSJobId}
|
||||
convertedOnly={true}
|
||||
<JobSearchAndSelectModal
|
||||
currentValue={curSelClockIntoJob}
|
||||
onSetCurrentValue={setCurSelClockIntoJob}
|
||||
notExported={!currentBodyshop.tt_allow_post_to_invoiced}
|
||||
notInvoiced={!currentBodyshop.tt_allow_post_to_invoiced}
|
||||
/> */}
|
||||
<JobSearchAndSelectModal
|
||||
currentValue={curSelClockIntoJob}
|
||||
onSetCurrentValue={setCurSelClockIntoJob}
|
||||
notExported={!currentBodyshop.tt_allow_post_to_invoiced}
|
||||
notInvoiced={!currentBodyshop.tt_allow_post_to_invoiced}
|
||||
convertedOnly={true}
|
||||
/>
|
||||
convertedOnly={true}
|
||||
/>
|
||||
<Button
|
||||
mode="outlined"
|
||||
title="TicketDatePickerButton"
|
||||
|
||||
Reference in New Issue
Block a user