added some checks for bugs

This commit is contained in:
jfrye122
2023-05-19 15:48:44 -04:00
parent 05e3613db9
commit 4dc054b1e3
6 changed files with 133 additions and 44 deletions

View File

@@ -1,5 +1,11 @@
import React, { useState } from "react";
import { View, Text, StyleSheet, ScrollView } from "react-native";
import React, { useCallback, useState } from "react";
import {
View,
Text,
StyleSheet,
ScrollView,
RefreshControl,
} from "react-native";
import axios from "axios";
import { connect } from "react-redux";
import { employeeGetRatesStart } from "../../redux/employee/employee.actions";
@@ -24,7 +30,7 @@ import {
selectCurrentTimeTicketJobId,
} from "../../redux/timetickets/timetickets.selectors";
import moment from "moment";
import EmployeeClockedInList from "../time-ticket-lists/employee-clockedin-list.component";
import EmployeeClockedInList from "../time-ticket-lists/employee-clockedin-list.component";
import { useNavigation } from "@react-navigation/native";
import { INSERT_NEW_TIME_TICKET } from "../../graphql/timetickets.queries";
@@ -62,22 +68,14 @@ export function ScreenTimeTicketBrowser({
const [currentSJobId, setCurrentSJobId] = useState(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const [insertTimeTicket] = useMutation(INSERT_NEW_TIME_TICKET,{
const [refreshing, setRefreshing] = useState(false);
const [insertTimeTicket] = useMutation(INSERT_NEW_TIME_TICKET, {
refetchQueries: ["QUERY_ACTIVE_TIME_TICKETS"],
});
const [jobCount, setJobCount] = useState(0);
// const { error, data } = useQuery(QUERY_EMPLOYEE_BY_ID, {
// variables: { id: currentEmployee.technician.id },
// });
// const signingErrorMsg = error ? (<ErrorDisplay errorMessage={error.message} />) : null;
// const signingErrorMsg = signingError ? (<ErrorDisplay errorMessage={signingError} />) : null;
// const wrapperSetCurrentSJobState = useCallback(
// (val) => {
// setCurrentSJobId(val);
// },
// [setCurrentSJobId]
// );
//test area
const handleFinish = async (values) => {
console.log("handleFinish called in ScreenTimeTicketBrowser");
setLoading(true);
@@ -133,6 +131,7 @@ export function ScreenTimeTicketBrowser({
const result = await insertTimeTicket(tempVariablesObj);
console.log("insertTimeTicket, result :", result);
setLoading(false);
if (!!result.errors) {
console.log("insertTimeTicket, result.error :", result.errors);
setError(JSON.stringify(result.errors));
@@ -144,14 +143,24 @@ export function ScreenTimeTicketBrowser({
setCurrentSJobId(null);
setCurrentSCC(null);
}
setLoading(false);
};
const onRefresh = useCallback(() => {
setRefreshing(true);
setTimeout(() => {
setRefreshing(false);
}, 2000);
}, []);
return (
<View style={localStyles.content}>
<ScrollView style={{flex:1}} contentContainerStyle={{ flexGrow: 1 }}>
<Card >
<ScrollView
style={{ flex: 1 }}
contentContainerStyle={{ flexGrow: 1 }}
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
}
>
<Card>
<JobIdSearchSelect
currentValue={currentSJobId}
onJobSelected={setCurrentSJobId}
@@ -170,10 +179,26 @@ export function ScreenTimeTicketBrowser({
<ErrorDisplay errorMessage={error.message} />
) : null}
</Card>
{/* <View style={{ flexGrow: 1, flex: 1 }}>
<EmployeeClockedInList
technician={currentEmployee}
isRefresh={refreshing}
onRefresh={onRefresh}
/>
</View> */}
</ScrollView>
<View style={{ flexGrow: 1, flex: 1 }}>
<EmployeeClockedInList
technician={currentEmployee}
isRefresh={refreshing}
/>
</View>
{/* <ScrollView style={{flex:1}} contentContainerStyle={{ flexGrow: 1 }} refreshControl={<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />} >
<View style={{ flexGrow: 1, flex:1 }}>
<EmployeeClockedInList technician={currentEmployee} />
<EmployeeClockedInList technician={currentEmployee} handleRefresh={refreshing} onRefresh={onRefresh} />
</View>
</ScrollView> */}
</View>
);
}