added refresing of calls for active tickets
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
|||||||
} from "../../redux/employee/employee.selectors";
|
} from "../../redux/employee/employee.selectors";
|
||||||
import { Button, Card } from "react-native-paper";
|
import { Button, Card } from "react-native-paper";
|
||||||
|
|
||||||
|
import { QUERY_ACTIVE_TIME_TICKETS } from "../../graphql/timetickets.queries";
|
||||||
//temp
|
//temp
|
||||||
import { useQuery } from "@apollo/client";
|
import { useQuery } from "@apollo/client";
|
||||||
import ErrorDisplay from "../error-display/error-display.component";
|
import ErrorDisplay from "../error-display/error-display.component";
|
||||||
@@ -61,7 +62,9 @@ export function ScreenTimeTicketBrowser({
|
|||||||
const [currentSJobId, setCurrentSJobId] = useState(null);
|
const [currentSJobId, setCurrentSJobId] = useState(null);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState(null);
|
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 [jobCount, setJobCount] = useState(0);
|
||||||
// const { error, data } = useQuery(QUERY_EMPLOYEE_BY_ID, {
|
// const { error, data } = useQuery(QUERY_EMPLOYEE_BY_ID, {
|
||||||
// variables: { id: currentEmployee.technician.id },
|
// variables: { id: currentEmployee.technician.id },
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
setTmTicketJobIdRedux: (jobId) => dispatch(setTmTicketJobId(jobId)),
|
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 { t } = useTranslation();
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ export function ClockedinListItem({ setTmTicketJobIdRedux, ticket }) {
|
|||||||
navigation.navigate("TimeTicketClockOff", {
|
navigation.navigate("TimeTicketClockOff", {
|
||||||
// jobId: ticket.jobid, //item.id,
|
// jobId: ticket.jobid, //item.id,
|
||||||
timeTicketId:ticket.id,
|
timeTicketId:ticket.id,
|
||||||
|
handleOnDone:handleRefresh,
|
||||||
//completedCallback: refetch,
|
//completedCallback: refetch,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import {
|
import { selectCurrentEmployee } from "../../redux/employee/employee.selectors";
|
||||||
selectCurrentEmployee,
|
|
||||||
selectTechnician,
|
|
||||||
} from "../../redux/employee/employee.selectors";
|
|
||||||
import { QUERY_ACTIVE_TIME_TICKETS } from "../../graphql/timetickets.queries";
|
import { QUERY_ACTIVE_TIME_TICKETS } from "../../graphql/timetickets.queries";
|
||||||
import { ActivityIndicator } from "react-native-paper";
|
import { ActivityIndicator } from "react-native-paper";
|
||||||
import ErrorDisplay from "../error-display/error-display.component";
|
import ErrorDisplay from "../error-display/error-display.component";
|
||||||
@@ -11,19 +8,25 @@ import { useQuery } from "@apollo/client";
|
|||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import ClockedinListItem from "../time-ticket-items/clockedin-list-item.component";
|
import ClockedinListItem from "../time-ticket-items/clockedin-list-item.component";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
// import { setTmTicketJobId } from "../../redux/app/app.actions";
|
// import { setTmTicketJobId } from "../../redux/app/app.actions";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
technician: selectTechnician,
|
//technician: selectTechnician,
|
||||||
//currentEmployee: selectCurrentEmployee,
|
currentEmployee: selectCurrentEmployee,
|
||||||
});
|
});
|
||||||
// const mapDispatchToProps = (dispatch) => ({
|
// const mapDispatchToProps = (dispatch) => ({
|
||||||
// setTmTicketJobId: (jobId) => dispatch(setTmTicketJobId(jobId)),
|
// setTmTicketJobId: (jobId) => dispatch(setTmTicketJobId(jobId)),
|
||||||
// });
|
// });
|
||||||
|
|
||||||
export function EmployeeClockedInList({ technician }) {
|
export function EmployeeClockedInList({ currentEmployee }) {
|
||||||
console.info("EmployeeClockedInList, QUERY_ACTIVE_TIME_TICKETS called.");
|
|
||||||
|
const [jobData, setJobData] = useState(null);
|
||||||
|
console.info(
|
||||||
|
"EmployeeClockedInList, QUERY_ACTIVE_TIME_TICKETS called.",
|
||||||
|
currentEmployee
|
||||||
|
);
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -31,11 +34,10 @@ export function EmployeeClockedInList({ technician }) {
|
|||||||
QUERY_ACTIVE_TIME_TICKETS,
|
QUERY_ACTIVE_TIME_TICKETS,
|
||||||
{
|
{
|
||||||
variables: {
|
variables: {
|
||||||
employeeId: technician?.id,
|
employeeId: currentEmployee?.technician?.id,
|
||||||
},
|
},
|
||||||
skip: !technician,
|
skip: !currentEmployee?.technician,
|
||||||
fetchPolicy: "network-only",
|
onCompleted:setJobData
|
||||||
nextFetchPolicy: "network-only",
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if (loading) return <ActivityIndicator color="dodgerblue" size="large" />;
|
if (loading) return <ActivityIndicator color="dodgerblue" size="large" />;
|
||||||
@@ -46,18 +48,23 @@ export function EmployeeClockedInList({ technician }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{ flex:1, flexGrow:1 }} >
|
<View style={{ flex: 1, flexGrow: 1 }}>
|
||||||
{data.timetickets.length > 0 ? (
|
{jobData ? (
|
||||||
<View>
|
<View>
|
||||||
<Text style={{ paddingLeft: 12, paddingTop: 14 }}>
|
<Text style={{ paddingLeft: 12, paddingTop: 14 }}>
|
||||||
You are already clocked in to the following job(s):
|
You are already clocked in to the following job(s):
|
||||||
</Text>
|
</Text>
|
||||||
<FlatList
|
<FlatList
|
||||||
data={data.timetickets}
|
data={jobData?.timetickets}
|
||||||
refreshControl={
|
refreshControl={
|
||||||
<RefreshControl refreshing={loading} onRefresh={onRefresh} />
|
<RefreshControl refreshing={loading} onRefresh={onRefresh} />
|
||||||
}
|
}
|
||||||
renderItem={(object) => <ClockedinListItem ticket={object.item} />}
|
renderItem={(object) => (
|
||||||
|
<ClockedinListItem
|
||||||
|
ticket={object.item}
|
||||||
|
handleRefresh={onRefresh}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
// setTmTicketJobId={setTmTicketJobId}
|
// setTmTicketJobId={setTmTicketJobId}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import axios from "axios";
|
|||||||
import { useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
// import { selectCurrentTimeTicketJobId } from "../../redux/timetickets/timetickets.selectors";
|
// import { selectCurrentTimeTicketJobId } from "../../redux/timetickets/timetickets.selectors";
|
||||||
|
|
||||||
|
import { QUERY_ACTIVE_TIME_TICKETS } from "../../graphql/timetickets.queries";
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
currentEmployee: selectCurrentEmployee,
|
currentEmployee: selectCurrentEmployee,
|
||||||
currentRatesNCostCenters: selectRates,
|
currentRatesNCostCenters: selectRates,
|
||||||
@@ -40,20 +41,20 @@ export function TimeTicketClockOff({
|
|||||||
route,
|
route,
|
||||||
}) {
|
}) {
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
const { timeTicketId } = route.params;
|
const { timeTicketId, handleOnDone } = route.params;
|
||||||
// console.log("TimeTicketClockOff, timeTicketId :", timeTicketId);
|
// console.log("TimeTicketClockOff, timeTicketId :", timeTicketId);
|
||||||
// console.log( "TimeTicketClockOff, currentTmTicketJobId :", currentTmTicketJobId );
|
console.log( "TimeTicketClockOff, handleOnDone :", handleOnDone );
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
const [currentSCC, setCurrentSCC] = 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) => {
|
const handleFinish = async (values) => {
|
||||||
logImEXEvent("TimeTicketClockOff_handleFinish");
|
logImEXEvent("TimeTicketClockOff_handleFinish");
|
||||||
// console.log("TimeTicketClockOff, values.cost_center?.value :", currentSCC);
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!!values.actualhours &&
|
!!values.actualhours &&
|
||||||
|
|||||||
@@ -57,17 +57,19 @@ export function* onEmployeeSignInSuccessSaga() {
|
|||||||
export function* updateEmployeeWithEmployeeId({ payload }) {
|
export function* updateEmployeeWithEmployeeId({ payload }) {
|
||||||
try {
|
try {
|
||||||
const employeeId = payload.id;
|
const employeeId = payload.id;
|
||||||
|
console.log("updateEmployeeWithEmployeeId",employeeId);
|
||||||
// logImEXEvent("redux_update_employee_with_employee_id_attempt", employeeId);
|
// logImEXEvent("redux_update_employee_with_employee_id_attempt", employeeId);
|
||||||
const result = yield client.query({ query: QUERY_EMPLOYEE_BY_ID,
|
const result = yield client.query({ query: QUERY_EMPLOYEE_BY_ID,
|
||||||
variables: {
|
variables: {
|
||||||
id: employeeId,
|
id: employeeId,
|
||||||
}
|
},
|
||||||
|
skip: !employeeId
|
||||||
});
|
});
|
||||||
const { employees_by_pk } = result.data;
|
const { employees_by_pk } = result?.data;
|
||||||
if (employees_by_pk) {
|
if (employees_by_pk) {
|
||||||
yield put(employeeGetRatesSuccess(employees_by_pk));
|
yield put(employeeGetRatesSuccess(employees_by_pk));
|
||||||
} else {
|
} else {
|
||||||
yield put(employeeGetRatesFailure(result.error));
|
yield put(employeeGetRatesFailure(result?.error));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
yield put(employeeGetRatesFailure(error));
|
yield put(employeeGetRatesFailure(error));
|
||||||
|
|||||||
Reference in New Issue
Block a user