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