added missing fuctionallity
This commit is contained in:
@@ -6,15 +6,16 @@ import { Button, List, Title } from "react-native-paper";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { logImEXEvent } from "../../firebase/firebase.analytics";
|
import { logImEXEvent } from "../../firebase/firebase.analytics";
|
||||||
import { setCameraJob, setCameraJobId } from "../../redux/app/app.actions";
|
import { setCameraJob, setCameraJobId, setTmTicketJobId } from "../../redux/app/app.actions";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({});
|
const mapStateToProps = createStructuredSelector({});
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
setCameraJobId: (id) => dispatch(setCameraJobId(id)),
|
setCameraJobId: (id) => dispatch(setCameraJobId(id)),
|
||||||
setCameraJob: (job) => dispatch(setCameraJob(job)),
|
setCameraJob: (job) => dispatch(setCameraJob(job)),
|
||||||
|
setTmTicketJobId:(id) => dispatch(setTmTicketJobId(id)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export function JobListItem({ setCameraJob, setCameraJobId, item }) {
|
export function JobListItem({ setCameraJob, setCameraJobId,setTmTicketJobId, item }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
// const _swipeableRow = useRef(null);
|
// const _swipeableRow = useRef(null);
|
||||||
@@ -71,6 +72,7 @@ export function JobListItem({ setCameraJob, setCameraJobId, item }) {
|
|||||||
onPress={() => {
|
onPress={() => {
|
||||||
logImEXEvent("imexmobile_setcamerajobid_row");
|
logImEXEvent("imexmobile_setcamerajobid_row");
|
||||||
setCameraJobId(item.id);
|
setCameraJobId(item.id);
|
||||||
|
setTmTicketJobId(item.id);
|
||||||
setCameraJob(item);
|
setCameraJob(item);
|
||||||
navigation.navigate("MediaBrowserTab");
|
navigation.navigate("MediaBrowserTab");
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { FlatList, RefreshControl, StyleSheet, Text, View } from "react-native";
|
||||||
|
import { Card, DataTable } from "react-native-paper";
|
||||||
|
import { GET_LINE_TICKET_BY_PK } from "../../graphql/jobs.queries";
|
||||||
|
import ErrorDisplay from "../error-display/error-display.component";
|
||||||
|
import { useQuery } from "@apollo/client";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
|
||||||
|
export function LaborAllocationsTableContainer({ jobId }) {
|
||||||
|
console.log("LaborAllocationsTableContainer, jobId", jobId);
|
||||||
|
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const { loading, error, data, refetch } = useQuery(GET_LINE_TICKET_BY_PK, {
|
||||||
|
variables: { id: jobId },
|
||||||
|
skip: !!!jobId,
|
||||||
|
fetchPolicy: "network-only",
|
||||||
|
nextFetchPolicy: "network-only",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("LaborAllocationsTableContainer, data", data);
|
||||||
|
if (error) return <ErrorDisplay errorMessage={error.message} />;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View>
|
||||||
|
{data ? (
|
||||||
|
<LaborAllocationsTableContainer
|
||||||
|
loading={loading}
|
||||||
|
refetch={refetch}
|
||||||
|
jobId={jobId}
|
||||||
|
joblines={data ? data.joblines : []}
|
||||||
|
timetickets={data ? data.timetickets : []}
|
||||||
|
adjustments={data ? data.jobs_by_pk.lbr_adjustments : []}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const localStyles = StyleSheet.create({});
|
||||||
|
export default connect(null, null)(LaborAllocationsTableContainer);
|
||||||
@@ -243,13 +243,13 @@ headerArea:{
|
|||||||
margin:1
|
margin:1
|
||||||
},
|
},
|
||||||
footertext:{
|
footertext:{
|
||||||
flex:1, textAlign:'center', textAlignVertical:'center',margin:1
|
flex:1, textAlign:'center', textAlignVertical:'center',margin:1,paddingBottom:8
|
||||||
},
|
},
|
||||||
headertext:{
|
headertext:{
|
||||||
flex:1, textAlign:'center', textAlignVertical:'center',backgroundColor:'blue',margin:1
|
flex:1, textAlign:'center', textAlignVertical:'center',margin:1,paddingBottom:8
|
||||||
},
|
},
|
||||||
headertextAdjusts:{
|
headertextAdjusts:{
|
||||||
flex:1, textAlign:'center', textAlignVertical:'center',backgroundColor:'green',margin:1
|
flex:1, textAlign:'center', textAlignVertical:'center',margin:1,paddingBottom:8
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ import ScreenSettingsComponent from "../screen-settings/screen-settings.componen
|
|||||||
import ScreenSignIn from "../screen-sign-in/screen-sign-in.component";
|
import ScreenSignIn from "../screen-sign-in/screen-sign-in.component";
|
||||||
import ScreenSplash from "../screen-splash/screen-splash.component";
|
import ScreenSplash from "../screen-splash/screen-splash.component";
|
||||||
|
|
||||||
//TODO Inprogress JF add import for screens for time ticket browser here
|
|
||||||
import EmployeeSignIn from "../screen-employee-sign-in/screen-employee-sign-in.component";
|
import EmployeeSignIn from "../screen-employee-sign-in/screen-employee-sign-in.component";
|
||||||
import ScreenTimeTicketBrowser from "../screen-time-ticket-browser/screen-time-ticket-browser.component";
|
import ScreenTimeTicketBrowser from "../screen-time-ticket-browser/screen-time-ticket-browser.component";
|
||||||
import SignOutButton from "../Buttons/employee-sign-out-button.component";
|
import SignOutButton from "../Buttons/employee-sign-out-button.component";
|
||||||
import AddTimeTicketButton from "../Buttons/create-time-ticket-button.component";
|
import AddTimeTicketButton from "../Buttons/create-time-ticket-button.component";
|
||||||
import ScreenTimeTicketCreate from "../time-ticket/screen-time-ticket-create.component";
|
import ScreenTimeTicketCreate from "../time-ticket/screen-time-ticket-create.component";
|
||||||
|
import ScreenTimeTicketClockoffComponent from "../time-ticket/screen-time-ticket-clockoff.component";
|
||||||
|
|
||||||
const ActiveJobStack = createNativeStackNavigator();
|
const ActiveJobStack = createNativeStackNavigator();
|
||||||
const MoreStack = createNativeStackNavigator();
|
const MoreStack = createNativeStackNavigator();
|
||||||
@@ -123,7 +123,6 @@ const MoreStackNavigator = () => (
|
|||||||
</MoreStack.Navigator>
|
</MoreStack.Navigator>
|
||||||
);
|
);
|
||||||
|
|
||||||
//ADDED JF TimeTicketBrowserStackNavigator for navigating the stack and logout on appState background
|
|
||||||
const TimeTicketBrowserStackNavigator = connect(
|
const TimeTicketBrowserStackNavigator = connect(
|
||||||
mapStateToProps2,
|
mapStateToProps2,
|
||||||
mapDispatchToProps2
|
mapDispatchToProps2
|
||||||
@@ -138,7 +137,6 @@ const TimeTicketBrowserStackNavigator = connect(
|
|||||||
// if (appState.current.match(/active/) && nextAppState === "inactive") {
|
// if (appState.current.match(/active/) && nextAppState === "inactive") {
|
||||||
// console.log("App is about to be inactive");
|
// console.log("App is about to be inactive");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (
|
if (
|
||||||
appState.current.match(/active|inactive/) &&
|
appState.current.match(/active|inactive/) &&
|
||||||
nextAppState === "background"
|
nextAppState === "background"
|
||||||
@@ -146,12 +144,9 @@ const TimeTicketBrowserStackNavigator = connect(
|
|||||||
// console.log("App is about to be background");
|
// console.log("App is about to be background");
|
||||||
signOut();
|
signOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if ( appState.current.match(/inactive/)) { console.log("App has come to the inactive"); }
|
// if ( appState.current.match(/inactive/)) { console.log("App has come to the inactive"); }
|
||||||
// if (appState.current.match(/background/)) { console.log("App has come to the background");}
|
// if (appState.current.match(/background/)) { console.log("App has come to the background");}
|
||||||
|
|
||||||
appState.current = nextAppState;
|
appState.current = nextAppState;
|
||||||
// console.log("AppState", appState.current);
|
|
||||||
});
|
});
|
||||||
return () => {
|
return () => {
|
||||||
subscription.remove();
|
subscription.remove();
|
||||||
@@ -188,6 +183,13 @@ const TimeTicketBrowserStackNavigator = connect(
|
|||||||
})}
|
})}
|
||||||
component={ScreenTimeTicketCreate}
|
component={ScreenTimeTicketCreate}
|
||||||
/>
|
/>
|
||||||
|
<TimeTicketBrowserStack.Screen
|
||||||
|
name="TimeTicketClockOff"
|
||||||
|
options={() => ({
|
||||||
|
title: "Clock Off",
|
||||||
|
})}
|
||||||
|
component={ScreenTimeTicketClockoffComponent}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<TimeTicketBrowserStack.Screen
|
<TimeTicketBrowserStack.Screen
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
} from "../../redux/timetickets/timetickets.selectors";
|
} from "../../redux/timetickets/timetickets.selectors";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { EmployeeClockedInList } from "../time-ticket-lists/employee-clockedin-list.component";
|
import { EmployeeClockedInList } from "../time-ticket-lists/employee-clockedin-list.component";
|
||||||
|
import { useNavigation } from "@react-navigation/native";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
currentEmployee: selectCurrentEmployee,
|
currentEmployee: selectCurrentEmployee,
|
||||||
@@ -50,6 +51,7 @@ export function ScreenTimeTicketBrowser({
|
|||||||
currentSelectedTimeTicketJob,
|
currentSelectedTimeTicketJob,
|
||||||
currentSelectedTimeTicketJobId,
|
currentSelectedTimeTicketJobId,
|
||||||
}) {
|
}) {
|
||||||
|
const navigation = useNavigation();
|
||||||
//const employeeId = currentEmployee.technician.id;
|
//const employeeId = currentEmployee.technician.id;
|
||||||
const [currentSCC, setCurrentSCC] = useState(null);
|
const [currentSCC, setCurrentSCC] = useState(null);
|
||||||
// const [currentSJob, setCurrentSJob] = useState(null);
|
// const [currentSJob, setCurrentSJob] = useState(null);
|
||||||
@@ -128,8 +130,7 @@ export function ScreenTimeTicketBrowser({
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<Text>Time Ticket List goes here</Text>
|
{/* <Button
|
||||||
<Button
|
|
||||||
mode="outlined"
|
mode="outlined"
|
||||||
loading={loaderGettingRates}
|
loading={loaderGettingRates}
|
||||||
//onPress={() => getRates(currentEmployee)}
|
//onPress={() => getRates(currentEmployee)}
|
||||||
@@ -137,8 +138,8 @@ export function ScreenTimeTicketBrowser({
|
|||||||
createTheTimeTicketOBJ(currentEmployee, currentBodyshop, currentSCC, currentSJobId)
|
createTheTimeTicketOBJ(currentEmployee, currentBodyshop, currentSCC, currentSJobId)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Text>text here</Text>
|
<Text>createTheTimeTicketOBJTest</Text>
|
||||||
</Button>
|
</Button> */}
|
||||||
{/* {signingErrorMsg} */}
|
{/* {signingErrorMsg} */}
|
||||||
<JobIdSearchSelect
|
<JobIdSearchSelect
|
||||||
currentValue={currentSJobId}
|
currentValue={currentSJobId}
|
||||||
|
|||||||
@@ -2,30 +2,41 @@ import { Ionicons } from "@expo/vector-icons";
|
|||||||
import { useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Button, List, Title, Card, Text } from "react-native-paper";
|
import { Button, Card, Text } from "react-native-paper";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { OwnerNameDisplayFunction } from "../owner-name-display/owner-name-display.component";
|
import { OwnerNameDisplayFunction } from "../owner-name-display/owner-name-display.component";
|
||||||
import { DateTimeFormatter } from "../../util/DateFormater";
|
import { DateTimeFormatter } from "../../util/DateFormater";
|
||||||
|
// import { setTimeTicketJobId } from "../../redux/timetickets/timetickets.actions";
|
||||||
|
import { setTmTicketJobId } from "../../redux/app/app.actions";
|
||||||
|
import { logImEXEvent } from "../../firebase/firebase.analytics";
|
||||||
|
|
||||||
// const mapStateToProps = createStructuredSelector({});
|
const mapStateToProps = createStructuredSelector({});
|
||||||
// const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
// setCameraJobId: (id) => dispatch(setCameraJobId(id)),
|
// setTimeTicketJobId: (jobId) =>dispatch(setTimeTicketJobId({jobId})),
|
||||||
// setCameraJob: (job) => dispatch(setCameraJob(job)),
|
setTmTicketJobId:(id) => dispatch(setTmTicketJobId(id)),
|
||||||
// });
|
});
|
||||||
|
|
||||||
export function ClockedinListItem({ ticket }) {
|
export function ClockedinListItem({ setTmTicketJobId, ticket }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
|
|
||||||
const onPress = () => {
|
const onPress = (ticket, setCameraJobId) => {
|
||||||
// logImEXEvent("imexmobile_view_job_detail");
|
|
||||||
// navigation.push("JobDetail", {
|
|
||||||
// jobId: item.id,
|
|
||||||
// title: item.ro_number || t("general.labels.na"),
|
|
||||||
// job: item,
|
|
||||||
// });
|
|
||||||
console.log("ClockedinListItem, onPress called");
|
console.log("ClockedinListItem, onPress called");
|
||||||
|
console.log("ClockedinListItem, ticket", ticket);
|
||||||
|
setTimeTicketJobId(ticket.jobid);
|
||||||
|
// logImEXEvent("imexmobile_view_job_detail");
|
||||||
|
navigation.push("TimeTicketClockOff", {
|
||||||
|
jobId: ticket.jobid, //item.id,
|
||||||
|
timeTicketId: ticket.id,
|
||||||
|
//completedCallback: refetch,
|
||||||
|
});
|
||||||
|
// navigation.push("JobDetail", {
|
||||||
|
// jobId: item.id,
|
||||||
|
// timeTicketId: item.ro_number || t("general.labels.na"),
|
||||||
|
// job: item,
|
||||||
|
// });
|
||||||
|
// () => {navigation.navigate("TimeTicketClockOff");}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -36,18 +47,20 @@ export function ClockedinListItem({ ticket }) {
|
|||||||
} ${OwnerNameDisplayFunction(ticket.job)}`}
|
} ${OwnerNameDisplayFunction(ticket.job)}`}
|
||||||
/>
|
/>
|
||||||
<Card.Content>
|
<Card.Content>
|
||||||
<Text>Vehicle :
|
<Text>
|
||||||
{`${ticket.job.v_model_yr || ""} ${
|
Vehicle :
|
||||||
ticket.job.v_make_desc || ""
|
{`${ticket.job.v_model_yr || ""} ${ticket.job.v_make_desc || ""} ${
|
||||||
} ${ticket.job.v_model_desc || ""}`}
|
ticket.job.v_model_desc || ""
|
||||||
|
}`}
|
||||||
</Text>
|
</Text>
|
||||||
<Text>
|
<Text>
|
||||||
Clocked In : <DateTimeFormatter>{ticket.clockon}</DateTimeFormatter>
|
Clocked In : <DateTimeFormatter>{ticket.clockon}</DateTimeFormatter>
|
||||||
</Text>
|
</Text>
|
||||||
<Text>
|
<Text>
|
||||||
Cost Center : {ticket.cost_center === "timetickets.labels.shift"
|
Cost Center :{" "}
|
||||||
? t(ticket.cost_center)
|
{ticket.cost_center === "timetickets.labels.shift"
|
||||||
: ticket.cost_center}
|
? t(ticket.cost_center)
|
||||||
|
: ticket.cost_center}
|
||||||
</Text>
|
</Text>
|
||||||
</Card.Content>
|
</Card.Content>
|
||||||
<Card.Actions>
|
<Card.Actions>
|
||||||
@@ -56,8 +69,25 @@ export function ClockedinListItem({ ticket }) {
|
|||||||
timeTicketId={ticket.id}
|
timeTicketId={ticket.id}
|
||||||
completedCallback={refetch}
|
completedCallback={refetch}
|
||||||
/> */}
|
/> */}
|
||||||
<Button
|
<Button
|
||||||
mode="outlined" onPress={() => onPress}>Clock Out</Button>
|
mode="outlined"
|
||||||
|
onPress={() => {
|
||||||
|
logImEXEvent("imexmobile_setcamerajobid_row");
|
||||||
|
// setTmTicketJobId(ticket.id);
|
||||||
|
// console.log("ticket.jobid is :",ticket.jobid );
|
||||||
|
// console.log("setTimeTicketJobId is :",setTimeTicketJobId );
|
||||||
|
// console.log("ham is :",setTimeTicketJobId );
|
||||||
|
// if (typeof ham === 'undefined') {
|
||||||
|
// console.error("yo dog, setTimeTicketJobId is undefined!");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// setTimeTicketJobId(ticket.jobid);
|
||||||
|
navigation.navigate("TimeTicketClockOff");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Clock Out
|
||||||
|
</Button>
|
||||||
</Card.Actions>
|
</Card.Actions>
|
||||||
</Card>
|
</Card>
|
||||||
// <List.Item
|
// <List.Item
|
||||||
@@ -91,4 +121,4 @@ export function ClockedinListItem({ ticket }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(null, null)(ClockedinListItem);
|
export default connect(mapStateToProps, mapDispatchToProps)(ClockedinListItem);
|
||||||
|
|||||||
@@ -105,7 +105,4 @@ const onRefresh = async () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(
|
export default connect(mapStateToProps,null)(EmployeeClockedInList);
|
||||||
mapStateToProps,
|
|
||||||
mapDispatchToProps
|
|
||||||
)(EmployeeClockedInList);
|
|
||||||
|
|||||||
218
components/time-ticket/screen-time-ticket-clockoff.component.jsx
Normal file
218
components/time-ticket/screen-time-ticket-clockoff.component.jsx
Normal file
@@ -0,0 +1,218 @@
|
|||||||
|
import { Formik } from "formik";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { StyleSheet, Text, View, ScrollView } from "react-native";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import { Button, TextInput } from "react-native-paper";
|
||||||
|
import { CostCenterSelect } from "../Selects/select-cost-center";
|
||||||
|
import {
|
||||||
|
selectCurrentEmployee,
|
||||||
|
selectRates,
|
||||||
|
} from "../../redux/employee/employee.selectors";
|
||||||
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
|
import LaborAllocationsTable from "../labor-allocations-table/labor-allocations-table.component";
|
||||||
|
import { UPDATE_TIME_TICKET } from "../../graphql/timetickets.queries";
|
||||||
|
import { useMutation } from "@apollo/client";
|
||||||
|
import { selectCurrentTmTicketJobId } from "../../redux/app/app.selectors";
|
||||||
|
import ErrorDisplay from "../error-display/error-display.component";
|
||||||
|
// import { selectCurrentTimeTicketJobId } from "../../redux/timetickets/timetickets.selectors";
|
||||||
|
|
||||||
|
//TODO add props needed for call
|
||||||
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
currentEmployee: selectCurrentEmployee,
|
||||||
|
currentRatesNCostCenters: selectRates,
|
||||||
|
currentBodyshop: selectBodyshop,
|
||||||
|
currentTmTicketJobId: selectCurrentTmTicketJobId,
|
||||||
|
// currentJobId: selectCurrentTimeTicketJobId
|
||||||
|
});
|
||||||
|
// const mapDispatchToProps = (dispatch) => ({});
|
||||||
|
|
||||||
|
export function TimeTicketClockOff({
|
||||||
|
currentEmployee,
|
||||||
|
currentRatesNCostCenters,
|
||||||
|
currentBodyshop,
|
||||||
|
currentTmTicketJobId,
|
||||||
|
}) {
|
||||||
|
console.log("TimeTicketClockOff, currentEmployee :", currentEmployee);
|
||||||
|
//console.log("TimeTicketClockOff, currentRatesNCostCenters :", currentRatesNCostCenters );
|
||||||
|
console.log("TimeTicketClockOff, currentBodyshop :", currentBodyshop);
|
||||||
|
|
||||||
|
console.log("TimeTicketClockOff, currentTmTicketJobId :", currentTmTicketJobId);
|
||||||
|
// console.log("TimeTicketClockOff, jobId :", jobId);
|
||||||
|
// console.log("TimeTicketClockOff, timeTicketId :", timeTicketId);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
// const [isDatePickerVisible, setDatePickerVisibility] = useState(false);
|
||||||
|
// const [date2, setDate2] = useState(new Date());
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const [currentSCC, setCurrentSCC] = useState(null);
|
||||||
|
// const [currentSJob, setCurrentSJob] = useState(null);
|
||||||
|
const [currentSJobId, setCurrentSJobId] = useState(currentTmTicketJobId ? currentTmTicketJobId : null);
|
||||||
|
// const [updateTimeticket] = useMutation(UPDATE_TIME_TICKET);
|
||||||
|
// const wrapperSetCurrentSJobState = useCallback(
|
||||||
|
// (val) => {
|
||||||
|
// setCurrentSJob(val);
|
||||||
|
// },
|
||||||
|
// [setCurrentSJob]
|
||||||
|
// );
|
||||||
|
|
||||||
|
// const showDatePicker = () => {
|
||||||
|
// setDatePickerVisibility(true);
|
||||||
|
// };
|
||||||
|
// const hideDatePicker = () => {
|
||||||
|
// setDatePickerVisibility(false);
|
||||||
|
// };
|
||||||
|
// const handleConfirm = (date) => {
|
||||||
|
// setDate2(date);
|
||||||
|
// //console.war1n("A date has been picked: ", date);
|
||||||
|
// hideDatePicker();
|
||||||
|
// };
|
||||||
|
const formSubmit = (values) => {
|
||||||
|
console.log("values", values);
|
||||||
|
//Dialog.alert({ content: <pre>{JSON.stringify(values, null, 2)}</pre> });
|
||||||
|
//TODO update with start call for create time ticket
|
||||||
|
};
|
||||||
|
|
||||||
|
// const handleFinish = async (values) => {
|
||||||
|
// //logImEXEvent("tech_clock_out_job");
|
||||||
|
|
||||||
|
// setLoading(true);
|
||||||
|
// const result = await updateTimeticket({
|
||||||
|
// variables: {
|
||||||
|
// timeticketId: timeTicketId,
|
||||||
|
// timeticket: {
|
||||||
|
// clockoff: (await axios.post("/utils/time")).data,
|
||||||
|
// ...values,
|
||||||
|
// rate: currentSCC?.rate,
|
||||||
|
// // emps &&
|
||||||
|
// // emps.rates.filter((r) => r.cost_center === values.cost_center)[0]
|
||||||
|
// // ?.rate,
|
||||||
|
// flat_rate: currentEmployee && currentEmployee?.technician?.flat_rate,
|
||||||
|
// 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 (!!result.errors) {
|
||||||
|
// console.log("Error handleFinish clock off");
|
||||||
|
|
||||||
|
// //if (error) return <ErrorDisplay errorMessage={error.message} />;
|
||||||
|
|
||||||
|
// // notification["error"]({
|
||||||
|
// // message: t("timetickets.errors.clockingout", {
|
||||||
|
// // message: JSON.stringify(result.errors),
|
||||||
|
// // }),
|
||||||
|
// // });
|
||||||
|
// } else {
|
||||||
|
// console.log("success");
|
||||||
|
// // notification["success"]({
|
||||||
|
// // message: t("timetickets.successes.clockedout"),
|
||||||
|
// // });
|
||||||
|
// }
|
||||||
|
// setLoading(false);
|
||||||
|
// if (completedCallback) completedCallback();
|
||||||
|
// };
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={localStyles.content}>
|
||||||
|
<ScrollView contentContainerStyle={{ flexGrow: 1 }}>
|
||||||
|
<Formik
|
||||||
|
initialValues={{
|
||||||
|
costcenter: { currentSCC },
|
||||||
|
productivehours: "",
|
||||||
|
actualhours: "",
|
||||||
|
}}
|
||||||
|
onSubmit={formSubmit}
|
||||||
|
>
|
||||||
|
{({ handleChange, handleBlur, handleSubmit, values }) => (
|
||||||
|
<View style={localStyles.topTimeTicketContainer}>
|
||||||
|
{/* <JobIdSearchSelect
|
||||||
|
currentValue={currentSJobId}
|
||||||
|
onJobSelected={setCurrentSJobId}
|
||||||
|
convertedOnly={!currentBodyshop.tt_allow_post_to_invoiced}
|
||||||
|
notExported={!currentBodyshop.tt_allow_post_to_invoiced}
|
||||||
|
/> */}
|
||||||
|
<TextInput
|
||||||
|
style={localStyles.inputStyle}
|
||||||
|
mode="outlined"
|
||||||
|
onChangeText={handleChange("actualhours")}
|
||||||
|
onBlur={handleBlur("actualhours")}
|
||||||
|
value={values.actualhours}
|
||||||
|
label={"Actual Hours"}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
style={localStyles.inputStyle}
|
||||||
|
mode="outlined"
|
||||||
|
onChangeText={handleChange("productivehours")}
|
||||||
|
onBlur={handleBlur("productivehours")}
|
||||||
|
value={values.productivehours}
|
||||||
|
label={"Productive Hours"}
|
||||||
|
/>
|
||||||
|
<CostCenterSelect
|
||||||
|
currentRatesNCostCenters={currentRatesNCostCenters}
|
||||||
|
currentValue={currentSCC}
|
||||||
|
onValueSelected={setCurrentSCC}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
style={localStyles.input}
|
||||||
|
// onPress={handleSubmit}
|
||||||
|
title="Submit"
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 12 }}>Clock Off</Text>
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</Formik>
|
||||||
|
</ScrollView>
|
||||||
|
<View style={{ flexGrow: 1 }}>
|
||||||
|
<LaborAllocationsTable jobId={currentSJobId?.value} />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, null)(TimeTicketClockOff);
|
||||||
|
|
||||||
|
const localStyles = StyleSheet.create({
|
||||||
|
content: {
|
||||||
|
display: "flex",
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
topContainer: {},
|
||||||
|
bottomContainer: {},
|
||||||
|
input: {},
|
||||||
|
dateButton: {
|
||||||
|
marginVertical: 4,
|
||||||
|
marginHorizontal: 16,
|
||||||
|
height: 48,
|
||||||
|
justifyContent: "center",
|
||||||
|
alignContent: "center",
|
||||||
|
borderColor: "blue",
|
||||||
|
borderWidth: 0.8,
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
textForButton: {
|
||||||
|
flex: 1,
|
||||||
|
justifyContent: "center",
|
||||||
|
alignContent: "center",
|
||||||
|
},
|
||||||
|
inputStyle: {
|
||||||
|
marginVertical: 4,
|
||||||
|
marginHorizontal: 16,
|
||||||
|
height: 48,
|
||||||
|
fontSize: 16,
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -17,6 +17,8 @@ import { useCallback } from "react";
|
|||||||
// import LaborAllocationsTable from "../labor-allocations-table/labor-allocations-table.component";
|
// import LaborAllocationsTable from "../labor-allocations-table/labor-allocations-table.component";
|
||||||
import LaborAllocationsTable from "../labor-allocations-table/labor-allocations-table.component";
|
import LaborAllocationsTable from "../labor-allocations-table/labor-allocations-table.component";
|
||||||
|
|
||||||
|
import ErrorDisplay from "../error-display/error-display.component";
|
||||||
|
|
||||||
//TODO add props needed for call
|
//TODO add props needed for call
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
currentEmployee: selectCurrentEmployee,
|
currentEmployee: selectCurrentEmployee,
|
||||||
|
|||||||
@@ -27,3 +27,8 @@ export const documentUploadFailure = (error) => ({
|
|||||||
export const toggleDeleteAfterUpload = () => ({
|
export const toggleDeleteAfterUpload = () => ({
|
||||||
type: AppActionTypes.TOGGLE_DLETE_AFTER_UPLOAD,
|
type: AppActionTypes.TOGGLE_DLETE_AFTER_UPLOAD,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const setTmTicketJobId = (jobId) => ({
|
||||||
|
type: AppActionTypes.SET_TM_TICKET_JOB_ID,
|
||||||
|
payload: jobId,
|
||||||
|
});
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const INITIAL_STATE = {
|
|||||||
documentUploadInProgress: null,
|
documentUploadInProgress: null,
|
||||||
documentUploadError: null,
|
documentUploadError: null,
|
||||||
deleteAfterUpload: false,
|
deleteAfterUpload: false,
|
||||||
|
tmTicketJobId: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const appReducer = (state = INITIAL_STATE, action) => {
|
const appReducer = (state = INITIAL_STATE, action) => {
|
||||||
@@ -43,6 +44,11 @@ const appReducer = (state = INITIAL_STATE, action) => {
|
|||||||
...state,
|
...state,
|
||||||
deleteAfterUpload: !state.deleteAfterUpload,
|
deleteAfterUpload: !state.deleteAfterUpload,
|
||||||
};
|
};
|
||||||
|
case AppActionTypes.SET_TM_TICKET_JOB_ID:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
tmTicketJobId: action.payload,
|
||||||
|
};
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,3 +26,8 @@ export const selectDeleteAfterUpload = createSelector(
|
|||||||
[selectApp],
|
[selectApp],
|
||||||
(app) => app.deleteAfterUpload
|
(app) => app.deleteAfterUpload
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const selectCurrentTmTicketJobId = createSelector(
|
||||||
|
[selectApp],
|
||||||
|
(app) => app.tmTicketJobId
|
||||||
|
);
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ const AppActionTypes = {
|
|||||||
DOCUMENT_UPLOAD_SUCCESS: "DOCUMENT_UPLOAD_SUCCESS",
|
DOCUMENT_UPLOAD_SUCCESS: "DOCUMENT_UPLOAD_SUCCESS",
|
||||||
DOCUMENT_UPLOAD_FAILURE: "DOCUMENT_UPLOAD_FAILURE",
|
DOCUMENT_UPLOAD_FAILURE: "DOCUMENT_UPLOAD_FAILURE",
|
||||||
TOGGLE_DLETE_AFTER_UPLOAD: "TOGGLE_DLETE_AFTER_UPLOAD",
|
TOGGLE_DLETE_AFTER_UPLOAD: "TOGGLE_DLETE_AFTER_UPLOAD",
|
||||||
|
SET_TM_TICKET_JOB_ID: "SET_TM_TICKET_JOB_ID"
|
||||||
};
|
};
|
||||||
export default AppActionTypes;
|
export default AppActionTypes;
|
||||||
|
|||||||
@@ -6,5 +6,5 @@ import { employeeSagas } from "./employee/employee.sagas";
|
|||||||
import { timeTicketsSagas } from "./timetickets/timetickets.sagas";
|
import { timeTicketsSagas } from "./timetickets/timetickets.sagas";
|
||||||
|
|
||||||
export default function* rootSaga() {
|
export default function* rootSaga() {
|
||||||
yield all([call(userSagas), call(appSagas), call(photosSagas), call(employeeSagas), call(timeTicketsSagas)]);
|
yield all([call(userSagas), call(appSagas), call(photosSagas), call(employeeSagas), call(timeTicketsSagas),]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import TimeTicketsActionTypes from "./timetickets.types";
|
import TimeTicketsActionTypes from "./timetickets.types";
|
||||||
|
|
||||||
export const setTimeTicket = (timeTicket) => ({
|
export const setTimeTicket = (timeTicket) => ({
|
||||||
type: TimeTicketsActionTypes.SET_TIME_TICKET,
|
type: TimeTicketsActionTypes.SET_TIME_TICKET,
|
||||||
payload: timeTicket,
|
payload: timeTicket,
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
import TimeTicketsActionTypes from "./timetickets.types";
|
import TimeTicketsActionTypes from "./timetickets.types";
|
||||||
|
|
||||||
const INITIAL_STATE = {
|
const INITIAL_STATE = {
|
||||||
timeTicket: null,
|
ttjobid:null,
|
||||||
timeTickets: [],
|
timeticketjobid: null,
|
||||||
timeTicketJobId: null,
|
|
||||||
timeTicketJob: null,
|
timeTicketJob: null,
|
||||||
uploadTimeTicketInProgress: false,
|
uploadTimeTicketInProgress: false,
|
||||||
uploadTimeTicketError: null,
|
uploadTimeTicketError: null,
|
||||||
@@ -14,22 +13,19 @@ const timeTicketsReducer = (state = INITIAL_STATE, action) => {
|
|||||||
case TimeTicketsActionTypes.SET_TIME_TICKET:
|
case TimeTicketsActionTypes.SET_TIME_TICKET:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
timeTicket: action.payload,
|
timeTicket: action.payload
|
||||||
};
|
};
|
||||||
case TimeTicketsActionTypes.SET_TIME_TICKET_JOB_ID:
|
case TimeTicketsActionTypes.SET_TIME_TICKET_JOB_ID:
|
||||||
return {
|
return { ...state,timeticketjobid: action.payload };
|
||||||
...state,
|
|
||||||
timeTicketJobId: action.payload,
|
|
||||||
};
|
|
||||||
case TimeTicketsActionTypes.SET_TIME_TICKET_JOB:
|
case TimeTicketsActionTypes.SET_TIME_TICKET_JOB:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
timeTicketJob: action.payload,
|
timeTicketJob: action.payload
|
||||||
};
|
};
|
||||||
case TimeTicketsActionTypes.TIME_TICKET_CREATE_START:
|
case TimeTicketsActionTypes.TIME_TICKET_CREATE_START:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
uploadTimeTicketInProgress: true,
|
uploadTimeTicketInProgress: true
|
||||||
};
|
};
|
||||||
case TimeTicketsActionTypes.TIME_TICKET_CREATE_SUCCESS:
|
case TimeTicketsActionTypes.TIME_TICKET_CREATE_SUCCESS:
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -29,39 +29,39 @@ export function* insertNewTimeTicket({ payload: { timeTicketInput } }) {
|
|||||||
// pin: pin,
|
// pin: pin,
|
||||||
// });
|
// });
|
||||||
// const { valid, data, error } = response.data;
|
// const { valid, data, error } = response.data;
|
||||||
const result = yield client.mutate({
|
// const result = yield client.mutate({
|
||||||
mutation: INSERT_NEW_TIME_TICKET,
|
// mutation: INSERT_NEW_TIME_TICKET,
|
||||||
variables: {
|
// variables: {
|
||||||
timeTicketInput: [
|
// timeTicketInput: [
|
||||||
// {
|
// // {
|
||||||
// bodyshopid: bodyshop.id,
|
// // bodyshopid: bodyshop.id,
|
||||||
// employeeid: technician.id,
|
// // employeeid: technician.id,
|
||||||
// date: moment(theTime).format("YYYY-MM-DD"),
|
// // date: moment(theTime).format("YYYY-MM-DD"),
|
||||||
// clockon: moment(theTime),
|
// // clockon: moment(theTime),
|
||||||
// jobid: values.jobid,
|
// // jobid: values.jobid,
|
||||||
// cost_center: values.cost_center,
|
// // cost_center: values.cost_center,
|
||||||
// ciecacode:
|
// // ciecacode:
|
||||||
// bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
|
// // bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
|
||||||
// ? values.cost_center
|
// // ? values.cost_center
|
||||||
// : Object.keys(
|
// // : Object.keys(
|
||||||
// bodyshop.md_responsibility_centers.defaults.costs
|
// // bodyshop.md_responsibility_centers.defaults.costs
|
||||||
// ).find((key) => {
|
// // ).find((key) => {
|
||||||
// return (
|
// // return (
|
||||||
// bodyshop.md_responsibility_centers.defaults.costs[key] ===
|
// // bodyshop.md_responsibility_centers.defaults.costs[key] ===
|
||||||
// values.cost_center
|
// // values.cost_center
|
||||||
// );
|
// // );
|
||||||
// }),
|
// // }),
|
||||||
// },
|
// // },
|
||||||
],
|
// ],
|
||||||
},
|
// },
|
||||||
});
|
// });
|
||||||
console.log(result);
|
// console.log(result);
|
||||||
const { valid, data, error } = result.data;
|
// const { valid, data, error } = result.data;
|
||||||
if (valid) {
|
// if (valid) {
|
||||||
yield put(timeTicketCreateSuccess(data));
|
// yield put(timeTicketCreateSuccess(data));
|
||||||
} else {
|
// } else {
|
||||||
yield put(timeTicketCreateFailure(error));
|
// yield put(timeTicketCreateFailure(error));
|
||||||
}
|
// }
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
yield put(timeTicketCreateFailure(error));
|
yield put(timeTicketCreateFailure(error));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,3 +14,4 @@ export const selectCurrentTimeTicket = createSelector(
|
|||||||
[selectTimeTicketsState],
|
[selectTimeTicketsState],
|
||||||
(timeTickets) => timeTickets.timeTicket
|
(timeTickets) => timeTickets.timeTicket
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user