updated insert time ticketcall
This commit is contained in:
@@ -77,9 +77,9 @@ export function TimeTicketCreate({
|
||||
setError(null);
|
||||
setLoading(true);
|
||||
|
||||
// console.log("insertTimeTicket, currentSCC :", currentSCC);
|
||||
// console.log("insertTimeTicket, currentSCC :", currentSJobId);
|
||||
// console.log("insertTimeTicket, values :", values);
|
||||
// console.log("insertTicket, currentSCC :", currentSCC);
|
||||
// console.log("insertTicket, currentSCC :", currentSJobId);
|
||||
// console.log("insertTicket, values :", values);
|
||||
|
||||
if (
|
||||
!!currentSCC?.value &&
|
||||
@@ -87,7 +87,7 @@ export function TimeTicketCreate({
|
||||
!!values.productivehours &&
|
||||
!!currentBodyshop.id &&
|
||||
!!currentEmployee?.technician?.id &&
|
||||
!!date2
|
||||
!!date2 && !!values.actualhours
|
||||
) {
|
||||
setError(null);
|
||||
console.log("have all values");
|
||||
@@ -98,9 +98,9 @@ export function TimeTicketCreate({
|
||||
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("bodyshopid : ", currentBodyshop.id);
|
||||
if (date2) console.log("moment(date2).format(YYYY-MM-DD)", moment(date2).format("YYYY-MM-DD"));
|
||||
// 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("moment(date2).format(YYYY-MM-DD)", moment(date2).format("YYYY-MM-DD"));
|
||||
const tempVariablesObj = {
|
||||
variables: {
|
||||
timeTicketInput: [
|
||||
@@ -123,25 +123,32 @@ export function TimeTicketCreate({
|
||||
// clockon: 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
|
||||
|
||||
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
|
||||
console.log("insertTimeTicket, result :", result);
|
||||
// console.log("insertTicket, result :", result?.data?.insert_timetickets?.returning[0]);
|
||||
setLoading(false);
|
||||
// if (!!result.errors) {
|
||||
// console.log("insertTimeTicket, result.error :", result.errors);
|
||||
// setError(JSON.stringify(result.errors));
|
||||
// } else {
|
||||
// console.log("insertTimeTicket, result. :", result.data);
|
||||
// navigation.goBack();
|
||||
// }
|
||||
if (!!result.errors) {
|
||||
// console.log("insertTicket, result.error :", result.errors);
|
||||
setError(JSON.stringify(result.errors));
|
||||
} else {
|
||||
// console.log("insertTicket, result. :", result.data);
|
||||
navigation.goBack();
|
||||
}
|
||||
// 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 (
|
||||
<View style={localStyles.content}>
|
||||
<ScrollView contentContainerStyle={{ flexGrow: 1 }}>
|
||||
|
||||
Reference in New Issue
Block a user