added some checks for bugs
This commit is contained in:
@@ -4,32 +4,49 @@ import { QUERY_ACTIVE_TIME_TICKETS } from "../../graphql/timetickets.queries";
|
||||
import { ActivityIndicator } from "react-native-paper";
|
||||
import ErrorDisplay from "../error-display/error-display.component";
|
||||
import { View, Text, FlatList, RefreshControl } from "react-native";
|
||||
import { useQuery } from "@apollo/client";
|
||||
import { useMutation, useQuery } from "@apollo/client";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import ClockedinListItem from "../time-ticket-items/clockedin-list-item.component";
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
// import { setTmTicketJobId } from "../../redux/app/app.actions";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
//technician: selectTechnician,
|
||||
currentEmployee: selectCurrentEmployee,
|
||||
// updateJobs: selectUpdateJobs
|
||||
});
|
||||
// const mapDispatchToProps = (dispatch) => ({
|
||||
// setTmTicketJobId: (jobId) => dispatch(setTmTicketJobId(jobId)),
|
||||
// });
|
||||
|
||||
export function EmployeeClockedInList({ currentEmployee }) {
|
||||
|
||||
const [jobData, setJobData] = useState(null);
|
||||
export function EmployeeClockedInList({ currentEmployee, isRefresh }) {
|
||||
const [refreshKey, setRefreshKey] = useState(isRefresh);
|
||||
const [jobData, setJobData] = useState(data);
|
||||
console.info(
|
||||
"EmployeeClockedInList, QUERY_ACTIVE_TIME_TICKETS called.",
|
||||
currentEmployee
|
||||
);
|
||||
|
||||
// console.info(
|
||||
// "EmployeeClockedInList, isRefresh :",
|
||||
// isRefresh
|
||||
// );
|
||||
const { t } = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
// async function fetchData(){
|
||||
// // const result = await getUsers();
|
||||
// // setData(result);
|
||||
// console.log("teste: ", result);
|
||||
// }
|
||||
// fetchData();
|
||||
console.log("useEffect: ", isRefresh);
|
||||
// setRefreshKey(isRefresh);
|
||||
|
||||
}, [isRefresh]);
|
||||
|
||||
const { loading, error, data, refetch } = useQuery(
|
||||
QUERY_ACTIVE_TIME_TICKETS,
|
||||
{
|
||||
@@ -37,16 +54,21 @@ export function EmployeeClockedInList({ currentEmployee }) {
|
||||
employeeId: currentEmployee?.technician?.id,
|
||||
},
|
||||
skip: !currentEmployee?.technician,
|
||||
onCompleted:setJobData
|
||||
onCompleted:setJobData,
|
||||
onRefresh:{onRefresh}
|
||||
}
|
||||
);
|
||||
if (loading) return <ActivityIndicator color="dodgerblue" size="large" />;
|
||||
if (error) return <ErrorDisplay errorMessage={error.message} />;
|
||||
|
||||
const onRefresh = async () => {
|
||||
console.info("EmployeeClockedInList, onRefresh.");
|
||||
return refetch();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1, flexGrow: 1 }}>
|
||||
{jobData ? (
|
||||
@@ -62,7 +84,7 @@ export function EmployeeClockedInList({ currentEmployee }) {
|
||||
renderItem={(object) => (
|
||||
<ClockedinListItem
|
||||
ticket={object.item}
|
||||
handleRefresh={onRefresh}
|
||||
// handleRefresh={onRefresh}
|
||||
/>
|
||||
)}
|
||||
// setTmTicketJobId={setTmTicketJobId}
|
||||
|
||||
Reference in New Issue
Block a user