fixbugwithselectordropdownaddedclockedinlist
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import { View, Text } from "react-native";
|
||||
|
||||
import axios from "axios";
|
||||
import { connect } from "react-redux";
|
||||
import { employeeGetRatesStart } from "../../redux/employee/employee.actions";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -16,13 +16,14 @@ import { Button } from "react-native-paper";
|
||||
import { useQuery } from "@apollo/client";
|
||||
import ErrorDisplay from "../error-display/error-display.component";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import { JobSearchSelect } from "../Selects/select-job-name";
|
||||
import { JobIdSearchSelect } from "../Selects/select-job-id";
|
||||
import { CostCenterSelect } from "../Selects/select-cost-center";
|
||||
import {
|
||||
selectCurrentTimeTicketJob,
|
||||
selectCurrentTimeTicketJobId,
|
||||
} from "../../redux/timetickets/timetickets.selectors";
|
||||
import { JobIdSearchSelect } from "../Selects/select-job-id";
|
||||
import moment from "moment";
|
||||
import { EmployeeClockedInList } from "../time-ticket-lists/employee-clockedin-list.component";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentEmployee: selectCurrentEmployee,
|
||||
@@ -51,7 +52,7 @@ export function ScreenTimeTicketBrowser({
|
||||
}) {
|
||||
//const employeeId = currentEmployee.technician.id;
|
||||
const [currentSCC, setCurrentSCC] = useState(null);
|
||||
const [currentSJob, setCurrentSJob] = useState(null);
|
||||
// const [currentSJob, setCurrentSJob] = useState(null);
|
||||
const [currentSJobId, setCurrentSJobId] = useState(null);
|
||||
|
||||
// const { error, data } = useQuery(QUERY_EMPLOYEE_BY_ID, {
|
||||
@@ -60,43 +61,65 @@ export function ScreenTimeTicketBrowser({
|
||||
// const signingErrorMsg = error ? (<ErrorDisplay errorMessage={error.message} />) : null;
|
||||
// const signingErrorMsg = signingError ? (<ErrorDisplay errorMessage={signingError} />) : null;
|
||||
|
||||
const wrapperSetCurrentSJobState = useCallback(val => {
|
||||
setCurrentSJob(val);
|
||||
}, [setCurrentSJob]);
|
||||
|
||||
// const wrapperSetCurrentSJobState = useCallback(
|
||||
// (val) => {
|
||||
// setCurrentSJobId(val);
|
||||
// },
|
||||
// [setCurrentSJobId]
|
||||
// );
|
||||
|
||||
const getRates = (currentEmployee) => {
|
||||
employeeGetRatesStart(currentEmployee.technician.id);
|
||||
};
|
||||
const createTheTimeTicketOBJ = (
|
||||
const createTheTimeTicketOBJ = async (
|
||||
currentEmployee,
|
||||
currentBodyshop,
|
||||
currentSCC,
|
||||
currentSJob,
|
||||
currentSJobId
|
||||
) => {
|
||||
console.log("currentSCC", currentSCC.value);
|
||||
console.log("currentSJob", currentSJob.value);
|
||||
console.log("currentSJobId", currentSJobId.value);
|
||||
console.log("bodyshopid", currentBodyshop.id);
|
||||
console.log("employeeid", currentEmployee.technician.id);
|
||||
console.log(currentBodyshop);
|
||||
const theTime = (await axios.post("/utils/time")).data;
|
||||
if (currentBodyshop) console.log("bodyshopid", currentBodyshop?.id);
|
||||
if (currentEmployee) console.log("employeeid", currentEmployee?.technician.id);
|
||||
if (theTime) console.log("date", moment(theTime).format("YYYY-MM-DD"));
|
||||
// if (currentSJob) console.log("currentSJob", currentSJob?.value);
|
||||
if (currentSJobId) console.log("jobid or currentSJobId", currentSJobId?.value);
|
||||
if (currentSCC) console.log("cost_center or currentSCC", currentSCC?.value);
|
||||
//if(currentBodyshop)console.log(currentBodyshop);
|
||||
if (currentBodyshop)
|
||||
console.log(
|
||||
"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
|
||||
);
|
||||
})
|
||||
);
|
||||
if (currentEmployee)
|
||||
console.log("flat_rate", currentEmployee?.technician?.flat_rate);
|
||||
|
||||
if (currentSCC) console.log("rate or currentSCC", currentSCC?.rate);
|
||||
// const temp = {
|
||||
// timeTicketInput: [
|
||||
// {
|
||||
// bodyshopid: currentBodyshop?.id,
|
||||
// employeeid: currentEmployee?.technician?.id,
|
||||
// date: "2023-05-11", //moment(theTime).format("YYYY-MM-DD"),
|
||||
//have bodyshopid: currentBodyshop?.id,
|
||||
//have employeeid: currentEmployee?.technician?.id,
|
||||
//have date: "2023-05-11", //moment(theTime).format("YYYY-MM-DD"),
|
||||
// //clockon: moment(theTime),
|
||||
// jobid: "temp",//values.jobid,
|
||||
// cost_center: "temp",//values.cost_center,
|
||||
// ciecacode: currentBodyshop?.cdk_dealerid || currentBodyshop?.pbs_serialnumber
|
||||
//have cost_center: "temp",//values.cost_center,
|
||||
//have ciecacode: currentBodyshop?.cdk_dealerid || currentBodyshop?.pbs_serialnumber
|
||||
// ? values.cost_center
|
||||
// : Object.keys(currentBodyshop.md_responsibility_centers.defaults.costs).find((key) => {
|
||||
// return (currentBodyshop.md_responsibility_centers.defaults.costs[key] === "temp");//values.cost_center);
|
||||
// }),
|
||||
// flat_rate: currentEmployee.technician.flat_rate,
|
||||
// rate: 1,
|
||||
//have flat_rate: currentEmployee.technician.flat_rate,
|
||||
//have rate: 1,
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
@@ -111,7 +134,7 @@ export function ScreenTimeTicketBrowser({
|
||||
loading={loaderGettingRates}
|
||||
//onPress={() => getRates(currentEmployee)}
|
||||
onPress={() =>
|
||||
createTheTimeTicketOBJ(currentEmployee, currentBodyshop, currentSCC)
|
||||
createTheTimeTicketOBJ(currentEmployee, currentBodyshop, currentSCC, currentSJobId)
|
||||
}
|
||||
>
|
||||
<Text>text here</Text>
|
||||
@@ -119,14 +142,7 @@ export function ScreenTimeTicketBrowser({
|
||||
{/* {signingErrorMsg} */}
|
||||
<JobIdSearchSelect
|
||||
currentValue={currentSJobId}
|
||||
//onValueSelected={setCurrentSJobId}
|
||||
convertedOnly={!currentBodyshop.tt_allow_post_to_invoiced}
|
||||
notExported={!currentBodyshop.tt_allow_post_to_invoiced}
|
||||
/>
|
||||
|
||||
<JobSearchSelect
|
||||
currentValue={currentSJob}
|
||||
onValueSelected={setCurrentSJob}
|
||||
onJobSelected={setCurrentSJobId}
|
||||
convertedOnly={!currentBodyshop.tt_allow_post_to_invoiced}
|
||||
notExported={!currentBodyshop.tt_allow_post_to_invoiced}
|
||||
/>
|
||||
@@ -139,10 +155,11 @@ export function ScreenTimeTicketBrowser({
|
||||
mode="outlined"
|
||||
//loading={loaderClockIn}
|
||||
//onPress={() => clockIn()}
|
||||
|
||||
>
|
||||
<Text>Clock In</Text>
|
||||
</Button>
|
||||
|
||||
<EmployeeClockedInList technician={currentEmployee} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user