diff --git a/components/screen-time-ticket-browser/screen-time-ticket-browser.component.jsx b/components/screen-time-ticket-browser/screen-time-ticket-browser.component.jsx
index 8403287..3144116 100644
--- a/components/screen-time-ticket-browser/screen-time-ticket-browser.component.jsx
+++ b/components/screen-time-ticket-browser/screen-time-ticket-browser.component.jsx
@@ -12,6 +12,7 @@ import {
} from "../../redux/employee/employee.selectors";
import { Button, Card } from "react-native-paper";
+import { QUERY_ACTIVE_TIME_TICKETS } from "../../graphql/timetickets.queries";
//temp
import { useQuery } from "@apollo/client";
import ErrorDisplay from "../error-display/error-display.component";
@@ -61,7 +62,9 @@ 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 [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 },
diff --git a/components/time-ticket-items/clockedin-list-item.component.jsx b/components/time-ticket-items/clockedin-list-item.component.jsx
index d46d08e..467feab 100644
--- a/components/time-ticket-items/clockedin-list-item.component.jsx
+++ b/components/time-ticket-items/clockedin-list-item.component.jsx
@@ -11,7 +11,8 @@ const mapDispatchToProps = (dispatch) => ({
setTmTicketJobIdRedux: (jobId) => dispatch(setTmTicketJobId(jobId)),
});
-export function ClockedinListItem({ setTmTicketJobIdRedux, ticket }) {
+export function ClockedinListItem({ setTmTicketJobIdRedux, ticket, handleRefresh }) {
+ console.log("makeNavToTimeTicketClockOff, handleRefresh:",handleRefresh);
const { t } = useTranslation();
const navigation = useNavigation();
@@ -21,6 +22,7 @@ export function ClockedinListItem({ setTmTicketJobIdRedux, ticket }) {
navigation.navigate("TimeTicketClockOff", {
// jobId: ticket.jobid, //item.id,
timeTicketId:ticket.id,
+ handleOnDone:handleRefresh,
//completedCallback: refetch,
})
);
diff --git a/components/time-ticket-lists/employee-clockedin-list.component.jsx b/components/time-ticket-lists/employee-clockedin-list.component.jsx
index 9a1b86d..55414c8 100644
--- a/components/time-ticket-lists/employee-clockedin-list.component.jsx
+++ b/components/time-ticket-lists/employee-clockedin-list.component.jsx
@@ -1,8 +1,5 @@
import { connect } from "react-redux";
-import {
- selectCurrentEmployee,
- selectTechnician,
-} from "../../redux/employee/employee.selectors";
+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";
@@ -11,31 +8,36 @@ 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,
+ //technician: selectTechnician,
+ currentEmployee: selectCurrentEmployee,
});
// const mapDispatchToProps = (dispatch) => ({
// setTmTicketJobId: (jobId) => dispatch(setTmTicketJobId(jobId)),
// });
-export function EmployeeClockedInList({ technician }) {
- console.info("EmployeeClockedInList, QUERY_ACTIVE_TIME_TICKETS called.");
+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: technician?.id,
+ employeeId: currentEmployee?.technician?.id,
},
- skip: !technician,
- fetchPolicy: "network-only",
- nextFetchPolicy: "network-only",
+ skip: !currentEmployee?.technician,
+ onCompleted:setJobData
}
);
if (loading) return ;
@@ -46,18 +48,23 @@ export function EmployeeClockedInList({ technician }) {
};
return (
-
- {data.timetickets.length > 0 ? (
+
+ {jobData ? (
You are already clocked in to the following job(s):
}
- renderItem={(object) => }
+ renderItem={(object) => (
+
+ )}
// setTmTicketJobId={setTmTicketJobId}
/>
diff --git a/components/time-ticket/screen-time-ticket-clockoff.component.jsx b/components/time-ticket/screen-time-ticket-clockoff.component.jsx
index e9623ca..8c0bd44 100644
--- a/components/time-ticket/screen-time-ticket-clockoff.component.jsx
+++ b/components/time-ticket/screen-time-ticket-clockoff.component.jsx
@@ -22,6 +22,7 @@ import axios from "axios";
import { useNavigation } from "@react-navigation/native";
// import { selectCurrentTimeTicketJobId } from "../../redux/timetickets/timetickets.selectors";
+import { QUERY_ACTIVE_TIME_TICKETS } from "../../graphql/timetickets.queries";
const mapStateToProps = createStructuredSelector({
currentEmployee: selectCurrentEmployee,
currentRatesNCostCenters: selectRates,
@@ -40,20 +41,20 @@ export function TimeTicketClockOff({
route,
}) {
const navigation = useNavigation();
- const { timeTicketId } = route.params;
+ const { timeTicketId, handleOnDone } = route.params;
// console.log("TimeTicketClockOff, timeTicketId :", timeTicketId);
- // console.log( "TimeTicketClockOff, currentTmTicketJobId :", currentTmTicketJobId );
+ console.log( "TimeTicketClockOff, handleOnDone :", handleOnDone );
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
const [currentSCC, setCurrentSCC] = useState(null);
- const [updateTimeticket] = useMutation(UPDATE_TIME_TICKET);
+ const [updateTimeticket] = useMutation(UPDATE_TIME_TICKET,
+ {refetchQueries: ["QUERY_ACTIVE_TIME_TICKETS"]});
const handleFinish = async (values) => {
logImEXEvent("TimeTicketClockOff_handleFinish");
- // console.log("TimeTicketClockOff, values.cost_center?.value :", currentSCC);
if (
!!values.actualhours &&
diff --git a/redux/employee/employee.sagas.js b/redux/employee/employee.sagas.js
index 34ddfe6..9b2fddf 100644
--- a/redux/employee/employee.sagas.js
+++ b/redux/employee/employee.sagas.js
@@ -57,17 +57,19 @@ export function* onEmployeeSignInSuccessSaga() {
export function* updateEmployeeWithEmployeeId({ payload }) {
try {
const employeeId = payload.id;
+ console.log("updateEmployeeWithEmployeeId",employeeId);
// logImEXEvent("redux_update_employee_with_employee_id_attempt", employeeId);
const result = yield client.query({ query: QUERY_EMPLOYEE_BY_ID,
variables: {
id: employeeId,
- }
+ },
+ skip: !employeeId
});
- const { employees_by_pk } = result.data;
+ const { employees_by_pk } = result?.data;
if (employees_by_pk) {
yield put(employeeGetRatesSuccess(employees_by_pk));
} else {
- yield put(employeeGetRatesFailure(result.error));
+ yield put(employeeGetRatesFailure(result?.error));
}
} catch (error) {
yield put(employeeGetRatesFailure(error));