import { connect } from "react-redux"; import { selectCurrentEmployee } from "../../redux/employee/employee.selectors"; 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 { createStructuredSelector } from "reselect"; import { useTranslation } from "react-i18next"; import ClockedinListItem from "../time-ticket-items/clockedin-list-item.component"; import { useState } from "react"; // import { setTmTicketJobId } from "../../redux/app/app.actions"; const mapStateToProps = createStructuredSelector({ //technician: selectTechnician, currentEmployee: selectCurrentEmployee, }); // const mapDispatchToProps = (dispatch) => ({ // setTmTicketJobId: (jobId) => dispatch(setTmTicketJobId(jobId)), // }); export function EmployeeClockedInList({ currentEmployee }) { const [jobData, setJobData] = useState(null); console.info( "EmployeeClockedInList, QUERY_ACTIVE_TIME_TICKETS called.", currentEmployee ); const { t } = useTranslation(); const { loading, error, data, refetch } = useQuery( QUERY_ACTIVE_TIME_TICKETS, { variables: { employeeId: currentEmployee?.technician?.id, }, skip: !currentEmployee?.technician, onCompleted:setJobData } ); if (loading) return ; if (error) return ; const onRefresh = async () => { return refetch(); }; return ( {jobData ? ( You are already clocked in to the following job(s): } renderItem={(object) => ( )} // setTmTicketJobId={setTmTicketJobId} /> ) : null} //
// {data.timetickets.length > 0 ? ( //
// // {t("timetickets.labels.alreadyclockedon")} // // ( // // // {`${ // ticket.job.ro_number || t("general.labels.na") // } ${OwnerNameDisplayFunction(ticket.job)}`} // // } // actions={[ // , // ]} // > //
// {` // ${ticket.job.v_model_yr || ""} ${ // ticket.job.v_make_desc || "" // } ${ticket.job.v_model_desc || ""}`} //
// // {ticket.clockon} // // // {ticket.cost_center === "timetickets.labels.shift" // ? t(ticket.cost_center) // : ticket.cost_center} // //
//
// )} // >
//
// ) : null} //
); } export default connect(mapStateToProps, null)(EmployeeClockedInList);