added some checks for bugs

This commit is contained in:
jfrye122
2023-05-19 15:48:44 -04:00
parent 05e3613db9
commit 4dc054b1e3
6 changed files with 133 additions and 44 deletions

View File

@@ -41,9 +41,9 @@ export function TimeTicketClockOff({
route,
}) {
const navigation = useNavigation();
const { timeTicketId, handleOnDone } = route.params;
const { timeTicketId } = route.params;
// console.log("TimeTicketClockOff, timeTicketId :", timeTicketId);
console.log( "TimeTicketClockOff, handleOnDone :", handleOnDone );
// console.log( "TimeTicketClockOff, handleOnDone :", handleOnDone );
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
@@ -61,6 +61,12 @@ export function TimeTicketClockOff({
!!values.productivehours &&
!!currentSCC?.value
) {
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("all have values:");
} else {

View File

@@ -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>