update files
This commit is contained in:
@@ -5,12 +5,6 @@ import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
|
||||
|
||||
|
||||
// const mapDispatchToProps = (dispatch) => ({
|
||||
// signOut: () => dispatch(employeeSignOut()),
|
||||
// });
|
||||
|
||||
export function AddTimeTicketButton() {
|
||||
|
||||
const navigation = useNavigation();
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
import { FlatList, RefreshControl, StyleSheet, Text, View } from "react-native";
|
||||
import React from "react";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { Button, List, Searchbar } from "react-native-paper";
|
||||
import { useState } from "react";
|
||||
import { SEARCH_JOBS_FOR_AUTOCOMPLETE } from "../../graphql/jobs.queries";
|
||||
import { useQuery } from "@apollo/client";
|
||||
|
||||
function JobIdSearchAndList({ onClose }) {
|
||||
const jobSrchNotExported = true;
|
||||
const jobSrchNotInvoiced = false;
|
||||
const jobSrchConvertedOnly = false;
|
||||
|
||||
const jobSrchCurrentValue = { id: "temp", ro_number: "Temporary Storage" };
|
||||
const jobSrchOnSetCurrentValue = (e) => {
|
||||
console.info("onSetCurrentValue was called", e);
|
||||
};
|
||||
const jobSrchCurrentValueId = "temp";
|
||||
const jobSrchOnSetCurrentValueId = () => {
|
||||
console.info("onSetCurrentValueId was called");
|
||||
};
|
||||
|
||||
const [searchText, setSearchText] = useState(null);
|
||||
const [loading2, setLoading2] = useState(null);
|
||||
|
||||
console.log("onClose :", onClose);
|
||||
// const showModal = () => setVisible(true);
|
||||
const close = onClose ? onClose : () => console.info("todo add close"); //setVisible(false);
|
||||
const onChangeSearch = (query) => {
|
||||
console.log("onChangeSearch text:", query);
|
||||
setSearchText(query);
|
||||
};
|
||||
const onRefresh = async () => {
|
||||
//7/18
|
||||
setLoading2(true);
|
||||
// refetch();
|
||||
setTimeout(() => {
|
||||
setLoading2(false);
|
||||
}, 1000);
|
||||
|
||||
//7/17
|
||||
// setRefreshing(true);
|
||||
// console.log(" ");
|
||||
// console.log(" ");
|
||||
// console.log(" ");
|
||||
// console.log(" ");
|
||||
// console.log(" ");
|
||||
// console.log("onRefresh was called");
|
||||
|
||||
// console.log("data:", data);
|
||||
// refetch({
|
||||
// notInvoiced: jobSrchNotInvoiced,
|
||||
// notExported: jobSrchNotExported,
|
||||
// isConverted: jobSrchConvertedOnly,
|
||||
// search: searchText,
|
||||
// });
|
||||
};
|
||||
|
||||
const { loading, error, data, refetch } = useQuery(
|
||||
SEARCH_JOBS_FOR_AUTOCOMPLETE,
|
||||
{
|
||||
// fetchPolicy: "cache-and-network",
|
||||
variables: {
|
||||
search: searchText,
|
||||
...(jobSrchConvertedOnly || jobSrchNotExported
|
||||
? {
|
||||
...(jobSrchConvertedOnly ? { isConverted: true } : {}),
|
||||
...(jobSrchNotExported ? { notExported: true } : {}),
|
||||
...(jobSrchNotInvoiced ? { notInvoiced: true } : {}),
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
skip: !!!searchText,
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only",
|
||||
}
|
||||
);
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
}}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
margin: 8,
|
||||
}}
|
||||
>
|
||||
<Button onPress={() => close()}>
|
||||
<Ionicons name="ios-arrow-back" size={32} color="dodgerblue" />
|
||||
</Button>
|
||||
<Searchbar
|
||||
style={{ flex: 1 }}
|
||||
onChangeText={(text) => onChangeSearch(text)}
|
||||
value={searchText}
|
||||
/>
|
||||
</View>
|
||||
<FlatList
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={loading2} onRefresh={onRefresh} />
|
||||
}
|
||||
// data={[{ id: "temp", ro_number: "Temporary Storage" }, ...jobs]}
|
||||
data={data?.search_jobs}
|
||||
keyExtractor={(item) => item.id}
|
||||
renderItem={(object) => (
|
||||
<List.Item
|
||||
onPress={() => {
|
||||
// jobSrchOnSetCurrentValue(object.item);
|
||||
// jobSrchOnSetCurrentValueId(object.item.id);
|
||||
hideModal();
|
||||
setSearchText("");
|
||||
}}
|
||||
left={() => {
|
||||
if (object.item.id !== jobSrchCurrentValueId) return null;
|
||||
return (
|
||||
<Ionicons
|
||||
name="ios-checkmark-circle"
|
||||
size={24}
|
||||
color="dodgerblue"
|
||||
style={{ alignSelf: "center" }}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
titleStyle={{
|
||||
...(object.item.id === jobSrchCurrentValueId
|
||||
? { color: "dodgerblue" }
|
||||
: {}),
|
||||
}}
|
||||
title={`${
|
||||
object.item.ro_number ? `${object.item.ro_number} ` : ``
|
||||
}${object.item.ownr_fn || ""} ${object.item.ownr_ln || ""}${
|
||||
object.item.v_model_yr ? `- ${object.item.v_model_yr}` : ""
|
||||
}${object.item.v_make_desc ? `- ${object.item.v_make_desc}` : ""}${
|
||||
object.item.v_model_desc ? `- ${object.item.v_model_desc}` : ""
|
||||
}`}
|
||||
key={object.item.id}
|
||||
/>
|
||||
)}
|
||||
ListEmptyComponent={
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
padding: 10,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Text>No Data</Text>
|
||||
</View>
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export default JobIdSearchAndList;
|
||||
|
||||
const styles = StyleSheet.create({});
|
||||
@@ -8,10 +8,7 @@ import { connect } from "react-redux";
|
||||
import { SEARCH_JOBS_FOR_AUTOCOMPLETE } from "../../graphql/jobs.queries";
|
||||
import ErrorDisplay from "../error-display/error-display.component";
|
||||
import _ from "lodash";
|
||||
import { useCallback } from "react";
|
||||
import { useRef } from "react";
|
||||
import { useEffect } from "react";
|
||||
|
||||
import { useCallback,useRef, useEffect } from "react";
|
||||
|
||||
const useIsMounted = () => {
|
||||
const isMounted = useRef(false);
|
||||
@@ -38,7 +35,7 @@ export function JobSearchAndSelectModal(props) {
|
||||
const jobSrchCurrentValue =
|
||||
props?.currentValue !== undefined
|
||||
? props.currentValue
|
||||
: { id: "temp", ro_number: "No Selection" };
|
||||
: { id:"temp", ro_number:t("selectjobid.labels.noselection") };
|
||||
const jobSrchOnSetCurrentValue =
|
||||
props?.onSetCurrentValue !== undefined
|
||||
? props.onSetCurrentValue
|
||||
@@ -84,7 +81,6 @@ export function JobSearchAndSelectModal(props) {
|
||||
const inputSearch = useRef(null);
|
||||
const isMounted = useIsMounted();
|
||||
const setFocus = useCallback(() => {
|
||||
console.log("setFocus called",inputSearch);
|
||||
if (inputSearch.current) {
|
||||
inputSearch.current.focus();
|
||||
}
|
||||
@@ -183,7 +179,7 @@ export function JobSearchAndSelectModal(props) {
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Text>No Data</Text>
|
||||
<Text>{t("selectjobid.labels.nodata")}</Text>
|
||||
</View>
|
||||
}
|
||||
/>
|
||||
@@ -205,7 +201,7 @@ export function JobSearchAndSelectModal(props) {
|
||||
>
|
||||
{jobSrchCurrentValue?.id
|
||||
? jobSrchCurrentValue?.id === "temp"
|
||||
? t("mediabrowser.labels.temporarystorage")
|
||||
? t("selectjobid.labels.noselection")
|
||||
: `${
|
||||
jobSrchCurrentValue.ro_number
|
||||
? `${jobSrchCurrentValue.ro_number} - `
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button, Modal, Portal } from "react-native-paper";
|
||||
import JobIdSearchAndList from "./JobIdSearchAndList";
|
||||
import { useState } from "react";
|
||||
|
||||
function JobSearchModal() {
|
||||
const { t } = useTranslation();
|
||||
const [visible, setVisible] = useState(false);
|
||||
const showModal = () => setVisible(true);
|
||||
const hideModal = () => setVisible(false);
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<Portal>
|
||||
<Modal
|
||||
visible={visible}
|
||||
onDismiss={hideModal}
|
||||
// eslint-disable-next-line react-native/no-color-literals
|
||||
contentContainerStyle={{
|
||||
paddingTop: 20,
|
||||
paddingBottom: 20,
|
||||
margin: 12,
|
||||
flex: 1,
|
||||
backgroundColor: "white",
|
||||
}}
|
||||
>
|
||||
<JobIdSearchAndList onClose={hideModal}/>
|
||||
</Modal>
|
||||
</Portal>
|
||||
<Button mode="outlined" style={{ margin: 8 }} onPress={showModal}>
|
||||
{/* {jobSrchCurrentValueId
|
||||
? jobSrchCurrentValueId === "temp"
|
||||
? t("mediabrowser.labels.temporarystorage")
|
||||
: `${
|
||||
jobSrchCurrentValue.ro_number
|
||||
? `${jobSrchCurrentValue.ro_number} - `
|
||||
: ``
|
||||
}${jobSrchCurrentValue.ownr_fn || ""} ${
|
||||
jobSrchCurrentValue.ownr_ln || ""
|
||||
} - ${jobSrchCurrentValue.v_model_yr || ""} ${
|
||||
jobSrchCurrentValue.v_make_desc || ""
|
||||
} ${jobSrchCurrentValue.v_model_desc || ""}`
|
||||
: t("mediabrowser.labels.selectjob")} */}
|
||||
{t("mediabrowser.labels.selectjob")}
|
||||
</Button>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export default JobSearchModal;
|
||||
|
||||
const styles = StyleSheet.create({});
|
||||
@@ -1,28 +1,21 @@
|
||||
import React, { useState } from "react";
|
||||
import { useQuery } from "@apollo/client";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
import { StyleSheet, View } from "react-native";
|
||||
import { Dropdown } from "react-native-element-dropdown";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { QUERY_EMPLOYEE_BY_ID } from "../../graphql/employees.queries";
|
||||
import { useEffect } from "react";
|
||||
import { t } from "i18next";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop
|
||||
// timeTicketJobId: selectCurrentTimeTicketJobId,
|
||||
// timeTicketJob: selectCurrentTimeTicketJob,
|
||||
});
|
||||
|
||||
// const mapDispatchToProps = {};
|
||||
|
||||
export function CostCenterSelect(props) {
|
||||
const currentRatesNCostCenters = props.currentRatesNCostCenters;
|
||||
const bodyshop = props.bodyshop;
|
||||
|
||||
const [value, setValue] = useState(null);
|
||||
// const [value, setValue] = useState(null);
|
||||
const [isFocus, setIsFocus] = useState(false);
|
||||
const [costCenters, setCostCenters] = useState([]);
|
||||
|
||||
@@ -52,7 +45,6 @@ export function CostCenterSelect(props) {
|
||||
selectedTextStyle={styles.selectedTextStyle}
|
||||
inputSearchStyle={styles.inputSearchStyle}
|
||||
iconStyle={styles.iconStyle}
|
||||
|
||||
maxHeight={200}
|
||||
labelField="label"
|
||||
valueField="value"
|
||||
@@ -64,7 +56,6 @@ export function CostCenterSelect(props) {
|
||||
value={props.currentValue?.value}
|
||||
onChange={(item) => {
|
||||
props.onValueSelected(item);
|
||||
//setValue(item.value);
|
||||
setIsFocus(false);
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -2,8 +2,6 @@ import { View, Text, Platform } from "react-native";
|
||||
import React from "react";
|
||||
import { KeyboardAvoidingView } from "react-native";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { TouchableWithoutFeedback } from "react-native";
|
||||
import { Keyboard } from "react-native";
|
||||
|
||||
const KeyboardAvoidingComponent = ({ children }) => {
|
||||
return (
|
||||
@@ -12,9 +10,7 @@ const KeyboardAvoidingComponent = ({ children }) => {
|
||||
behavior={Platform.OS === "ios" ? "padding":"height" }
|
||||
style={styles.container}
|
||||
>
|
||||
{/* <TouchableWithoutFeedback onPress={Keyboard.dismiss}> */}
|
||||
<View style={styles.inner}>{children}</View>
|
||||
{/* </TouchableWithoutFeedback> */}
|
||||
<View style={styles.inner}>{children}</View>
|
||||
</KeyboardAvoidingView>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -130,18 +130,11 @@ const TimeTicketBrowserStackNavigator = connect(
|
||||
const appState = useRef(AppState.currentState);
|
||||
useEffect(() => {
|
||||
const subscription = AppState.addEventListener("change", (nextAppState) => {
|
||||
// console.log("oldAppState", appState.current);
|
||||
// console.log("nextAppState", nextAppState);
|
||||
// if ( appState.current.match(/inactive|background/) && nextAppState === "active"
|
||||
// ) { console.log("App has come to the foreground"); //signOut(); }
|
||||
// if (appState.current.match(/active/) && nextAppState === "inactive") {
|
||||
// console.log("App is about to be inactive");
|
||||
// }
|
||||
if (
|
||||
appState.current.match(/active|inactive/) &&
|
||||
nextAppState === "background"
|
||||
) {
|
||||
// console.log("App is about to be background");
|
||||
//App is about to be background
|
||||
signOut();
|
||||
}
|
||||
// if ( appState.current.match(/inactive/)) { console.log("App has come to the inactive"); }
|
||||
|
||||
@@ -41,7 +41,7 @@ import { INSERT_NEW_TIME_TICKET } from "../../graphql/timetickets.queries";
|
||||
import { useMutation, useQuery } from "@apollo/client";
|
||||
import { QUERY_ACTIVE_TIME_TICKETS } from "../../graphql/timetickets.queries";
|
||||
|
||||
import EmployeeClockedInList from "../time-ticket-lists/employee-clockedin-list.component";
|
||||
// import EmployeeClockedInList from "../time-ticket-lists/employee-clockedin-list.component";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import ClockedinListItem from "../time-ticket-items/clockedin-list-item.component";
|
||||
import SignOutButton from "../Buttons/employee-sign-out-button.component";
|
||||
@@ -89,7 +89,6 @@ export function ScreenTimeTicketBrowser({
|
||||
const [curSelClockIntoJob, setCurSelClockIntoJob] = useState(null);
|
||||
|
||||
const handleFinish = async (values) => {
|
||||
// console.log("handleFinish called in ScreenTimeTicketBrowser");
|
||||
setLoadingClockIn(true);
|
||||
setError(null);
|
||||
|
||||
@@ -131,15 +130,11 @@ export function ScreenTimeTicketBrowser({
|
||||
],
|
||||
},
|
||||
};
|
||||
// console.info("INSERT_NEW_TIME_TICKET, variables for clockin. : ",tempVariablesObj?.variables?.timeTicketInput[0] );
|
||||
const result = await insertTimeTicket(tempVariablesObj);
|
||||
// console.log("insertTimeTicket, result :", result);
|
||||
setLoadingClockIn(false);
|
||||
if (!!result.errors) {
|
||||
// console.log("insertTimeTicket, result.error :", result.errors);
|
||||
setError(JSON.stringify(result.errors));
|
||||
} else {
|
||||
// console.log("insertTimeTicket, result. :", result.data);
|
||||
setCurSelClockIntoJob(null);
|
||||
setCurrentSCC(null);
|
||||
}
|
||||
@@ -150,7 +145,7 @@ export function ScreenTimeTicketBrowser({
|
||||
refetch();
|
||||
setTimeout(() => {
|
||||
setRefreshing(false);
|
||||
}, 1000);
|
||||
}, 500);
|
||||
}, []);
|
||||
|
||||
const [itemState, setItemState] = useState({
|
||||
@@ -179,7 +174,6 @@ export function ScreenTimeTicketBrowser({
|
||||
);
|
||||
|
||||
if (loadingATT) {
|
||||
// console.log("loadingATT : ");
|
||||
setItemState((itemState) => ({
|
||||
...itemState,
|
||||
content: <ActivityIndicator color="dodgerblue" size="large" />,
|
||||
@@ -187,14 +181,12 @@ export function ScreenTimeTicketBrowser({
|
||||
return;
|
||||
}
|
||||
if (errorATT) {
|
||||
// console.error("ErrorATT : ",errorATT);
|
||||
setItemState((itemState) => ({
|
||||
...itemState,
|
||||
content: <ErrorDisplay errorMessage={errorATT.message} />,
|
||||
}));
|
||||
return;
|
||||
}
|
||||
// console.log({ itemState: !!itemState });
|
||||
|
||||
return (
|
||||
<View style={styles.cardBackground}>
|
||||
@@ -306,7 +298,7 @@ const MyItem = ({ itemState, style }) => {
|
||||
) : !!itemState?.content ? (
|
||||
itemState.content
|
||||
) : (
|
||||
<Text>No Data</Text>
|
||||
<Text>{t("timeticketbrowser.labels.nodata")}</Text>
|
||||
)}
|
||||
</Card.Content>
|
||||
</Card>
|
||||
|
||||
@@ -6,10 +6,8 @@ import { createStructuredSelector } from "reselect";
|
||||
import { signOutStart } from "../../redux/user/user.actions";
|
||||
import { employeeSignOut } from "../../redux/employee/employee.actions";
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//currentUser: selectCurrentUser
|
||||
});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
//setUserLanguage: language => dispatch(setUserLanguage(language))
|
||||
signOutStart: () => dispatch(signOutStart()),
|
||||
signOut: () => dispatch(employeeSignOut()),
|
||||
});
|
||||
|
||||
@@ -13,18 +13,13 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
});
|
||||
|
||||
export function ClockedinListItem({ setTmTicketJobIdRedux, ticket }) {
|
||||
// console.log("ClockedinListItem, ticket:",ticket);
|
||||
const { t } = useTranslation();
|
||||
const navigation = useNavigation();
|
||||
|
||||
const makeNavToTimeTicketClockOff = () => (
|
||||
// console.log("makeNavToTimeTicketClockOff, checkHasDispatchCall:",setTmTicketJobIdRedux),
|
||||
setTmTicketJobIdRedux(ticket.job.id),
|
||||
navigation.navigate("TimeTicketClockOff", {
|
||||
// jobId: ticket.jobid, //item.id,
|
||||
timeTicketId:ticket.id,
|
||||
// handleOnDone:handleRefresh,
|
||||
//completedCallback: refetch,
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -335,7 +335,8 @@
|
||||
},
|
||||
"labels": {
|
||||
"loggedinemployee": "Logged in Employee",
|
||||
"clockintojob": "Clock In"
|
||||
"clockintojob": "Clock In",
|
||||
"nodata":"No Data"
|
||||
},
|
||||
"errors": {
|
||||
"missingvalues": "Please make sure all fields have a value."
|
||||
@@ -484,7 +485,9 @@
|
||||
"labels": {
|
||||
"placeholder": "RO #",
|
||||
"selectedplaceholder": "...",
|
||||
"searchplaceholder": "Search..."
|
||||
"searchplaceholder": "Search...",
|
||||
"noselection":"No Selection",
|
||||
"nodata":"No Data"
|
||||
}
|
||||
},
|
||||
"selectcostcenter":{
|
||||
|
||||
@@ -335,7 +335,8 @@
|
||||
},
|
||||
"labels": {
|
||||
"loggedinemployee": "",
|
||||
"clockintojob": ""
|
||||
"clockintojob": "",
|
||||
"nodata":""
|
||||
},
|
||||
"errors": {
|
||||
"missingvalues": ""
|
||||
@@ -484,7 +485,9 @@
|
||||
"labels": {
|
||||
"placeholder": "",
|
||||
"selectedplaceholder": "...",
|
||||
"searchplaceholder": ""
|
||||
"searchplaceholder": "",
|
||||
"noselection":"",
|
||||
"nodata":""
|
||||
}
|
||||
},
|
||||
"selectcostcenter":{
|
||||
|
||||
@@ -335,7 +335,8 @@
|
||||
},
|
||||
"labels": {
|
||||
"loggedinemployee": "",
|
||||
"clockintojob": ""
|
||||
"clockintojob": "",
|
||||
"nodata":""
|
||||
},
|
||||
"errors": {
|
||||
"missingvalues": ""
|
||||
@@ -484,7 +485,9 @@
|
||||
"labels": {
|
||||
"placeholder": "",
|
||||
"selectedplaceholder": "...",
|
||||
"searchplaceholder": ""
|
||||
"searchplaceholder": "",
|
||||
"noselection":"",
|
||||
"nodata":""
|
||||
}
|
||||
},
|
||||
"selectcostcenter":{
|
||||
|
||||
Reference in New Issue
Block a user