updated insert time ticketcall

This commit is contained in:
jfrye122
2023-05-16 14:14:44 -04:00
parent e950fd9fd7
commit ea4750db1f

View File

@@ -77,9 +77,9 @@ export function TimeTicketCreate({
setError(null); setError(null);
setLoading(true); setLoading(true);
// console.log("insertTimeTicket, currentSCC :", currentSCC); // console.log("insertTicket, currentSCC :", currentSCC);
// console.log("insertTimeTicket, currentSCC :", currentSJobId); // console.log("insertTicket, currentSCC :", currentSJobId);
// console.log("insertTimeTicket, values :", values); // console.log("insertTicket, values :", values);
if ( if (
!!currentSCC?.value && !!currentSCC?.value &&
@@ -87,7 +87,7 @@ export function TimeTicketCreate({
!!values.productivehours && !!values.productivehours &&
!!currentBodyshop.id && !!currentBodyshop.id &&
!!currentEmployee?.technician?.id && !!currentEmployee?.technician?.id &&
!!date2 !!date2 && !!values.actualhours
) { ) {
setError(null); setError(null);
console.log("have all values"); console.log("have all values");
@@ -98,9 +98,9 @@ export function TimeTicketCreate({
return; return;
} }
if (date2) console.log("rate :", currentRatesNCostCenters && currentSCC?.value ? currentRatesNCostCenters.filter((r) => r.cost_center === currentSCC?.value)[0].rate : null);//2023-05-16T16:45:27.154Z // if (date2) console.log("rate :", currentRatesNCostCenters && currentSCC?.value ? currentRatesNCostCenters.filter((r) => r.cost_center === currentSCC?.value)[0].rate : null);//2023-05-16T16:45:27.154Z
if (date2) console.log("bodyshopid : ", currentBodyshop.id); // if (date2) console.log("bodyshopid : ", currentBodyshop.id);
if (date2) console.log("moment(date2).format(YYYY-MM-DD)", moment(date2).format("YYYY-MM-DD")); // if (date2) console.log("moment(date2).format(YYYY-MM-DD)", moment(date2).format("YYYY-MM-DD"));
const tempVariablesObj = { const tempVariablesObj = {
variables: { variables: {
timeTicketInput: [ timeTicketInput: [
@@ -123,25 +123,32 @@ export function TimeTicketCreate({
// clockon: undefined, // clockon: undefined,
// memo: undefined, // memo: undefined,
console.log("insertTimeTicket, tempVariablesObj. :", tempVariablesObj?.variables?.timeTicketInput[0]); // console.log("insertTicket, tempVariablesObj. :", tempVariablesObj?.variables?.timeTicketInput[0]);
//after obj is good add below to make call //after obj is good add below to make call
const result = await insertTicket(tempVariablesObj); const result = await insertTicket(tempVariablesObj);//.catch(handleMutationError);
// console.log(" result : ", result);
// //after call results are retuning add handling below for cases // //after call results are retuning add handling below for cases
console.log("insertTimeTicket, result :", result); // console.log("insertTicket, result :", result?.data?.insert_timetickets?.returning[0]);
setLoading(false); setLoading(false);
// if (!!result.errors) { if (!!result.errors) {
// console.log("insertTimeTicket, result.error :", result.errors); // console.log("insertTicket, result.error :", result.errors);
// setError(JSON.stringify(result.errors)); setError(JSON.stringify(result.errors));
// } else { } else {
// console.log("insertTimeTicket, result. :", result.data); // console.log("insertTicket, result. :", result.data);
// navigation.goBack(); navigation.goBack();
// } }
// if (completedCallback) completedCallback(); // if (completedCallback) completedCallback();
}; };
const handleMutationError = (error) => {
// setEnterAgain(false);
console.log("insertTicket, result.error :", error);
setError(error?.message ? JSON.stringify(error?.message) : JSON.stringify(error));
setLoading(false);
};
return ( return (
<View style={localStyles.content}> <View style={localStyles.content}>
<ScrollView contentContainerStyle={{ flexGrow: 1 }}> <ScrollView contentContainerStyle={{ flexGrow: 1 }}>