clean up of files
This commit is contained in:
@@ -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 (
|
||||
<Card style={{ margin: 8 }}>
|
||||
@@ -90,64 +50,11 @@ export function ClockedinListItem({ setTmTicketJobIdRedux, ticket }) {
|
||||
</Text>
|
||||
</Card.Content>
|
||||
<Card.Actions>
|
||||
{/* <TechClockOffButton
|
||||
jobId={ticket.jobid}
|
||||
timeTicketId={ticket.id}
|
||||
completedCallback={refetch}
|
||||
/> */}
|
||||
<Button
|
||||
// key={ticket.id}
|
||||
mode="outlined"
|
||||
onPress={makeNavToTimeTicketClockOff}
|
||||
// {
|
||||
// logImEXEvent("imexmobile_setcamerajobid_row");
|
||||
// // setTmTicketJobId(ticket.id);
|
||||
// // console.log("ticket.jobid is :",ticket.jobid );
|
||||
// // console.log("setTimeTicketJobId is :",setTimeTicketJobId );
|
||||
// // console.log("ham is :",setTimeTicketJobId );
|
||||
// // if (typeof ham === 'undefined') {
|
||||
// // console.error("yo dog, setTimeTicketJobId is undefined!");
|
||||
// // return;
|
||||
// // }
|
||||
// const { id, jobid } = e;
|
||||
// console.log("ticket.jobid is :", ticket.jobid);
|
||||
// setTmTicketJobId(ticket.jobid);
|
||||
// // setTimeTicketJobId(ticket.jobid);
|
||||
// //navigation.navigate("TimeTicketClockOff");
|
||||
// }}
|
||||
>
|
||||
<Button mode="outlined" onPress={makeNavToTimeTicketClockOff} >
|
||||
Clock Out
|
||||
</Button>
|
||||
</Card.Actions>
|
||||
</Card>
|
||||
// <List.Item
|
||||
// onPress={onPress}
|
||||
// title={<Title>{item.ro_number || t("general.labels.na")}</Title>}
|
||||
// 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 }) => (
|
||||
// <Button
|
||||
// style={[style, { alignSelf: "center" }]}
|
||||
// onPress={() => {
|
||||
// logImEXEvent("imexmobile_setcamerajobid_row");
|
||||
// setCameraJobId(item.id);
|
||||
// setCameraJob(item);
|
||||
// navigation.navigate("MediaBrowserTab");
|
||||
// }}
|
||||
// >
|
||||
// <Ionicons
|
||||
// style={[style, { alignSelf: "center" }]}
|
||||
// name="ios-add"
|
||||
// size={32}
|
||||
// color="dodgerblue"
|
||||
// />
|
||||
// </Button>
|
||||
// )}
|
||||
// />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 }) => (
|
||||
<View style={localStyles.topTimeTicketContainer}>
|
||||
@@ -168,7 +234,7 @@ console.log("TimeTicketClockOff, currentTmTicketJobId :", currentTmTicketJobId);
|
||||
/>
|
||||
<Button
|
||||
style={localStyles.input}
|
||||
// onPress={handleSubmit}
|
||||
onPress={handleSubmit}
|
||||
title="Submit"
|
||||
>
|
||||
<Text style={{ fontSize: 12 }}>Clock Off</Text>
|
||||
|
||||
Reference in New Issue
Block a user