clean up of files
This commit is contained in:
@@ -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