added some checks for bugs
This commit is contained in:
@@ -25,7 +25,6 @@ import { logImEXEvent } from "../../firebase/firebase.analytics";
|
||||
import moment from "moment";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentEmployee: selectCurrentEmployee,
|
||||
currentRatesNCostCenters: selectRates,
|
||||
@@ -87,8 +86,14 @@ export function TimeTicketCreate({
|
||||
!!values.productivehours &&
|
||||
!!currentBodyshop.id &&
|
||||
!!currentEmployee?.technician?.id &&
|
||||
!!date2 && !!values.actualhours
|
||||
!!date2 &&
|
||||
!!values.actualhours
|
||||
) {
|
||||
if (isNaN(values.actualhours) | isNaN(values.productivehours)) {
|
||||
console.log("actual hours is NAN!");
|
||||
setError({ message: "Please make sure all fields have valid values." });
|
||||
return;
|
||||
}
|
||||
setError(null);
|
||||
console.log("have all values");
|
||||
} else {
|
||||
@@ -107,14 +112,33 @@ export function TimeTicketCreate({
|
||||
{
|
||||
actualhrs: values?.actualhours ? values?.actualhours : null,
|
||||
bodyshopid: currentBodyshop.id,
|
||||
ciecacode: currentBodyshop?.cdk_dealerid || currentBodyshop?.pbs_serialnumber ? currentSCC?.value : Object.keys(currentBodyshop.md_responsibility_centers.defaults.costs).find((key) => {return (currentBodyshop.md_responsibility_centers.defaults.costs[key] === currentSCC?.value);}),
|
||||
ciecacode:
|
||||
currentBodyshop?.cdk_dealerid || currentBodyshop?.pbs_serialnumber
|
||||
? currentSCC?.value
|
||||
: Object.keys(
|
||||
currentBodyshop.md_responsibility_centers.defaults.costs
|
||||
).find((key) => {
|
||||
return (
|
||||
currentBodyshop.md_responsibility_centers.defaults.costs[
|
||||
key
|
||||
] === currentSCC?.value
|
||||
);
|
||||
}),
|
||||
cost_center: currentSCC?.value,
|
||||
date: moment(date2).format("YYYY-MM-DD"),
|
||||
employeeid: currentEmployee?.technician?.id,
|
||||
flat_rate: currentEmployee && currentEmployee.technician && currentEmployee.technician?.flat_rate,
|
||||
flat_rate:
|
||||
currentEmployee &&
|
||||
currentEmployee.technician &&
|
||||
currentEmployee.technician?.flat_rate,
|
||||
jobid: currentSJobId?.value,
|
||||
productivehrs: values?.productivehours,
|
||||
rate: currentRatesNCostCenters && currentSCC?.value ? currentRatesNCostCenters.filter((r) => r.cost_center === currentSCC?.value)[0].rate : null,
|
||||
rate:
|
||||
currentRatesNCostCenters && currentSCC?.value
|
||||
? currentRatesNCostCenters.filter(
|
||||
(r) => r.cost_center === currentSCC?.value
|
||||
)[0].rate
|
||||
: null,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -122,12 +146,12 @@ export function TimeTicketCreate({
|
||||
// clockoff: undefined,
|
||||
// clockon: undefined,
|
||||
// memo: undefined,
|
||||
|
||||
|
||||
// console.log("insertTicket, tempVariablesObj. :", tempVariablesObj?.variables?.timeTicketInput[0]);
|
||||
|
||||
//after obj is good add below to make call
|
||||
|
||||
const result = await insertTicket(tempVariablesObj);//.catch(handleMutationError);
|
||||
const result = await insertTicket(tempVariablesObj); //.catch(handleMutationError);
|
||||
|
||||
// console.log(" result : ", result);
|
||||
// //after call results are retuning add handling below for cases
|
||||
@@ -146,7 +170,9 @@ export function TimeTicketCreate({
|
||||
const handleMutationError = (error) => {
|
||||
// setEnterAgain(false);
|
||||
console.log("insertTicket, result.error :", error);
|
||||
setError(error?.message ? JSON.stringify(error?.message) : JSON.stringify(error));
|
||||
setError(
|
||||
error?.message ? JSON.stringify(error?.message) : JSON.stringify(error)
|
||||
);
|
||||
setLoading(false);
|
||||
};
|
||||
return (
|
||||
@@ -231,7 +257,7 @@ export function TimeTicketCreate({
|
||||
>
|
||||
<Text style={{ fontSize: 12 }}>Create Ticket</Text>
|
||||
</Button>
|
||||
{error ? <ErrorDisplay errorMessage={error.message} /> : null}
|
||||
{error ? <ErrorDisplay errorMessage={error.message} /> : null}
|
||||
</View>
|
||||
)}
|
||||
</Formik>
|
||||
|
||||
Reference in New Issue
Block a user