updated costcenterselector
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { View, Text } from "react-native";
|
||||
|
||||
import { connect } from "react-redux";
|
||||
@@ -15,13 +15,22 @@ import { Button } from "react-native-paper";
|
||||
//temp
|
||||
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 { CostCenterSelect } from "../Selects/select-cost-center";
|
||||
import {
|
||||
selectCurrentTimeTicketJob,
|
||||
selectCurrentTimeTicketJobId,
|
||||
} from "../../redux/timetickets/timetickets.selectors";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentEmployee: selectCurrentEmployee,
|
||||
theRates: selectRates,
|
||||
loaderGettingRates: selectGettingRates,
|
||||
signingError: selectSignInError,
|
||||
currentBodyshop: selectBodyshop,
|
||||
currentRatesNCostCenters: selectRates,
|
||||
currentSelectedTimeTicketJobId: selectCurrentTimeTicketJobId,
|
||||
currentSelectedTimeTicketJob: selectCurrentTimeTicketJob,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
@@ -33,33 +42,83 @@ export function ScreenTimeTicketBrowser({
|
||||
loaderGettingRates,
|
||||
currentEmployee,
|
||||
employeeGetRatesStart,
|
||||
signingError
|
||||
signingError,
|
||||
currentBodyshop,
|
||||
currentRatesNCostCenters,
|
||||
currentSelectedTimeTicketJob,
|
||||
currentSelectedTimeTicketJobId,
|
||||
}) {
|
||||
const employeeId = currentEmployee.technician.id;
|
||||
//const employeeId = currentEmployee.technician.id;
|
||||
const [currentCC, setCurrentCC] = useState(null);
|
||||
|
||||
// const { error, data } = useQuery(QUERY_EMPLOYEE_BY_ID, {
|
||||
// variables: { id: currentEmployee.technician.id },
|
||||
// });
|
||||
// const signingErrorMsg = error ? (<ErrorDisplay errorMessage={error.message} />) : null;
|
||||
// const signingErrorMsg = signingError ? (<ErrorDisplay errorMessage={signingError} />) : null;
|
||||
// const signingErrorMsg = signingError ? (<ErrorDisplay errorMessage={signingError} />) : null;
|
||||
|
||||
const getRates = (currentEmployee) => {
|
||||
employeeGetRatesStart(currentEmployee.technician.id);
|
||||
};
|
||||
|
||||
const createTheTimeTicketOBJ = (
|
||||
currentEmployee,
|
||||
currentBodyshop,
|
||||
currentCC
|
||||
) => {
|
||||
console.log("currentCC", currentCC.value);
|
||||
console.log("bodyshopid", currentBodyshop.id);
|
||||
console.log("employeeid", currentEmployee.technician.id);
|
||||
console.log(currentBodyshop);
|
||||
// const temp = {
|
||||
// timeTicketInput: [
|
||||
// {
|
||||
// bodyshopid: currentBodyshop?.id,
|
||||
// employeeid: currentEmployee?.technician?.id,
|
||||
// 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
|
||||
// ? 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,
|
||||
// },
|
||||
// ],
|
||||
// };
|
||||
// console.log(temp);
|
||||
//employeeGetRatesStart(currentEmployee.technician.id);
|
||||
};
|
||||
return (
|
||||
<View>
|
||||
<Text>Time Ticket List goes here</Text>
|
||||
<Button
|
||||
mode="outlined"
|
||||
loading={loaderGettingRates}
|
||||
onPress={() => getRates(currentEmployee)}
|
||||
>
|
||||
<Text>text here</Text>
|
||||
</Button>
|
||||
{/* {signingErrorMsg} */}
|
||||
mode="outlined"
|
||||
loading={loaderGettingRates}
|
||||
//onPress={() => getRates(currentEmployee)}
|
||||
onPress={() =>
|
||||
createTheTimeTicketOBJ(currentEmployee, currentBodyshop, currentCC)
|
||||
}
|
||||
>
|
||||
<Text>text here</Text>
|
||||
</Button>
|
||||
{/* {signingErrorMsg} */}
|
||||
<JobSearchSelect
|
||||
convertedOnly={!currentBodyshop.tt_allow_post_to_invoiced}
|
||||
notExported={!currentBodyshop.tt_allow_post_to_invoiced}
|
||||
/>
|
||||
<CostCenterSelect
|
||||
currentValue={currentCC}
|
||||
currentRatesNCostCenters={currentRatesNCostCenters}
|
||||
onValueSelected={setCurrentCC}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ScreenTimeTicketBrowser);
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(ScreenTimeTicketBrowser);
|
||||
|
||||
Reference in New Issue
Block a user