added refresing of calls for active tickets
This commit is contained in:
@@ -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 },
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
);
|
||||
|
||||
@@ -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 <ActivityIndicator color="dodgerblue" size="large" />;
|
||||
@@ -46,18 +48,23 @@ export function EmployeeClockedInList({ technician }) {
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={{ flex:1, flexGrow:1 }} >
|
||||
{data.timetickets.length > 0 ? (
|
||||
<View style={{ flex: 1, flexGrow: 1 }}>
|
||||
{jobData ? (
|
||||
<View>
|
||||
<Text style={{ paddingLeft: 12, paddingTop: 14 }}>
|
||||
You are already clocked in to the following job(s):
|
||||
</Text>
|
||||
<FlatList
|
||||
data={data.timetickets}
|
||||
data={jobData?.timetickets}
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={loading} onRefresh={onRefresh} />
|
||||
}
|
||||
renderItem={(object) => <ClockedinListItem ticket={object.item} />}
|
||||
renderItem={(object) => (
|
||||
<ClockedinListItem
|
||||
ticket={object.item}
|
||||
handleRefresh={onRefresh}
|
||||
/>
|
||||
)}
|
||||
// setTmTicketJobId={setTmTicketJobId}
|
||||
/>
|
||||
</View>
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user