update Employee field to show first and last name

This commit is contained in:
jfrye122
2023-06-02 13:34:42 -04:00
parent 00316dd6d0
commit 20e59bdd6b
2 changed files with 52 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ import DateTimePickerModal from "react-native-modal-datetime-picker";
import { import {
selectCurrentEmployee, selectCurrentEmployee,
selectRates, selectRates,
selectEmployeeFullName
} from "../../redux/employee/employee.selectors"; } from "../../redux/employee/employee.selectors";
import { selectBodyshop } from "../../redux/user/user.selectors"; import { selectBodyshop } from "../../redux/user/user.selectors";
import { useCallback } from "react"; import { useCallback } from "react";
@@ -29,6 +30,7 @@ const mapStateToProps = createStructuredSelector({
currentEmployee: selectCurrentEmployee, currentEmployee: selectCurrentEmployee,
currentRatesNCostCenters: selectRates, currentRatesNCostCenters: selectRates,
currentBodyshop: selectBodyshop, currentBodyshop: selectBodyshop,
currentEmployeeFullName: selectEmployeeFullName
}); });
// const mapDispatchToProps = (dispatch) => ({}); // const mapDispatchToProps = (dispatch) => ({});
@@ -36,6 +38,7 @@ export function TimeTicketCreate({
currentEmployee, currentEmployee,
currentRatesNCostCenters, currentRatesNCostCenters,
currentBodyshop, currentBodyshop,
currentEmployeeFullName
}) { }) {
const navigation = useNavigation(); const navigation = useNavigation();
const { t } = useTranslation(); const { t } = useTranslation();
@@ -183,7 +186,7 @@ export function TimeTicketCreate({
initialValues={{ initialValues={{
jobid: { currentSJobId }, jobid: { currentSJobId },
ticketdate: date2.toLocaleDateString(), ticketdate: date2.toLocaleDateString(),
employee: currentEmployee.technician.first_name, employee: {currentEmployeeFullName},
costcenter: { currentSCC }, costcenter: { currentSCC },
productivehours: "", productivehours: "",
actualhours: "", actualhours: "",

View File

@@ -24,5 +24,52 @@ export const selectGettingRates = createSelector(
); );
export const selectTechnician = createSelector( export const selectTechnician = createSelector(
[selectEmployee], [selectEmployee],
(employee) => employee.currentEmployee?.technician (employee) => {
if (!employee.currentEmployee || !employee.currentEmployee.technician) {
// console.info("selectTechnician returning null");
return null;
}
// console.info("selectTechnician returning :", employee.currentEmployee.technician);
return employee.currentEmployee.technician;
}
);
export const selectEmployeeFirstName = createSelector(
[selectTechnician],
(techResults) => {
if (!techResults || !techResults.first_name) {
// console.info("selectEmployeeFirstName returning null");
return null;
}
// console.info("selectEmployeeFirstName returning :", techResults.first_name);
return techResults.first_name;
}
);
export const selectEmployeeLastName = createSelector(
[selectTechnician],
(techResults) => {
if (!techResults || !techResults.last_name) {
// console.info("selectEmployeeLastName returning null");
return null;
}
// console.info("selectEmployeeLastName returning :", techResults.last_name);
return techResults.last_name;
}
);
export const selectEmployeeFullName = createSelector(
[selectEmployeeFirstName,selectEmployeeLastName],
(fName,lName) => {
if (!fName && !lName) {
// console.warn("selectEmployeeFullName returning null");
return null;
}
if (fName) {
if(lName){
return fName + " " + lName;
} else {
return fName;
}
} else {
return lName;
}
}
); );