diff --git a/components/time-ticket-items/clockedin-list-item.component.jsx b/components/time-ticket-items/clockedin-list-item.component.jsx
index fbcb826..d46d08e 100644
--- a/components/time-ticket-items/clockedin-list-item.component.jsx
+++ b/components/time-ticket-items/clockedin-list-item.component.jsx
@@ -1,69 +1,29 @@
-import { Ionicons } from "@expo/vector-icons";
import { useNavigation } from "@react-navigation/native";
import React from "react";
import { useTranslation } from "react-i18next";
import { Button, Card, Text } from "react-native-paper";
-import { connect, useSelector, useDispatch } from "react-redux";
-import { createSelector, createStructuredSelector } from "reselect";
+import { connect } from "react-redux";
import { OwnerNameDisplayFunction } from "../owner-name-display/owner-name-display.component";
import { DateTimeFormatter } from "../../util/DateFormater";
-// import { setTimeTicketJobId } from "../../redux/timetickets/timetickets.actions";
import { setTmTicketJobId } from "../../redux/app/app.actions";
-import { logImEXEvent } from "../../firebase/firebase.analytics";
-import { employeeSignInStart } from "../../redux/employee/employee.actions";
-import { useRef } from "react";
-
-// const selectNumCompletedTodos = createSelector(
-// (state) => state.timeTickets,
-// (timeTickets) => timeTickets.timeTicketJobId
-// );
-//const mapStateToProps = createStructuredSelector({});
-// // setTimeTicketJobId: (jobId) =>dispatch(setTimeTicketJobId({jobId})),
-//employeeSignInStart:(idjob) => dispatch(employeeSignInStart(idjob)),
const mapDispatchToProps = (dispatch) => ({
setTmTicketJobIdRedux: (jobId) => dispatch(setTmTicketJobId(jobId)),
});
export function ClockedinListItem({ setTmTicketJobIdRedux, ticket }) {
- console.log("ClockedinListItem, ticket", ticket);
- console.log("ClockedinListItem, setTmTicketJobId", setTmTicketJobId);
-
const { t } = useTranslation();
const navigation = useNavigation();
- console.log("ClockedinListItem, ticket job id", ticket.job.id);
- const jbId = ticket.job.id;
- console.log("ClockedinListItem, jbId: ", jbId);
- // const te = useRef(jbId);
-
const makeNavToTimeTicketClockOff = () => (
- console.log(
- "*** THIS IS THE ONE WE ARE TESTING. ClockedinListItem, makeNavToTimeTicketClockOff, setTmTicketJobId :",
- setTmTicketJobIdRedux
- ),
- //console.log("ClockedinListItem, makeNavToTimeTicketClockOff, jobId :", jbId)
+ // console.log("makeNavToTimeTicketClockOff, checkHasDispatchCall:",setTmTicketJobIdRedux),
setTmTicketJobIdRedux(ticket.job.id),
- //,
- navigation.navigate("TimeTicketClockOff")
+ navigation.navigate("TimeTicketClockOff", {
+ // jobId: ticket.jobid, //item.id,
+ timeTicketId:ticket.id,
+ //completedCallback: refetch,
+ })
);
- // const onPress = (ticket, setCameraJobId) => {
- // console.log("ClockedinListItem, onPress called");
- // console.log("ClockedinListItem, ticket", ticket);
- // setTimeTicketJobId(ticket.jobid);
- // // logImEXEvent("imexmobile_view_job_detail");
- // navigation.push("TimeTicketClockOff", {
- // jobId: ticket.jobid, //item.id,
- // timeTicketId: ticket.id,
- // //completedCallback: refetch,
- // });
- // // navigation.push("JobDetail", {
- // // jobId: item.id,
- // // timeTicketId: item.ro_number || t("general.labels.na"),
- // // job: item,
- // // });
- // // () => {navigation.navigate("TimeTicketClockOff");}
- // };
return (
@@ -90,64 +50,11 @@ export function ClockedinListItem({ setTmTicketJobIdRedux, ticket }) {
- {/* */}
-
- // {item.ro_number || t("general.labels.na")}}
- // descriptionNumberOfLines={2}
- // description={`${item.ownr_fn || ""} ${item.ownr_ln || ""} ${
- // item.ownr_co_nm || ""
- // } - ${item.v_model_yr || ""} ${item.v_make_desc || ""} ${
- // item.v_model_desc || ""
- // }`}
- // right={({ style }) => (
- // {
- // logImEXEvent("imexmobile_setcamerajobid_row");
- // setCameraJobId(item.id);
- // setCameraJob(item);
- // navigation.navigate("MediaBrowserTab");
- // }}
- // >
- //
- //
- // )}
- // />
);
}
diff --git a/components/time-ticket/screen-time-ticket-clockoff.component.jsx b/components/time-ticket/screen-time-ticket-clockoff.component.jsx
index d824096..cd0bd41 100644
--- a/components/time-ticket/screen-time-ticket-clockoff.component.jsx
+++ b/components/time-ticket/screen-time-ticket-clockoff.component.jsx
@@ -17,6 +17,7 @@ import { useMutation } from "@apollo/client";
import { selectCurrentTmTicketJobId } from "../../redux/app/app.selectors";
import ErrorDisplay from "../error-display/error-display.component";
import { timeTicketClockOutStart } from "../../redux/timetickets/timetickets.actions";
+import { logImEXEvent } from "../../firebase/firebase.analytics";
// import { selectCurrentTimeTicketJobId } from "../../redux/timetickets/timetickets.selectors";
//TODO add props needed for call
@@ -25,6 +26,8 @@ const mapStateToProps = createStructuredSelector({
currentRatesNCostCenters: selectRates,
currentBodyshop: selectBodyshop,
currentTmTicketJobId: selectCurrentTmTicketJobId,
+
+ //add way to get timeTicketId
// currentJobId: selectCurrentTimeTicketJobId
});
const mapDispatchToProps = (dispatch) => ({
@@ -36,8 +39,10 @@ export function TimeTicketClockOff({
currentRatesNCostCenters,
currentBodyshop,
currentTmTicketJobId,
+ route,
}) {
- // console.log("TimeTicketClockOff, currentEmployee :", currentEmployee);
+ const { timeTicketId } = route.params;
+ console.log("TimeTicketClockOff, timeTicketId :", timeTicketId);
//console.log("TimeTicketClockOff, currentRatesNCostCenters :", currentRatesNCostCenters );
// console.log("TimeTicketClockOff, currentBodyshop :", currentBodyshop);
@@ -75,6 +80,67 @@ console.log("TimeTicketClockOff, currentTmTicketJobId :", currentTmTicketJobId);
//TODO update with start call for create time ticket
};
+
+
+ const [updateTimeticket] = useMutation(UPDATE_TIME_TICKET);
+
+
+
+ const handleFinish = async (values) => {
+ logImEXEvent("TimeTicketClockOff_handleFinish");
+
+ //build obj
+ const tempcallobj = {
+ variables: {
+ timeticketId: timeTicketId,
+ timeticket: {
+ clockoff: (await axios.post("/utils/time")).data,
+ ...values,
+ rate:
+ emps &&
+ emps.rates.filter((r) => r.cost_center === values.cost_center)[0]
+ ?.rate,
+ flat_rate: emps && emps.flat_rate,
+ ciecacode:
+ bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
+ ? values.cost_center
+ : Object.keys(
+ bodyshop.md_responsibility_centers.defaults.costs
+ ).find((key) => {
+ return (
+ bodyshop.md_responsibility_centers.defaults.costs[key] ===
+ values.cost_center
+ );
+ }),
+ },
+ },
+ };
+
+ console.log("TimeTicketClockOff, tempcallobj :",tempcallobj);
+
+//after obj is good add below to make call
+ //setLoading(true);
+ //const result = await updateTimeticket();
+
+
+//after call results are retuning add handling below for cases
+
+ // if (!!result.errors) {
+ // notification["error"]({
+ // message: t("timetickets.errors.clockingout", {
+ // message: JSON.stringify(result.errors),
+ // }),
+ // });
+ // } else {
+ // notification["success"]({
+ // message: t("timetickets.successes.clockedout"),
+ // });
+ // }
+ setLoading(false);
+ // if (completedCallback) completedCallback();
+ };
+
+
// const handleFinish = async (values) => {
// //logImEXEvent("tech_clock_out_job");
@@ -135,7 +201,7 @@ console.log("TimeTicketClockOff, currentTmTicketJobId :", currentTmTicketJobId);
productivehours: "",
actualhours: "",
}}
- onSubmit={formSubmit}
+ onSubmit={handleFinish}
>
{({ handleChange, handleBlur, handleSubmit, values }) => (
@@ -168,7 +234,7 @@ console.log("TimeTicketClockOff, currentTmTicketJobId :", currentTmTicketJobId);
/>
Clock Off