updated timeticketcreate

This commit is contained in:
jfrye122
2023-07-20 17:00:27 -04:00
parent 79fe863fac
commit 69eaf5eba6

View File

@@ -32,6 +32,7 @@ import { useNavigation } from "@react-navigation/native";
import styles from "../styles"; import styles from "../styles";
import StyleRepeater from "../style-repeater/style-repeater"; import StyleRepeater from "../style-repeater/style-repeater";
import { FlatList } from "react-native"; import { FlatList } from "react-native";
import JobSearchAndSelectModal from "../Modals/JobSearchAndSelectModal";
const mapStateToProps = createStructuredSelector({ const mapStateToProps = createStructuredSelector({
currentEmployee: selectCurrentEmployee, currentEmployee: selectCurrentEmployee,
@@ -60,9 +61,7 @@ export function TimeTicketCreate({
const [date2, setDate2] = useState(new Date()); const [date2, setDate2] = useState(new Date());
const [currentSCC, setCurrentSCC] = useState(null); const [currentSCC, setCurrentSCC] = useState(null);
// const [currentSJob, setCurrentSJob] = useState(null); const [curSelClockIntoJob,setCurSelClockIntoJob] = useState(null);
const [currentSJobId, setCurrentSJobId] = useState(null);
const showDatePicker = () => { const showDatePicker = () => {
setDatePickerVisibility(true); setDatePickerVisibility(true);
}; };
@@ -88,7 +87,7 @@ export function TimeTicketCreate({
if ( if (
!!currentSCC?.value && !!currentSCC?.value &&
!!currentSJobId?.value && !!curSelClockIntoJob?.id &&
!!values.productivehours && !!values.productivehours &&
!!currentBodyshop.id && !!currentBodyshop.id &&
!!currentEmployee?.technician?.id && !!currentEmployee?.technician?.id &&
@@ -120,10 +119,7 @@ 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("bodyshopid : ", currentBodyshop.id);
// if (date2) console.log("moment(date2).format(YYYY-MM-DD)", moment(date2).format("YYYY-MM-DD"));
const tempVariablesObj = { const tempVariablesObj = {
variables: { variables: {
timeTicketInput: [ timeTicketInput: [
@@ -149,7 +145,7 @@ export function TimeTicketCreate({
currentEmployee && currentEmployee &&
currentEmployee.technician && currentEmployee.technician &&
currentEmployee.technician?.flat_rate, currentEmployee.technician?.flat_rate,
jobid: currentSJobId?.value, jobid: curSelClockIntoJob?.id,
productivehrs: values?.productivehours, productivehrs: values?.productivehours,
rate: rate:
currentRatesNCostCenters && currentSCC?.value currentRatesNCostCenters && currentSCC?.value
@@ -182,18 +178,8 @@ export function TimeTicketCreate({
// console.log("insertTicket, result. :", result.data); // console.log("insertTicket, result. :", result.data);
navigation.goBack(); 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);
// };
const onRefresh = useCallback(() => { const onRefresh = useCallback(() => {
setLoading(true); setLoading(true);
// refetch(); // refetch();
@@ -210,7 +196,6 @@ export function TimeTicketCreate({
<Card.Content> <Card.Content>
<Formik <Formik
initialValues={{ initialValues={{
jobid: { currentSJobId },
ticketdate: date2.toLocaleDateString(), ticketdate: date2.toLocaleDateString(),
employee: { currentEmployeeFullName }, employee: { currentEmployeeFullName },
costcenter: { currentSCC }, costcenter: { currentSCC },
@@ -221,13 +206,20 @@ export function TimeTicketCreate({
> >
{({ handleChange, handleBlur, handleSubmit, values }) => ( {({ handleChange, handleBlur, handleSubmit, values }) => (
<View style={localStyles.topTimeTicketContainer}> <View style={localStyles.topTimeTicketContainer}>
<JobIdSearchSelect {/* <JobIdSearchSelect
currentValue={currentSJobId} currentValue={currentSJobId}
onJobSelected={setCurrentSJobId} onJobSelected={setCurrentSJobId}
convertedOnly={true} convertedOnly={true}
notExported={!currentBodyshop.tt_allow_post_to_invoiced} notExported={!currentBodyshop.tt_allow_post_to_invoiced}
notInvoiced={!currentBodyshop.tt_allow_post_to_invoiced} notInvoiced={!currentBodyshop.tt_allow_post_to_invoiced}
/> /> */}
<JobSearchAndSelectModal
currentValue={curSelClockIntoJob}
onSetCurrentValue={setCurSelClockIntoJob}
notExported={!currentBodyshop.tt_allow_post_to_invoiced}
notInvoiced={!currentBodyshop.tt_allow_post_to_invoiced}
convertedOnly={true}
/>
<Button <Button
mode="outlined" mode="outlined"
title="TicketDatePickerButton" title="TicketDatePickerButton"
@@ -308,7 +300,7 @@ export function TimeTicketCreate({
renderItem={null} renderItem={null}
ListFooterComponent={ ListFooterComponent={
<LaborAllocationsTable <LaborAllocationsTable
jobId={currentSJobId?.value} jobId={curSelClockIntoJob?.id}
costCenterDiff={costCenterDiff} costCenterDiff={costCenterDiff}
selectedCostCenter={currentSCC} selectedCostCenter={currentSCC}
style={localStyles.localCardStyle} style={localStyles.localCardStyle}