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 { createStructuredSelector } from "reselect";
|
||||
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 mapDispatchToProps = (dispatch) => ({
|
||||
setCameraJobId: (id) => dispatch(setCameraJobId(id)),
|
||||
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 navigation = useNavigation();
|
||||
// const _swipeableRow = useRef(null);
|
||||
@@ -71,6 +72,7 @@ export function JobListItem({ setCameraJob, setCameraJobId, item }) {
|
||||
onPress={() => {
|
||||
logImEXEvent("imexmobile_setcamerajobid_row");
|
||||
setCameraJobId(item.id);
|
||||
setTmTicketJobId(item.id);
|
||||
setCameraJob(item);
|
||||
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
|
||||
},
|
||||
footertext:{
|
||||
flex:1, textAlign:'center', textAlignVertical:'center',margin:1
|
||||
flex:1, textAlign:'center', textAlignVertical:'center',margin:1,paddingBottom:8
|
||||
},
|
||||
headertext:{
|
||||
flex:1, textAlign:'center', textAlignVertical:'center',backgroundColor:'blue',margin:1
|
||||
flex:1, textAlign:'center', textAlignVertical:'center',margin:1,paddingBottom:8
|
||||
},
|
||||
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 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 ScreenTimeTicketBrowser from "../screen-time-ticket-browser/screen-time-ticket-browser.component";
|
||||
import SignOutButton from "../Buttons/employee-sign-out-button.component";
|
||||
import AddTimeTicketButton from "../Buttons/create-time-ticket-button.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 MoreStack = createNativeStackNavigator();
|
||||
@@ -123,7 +123,6 @@ const MoreStackNavigator = () => (
|
||||
</MoreStack.Navigator>
|
||||
);
|
||||
|
||||
//ADDED JF TimeTicketBrowserStackNavigator for navigating the stack and logout on appState background
|
||||
const TimeTicketBrowserStackNavigator = connect(
|
||||
mapStateToProps2,
|
||||
mapDispatchToProps2
|
||||
@@ -138,7 +137,6 @@ const TimeTicketBrowserStackNavigator = connect(
|
||||
// if (appState.current.match(/active/) && nextAppState === "inactive") {
|
||||
// console.log("App is about to be inactive");
|
||||
// }
|
||||
|
||||
if (
|
||||
appState.current.match(/active|inactive/) &&
|
||||
nextAppState === "background"
|
||||
@@ -146,12 +144,9 @@ const TimeTicketBrowserStackNavigator = connect(
|
||||
// console.log("App is about to be background");
|
||||
signOut();
|
||||
}
|
||||
|
||||
// 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");}
|
||||
|
||||
appState.current = nextAppState;
|
||||
// console.log("AppState", appState.current);
|
||||
});
|
||||
return () => {
|
||||
subscription.remove();
|
||||
@@ -188,6 +183,13 @@ const TimeTicketBrowserStackNavigator = connect(
|
||||
})}
|
||||
component={ScreenTimeTicketCreate}
|
||||
/>
|
||||
<TimeTicketBrowserStack.Screen
|
||||
name="TimeTicketClockOff"
|
||||
options={() => ({
|
||||
title: "Clock Off",
|
||||
})}
|
||||
component={ScreenTimeTicketClockoffComponent}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<TimeTicketBrowserStack.Screen
|
||||
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
} from "../../redux/timetickets/timetickets.selectors";
|
||||
import moment from "moment";
|
||||
import { EmployeeClockedInList } from "../time-ticket-lists/employee-clockedin-list.component";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentEmployee: selectCurrentEmployee,
|
||||
@@ -50,6 +51,7 @@ export function ScreenTimeTicketBrowser({
|
||||
currentSelectedTimeTicketJob,
|
||||
currentSelectedTimeTicketJobId,
|
||||
}) {
|
||||
const navigation = useNavigation();
|
||||
//const employeeId = currentEmployee.technician.id;
|
||||
const [currentSCC, setCurrentSCC] = useState(null);
|
||||
// const [currentSJob, setCurrentSJob] = useState(null);
|
||||
@@ -128,8 +130,7 @@ export function ScreenTimeTicketBrowser({
|
||||
};
|
||||
return (
|
||||
<View>
|
||||
<Text>Time Ticket List goes here</Text>
|
||||
<Button
|
||||
{/* <Button
|
||||
mode="outlined"
|
||||
loading={loaderGettingRates}
|
||||
//onPress={() => getRates(currentEmployee)}
|
||||
@@ -137,8 +138,8 @@ export function ScreenTimeTicketBrowser({
|
||||
createTheTimeTicketOBJ(currentEmployee, currentBodyshop, currentSCC, currentSJobId)
|
||||
}
|
||||
>
|
||||
<Text>text here</Text>
|
||||
</Button>
|
||||
<Text>createTheTimeTicketOBJTest</Text>
|
||||
</Button> */}
|
||||
{/* {signingErrorMsg} */}
|
||||
<JobIdSearchSelect
|
||||
currentValue={currentSJobId}
|
||||
|
||||
@@ -2,30 +2,41 @@ import { Ionicons } from "@expo/vector-icons";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import React from "react";
|
||||
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 { createStructuredSelector } from "reselect";
|
||||
import { OwnerNameDisplayFunction } from "../owner-name-display/owner-name-display.component";
|
||||
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 mapDispatchToProps = (dispatch) => ({
|
||||
// setCameraJobId: (id) => dispatch(setCameraJobId(id)),
|
||||
// setCameraJob: (job) => dispatch(setCameraJob(job)),
|
||||
// });
|
||||
const mapStateToProps = createStructuredSelector({});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
// setTimeTicketJobId: (jobId) =>dispatch(setTimeTicketJobId({jobId})),
|
||||
setTmTicketJobId:(id) => dispatch(setTmTicketJobId(id)),
|
||||
});
|
||||
|
||||
export function ClockedinListItem({ ticket }) {
|
||||
export function ClockedinListItem({ setTmTicketJobId, ticket }) {
|
||||
const { t } = useTranslation();
|
||||
const navigation = useNavigation();
|
||||
|
||||
const onPress = () => {
|
||||
// logImEXEvent("imexmobile_view_job_detail");
|
||||
// navigation.push("JobDetail", {
|
||||
// jobId: item.id,
|
||||
// title: item.ro_number || t("general.labels.na"),
|
||||
// job: item,
|
||||
// });
|
||||
const onPress = (ticket, setCameraJobId) => {
|
||||
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 (
|
||||
@@ -36,18 +47,20 @@ export function ClockedinListItem({ ticket }) {
|
||||
} ${OwnerNameDisplayFunction(ticket.job)}`}
|
||||
/>
|
||||
<Card.Content>
|
||||
<Text>Vehicle :
|
||||
{`${ticket.job.v_model_yr || ""} ${
|
||||
ticket.job.v_make_desc || ""
|
||||
} ${ticket.job.v_model_desc || ""}`}
|
||||
<Text>
|
||||
Vehicle :
|
||||
{`${ticket.job.v_model_yr || ""} ${ticket.job.v_make_desc || ""} ${
|
||||
ticket.job.v_model_desc || ""
|
||||
}`}
|
||||
</Text>
|
||||
<Text>
|
||||
Clocked In : <DateTimeFormatter>{ticket.clockon}</DateTimeFormatter>
|
||||
</Text>
|
||||
<Text>
|
||||
Cost Center : {ticket.cost_center === "timetickets.labels.shift"
|
||||
? t(ticket.cost_center)
|
||||
: ticket.cost_center}
|
||||
Cost Center :{" "}
|
||||
{ticket.cost_center === "timetickets.labels.shift"
|
||||
? t(ticket.cost_center)
|
||||
: ticket.cost_center}
|
||||
</Text>
|
||||
</Card.Content>
|
||||
<Card.Actions>
|
||||
@@ -56,8 +69,25 @@ export function ClockedinListItem({ ticket }) {
|
||||
timeTicketId={ticket.id}
|
||||
completedCallback={refetch}
|
||||
/> */}
|
||||
<Button
|
||||
mode="outlined" onPress={() => onPress}>Clock Out</Button>
|
||||
<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>
|
||||
// <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(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(EmployeeClockedInList);
|
||||
export default connect(mapStateToProps,null)(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 ErrorDisplay from "../error-display/error-display.component";
|
||||
|
||||
//TODO add props needed for call
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentEmployee: selectCurrentEmployee,
|
||||
|
||||
@@ -27,3 +27,8 @@ export const documentUploadFailure = (error) => ({
|
||||
export const toggleDeleteAfterUpload = () => ({
|
||||
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,
|
||||
documentUploadError: null,
|
||||
deleteAfterUpload: false,
|
||||
tmTicketJobId: null,
|
||||
};
|
||||
|
||||
const appReducer = (state = INITIAL_STATE, action) => {
|
||||
@@ -43,6 +44,11 @@ const appReducer = (state = INITIAL_STATE, action) => {
|
||||
...state,
|
||||
deleteAfterUpload: !state.deleteAfterUpload,
|
||||
};
|
||||
case AppActionTypes.SET_TM_TICKET_JOB_ID:
|
||||
return {
|
||||
...state,
|
||||
tmTicketJobId: action.payload,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -26,3 +26,8 @@ export const selectDeleteAfterUpload = createSelector(
|
||||
[selectApp],
|
||||
(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_FAILURE: "DOCUMENT_UPLOAD_FAILURE",
|
||||
TOGGLE_DLETE_AFTER_UPLOAD: "TOGGLE_DLETE_AFTER_UPLOAD",
|
||||
SET_TM_TICKET_JOB_ID: "SET_TM_TICKET_JOB_ID"
|
||||
};
|
||||
export default AppActionTypes;
|
||||
|
||||
@@ -6,5 +6,5 @@ import { employeeSagas } from "./employee/employee.sagas";
|
||||
import { timeTicketsSagas } from "./timetickets/timetickets.sagas";
|
||||
|
||||
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";
|
||||
|
||||
export const setTimeTicket = (timeTicket) => ({
|
||||
type: TimeTicketsActionTypes.SET_TIME_TICKET,
|
||||
payload: timeTicket,
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import TimeTicketsActionTypes from "./timetickets.types";
|
||||
|
||||
const INITIAL_STATE = {
|
||||
timeTicket: null,
|
||||
timeTickets: [],
|
||||
timeTicketJobId: null,
|
||||
ttjobid:null,
|
||||
timeticketjobid: null,
|
||||
timeTicketJob: null,
|
||||
uploadTimeTicketInProgress: false,
|
||||
uploadTimeTicketError: null,
|
||||
@@ -14,22 +13,19 @@ const timeTicketsReducer = (state = INITIAL_STATE, action) => {
|
||||
case TimeTicketsActionTypes.SET_TIME_TICKET:
|
||||
return {
|
||||
...state,
|
||||
timeTicket: action.payload,
|
||||
timeTicket: action.payload
|
||||
};
|
||||
case TimeTicketsActionTypes.SET_TIME_TICKET_JOB_ID:
|
||||
return {
|
||||
...state,
|
||||
timeTicketJobId: action.payload,
|
||||
};
|
||||
return { ...state,timeticketjobid: action.payload };
|
||||
case TimeTicketsActionTypes.SET_TIME_TICKET_JOB:
|
||||
return {
|
||||
...state,
|
||||
timeTicketJob: action.payload,
|
||||
timeTicketJob: action.payload
|
||||
};
|
||||
case TimeTicketsActionTypes.TIME_TICKET_CREATE_START:
|
||||
return {
|
||||
...state,
|
||||
uploadTimeTicketInProgress: true,
|
||||
uploadTimeTicketInProgress: true
|
||||
};
|
||||
case TimeTicketsActionTypes.TIME_TICKET_CREATE_SUCCESS:
|
||||
return {
|
||||
|
||||
@@ -29,39 +29,39 @@ export function* insertNewTimeTicket({ payload: { timeTicketInput } }) {
|
||||
// pin: pin,
|
||||
// });
|
||||
// const { valid, data, error } = response.data;
|
||||
const result = yield client.mutate({
|
||||
mutation: INSERT_NEW_TIME_TICKET,
|
||||
variables: {
|
||||
timeTicketInput: [
|
||||
// {
|
||||
// bodyshopid: bodyshop.id,
|
||||
// employeeid: technician.id,
|
||||
// date: moment(theTime).format("YYYY-MM-DD"),
|
||||
// clockon: moment(theTime),
|
||||
// jobid: values.jobid,
|
||||
// cost_center: values.cost_center,
|
||||
// ciecacode:
|
||||
// bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
|
||||
// ? values.cost_center
|
||||
// : Object.keys(
|
||||
// bodyshop.md_responsibility_centers.defaults.costs
|
||||
// ).find((key) => {
|
||||
// return (
|
||||
// bodyshop.md_responsibility_centers.defaults.costs[key] ===
|
||||
// values.cost_center
|
||||
// );
|
||||
// }),
|
||||
// },
|
||||
],
|
||||
},
|
||||
});
|
||||
console.log(result);
|
||||
const { valid, data, error } = result.data;
|
||||
if (valid) {
|
||||
yield put(timeTicketCreateSuccess(data));
|
||||
} else {
|
||||
yield put(timeTicketCreateFailure(error));
|
||||
}
|
||||
// const result = yield client.mutate({
|
||||
// mutation: INSERT_NEW_TIME_TICKET,
|
||||
// variables: {
|
||||
// timeTicketInput: [
|
||||
// // {
|
||||
// // bodyshopid: bodyshop.id,
|
||||
// // employeeid: technician.id,
|
||||
// // date: moment(theTime).format("YYYY-MM-DD"),
|
||||
// // clockon: moment(theTime),
|
||||
// // jobid: values.jobid,
|
||||
// // cost_center: values.cost_center,
|
||||
// // ciecacode:
|
||||
// // bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber
|
||||
// // ? values.cost_center
|
||||
// // : Object.keys(
|
||||
// // bodyshop.md_responsibility_centers.defaults.costs
|
||||
// // ).find((key) => {
|
||||
// // return (
|
||||
// // bodyshop.md_responsibility_centers.defaults.costs[key] ===
|
||||
// // values.cost_center
|
||||
// // );
|
||||
// // }),
|
||||
// // },
|
||||
// ],
|
||||
// },
|
||||
// });
|
||||
// console.log(result);
|
||||
// const { valid, data, error } = result.data;
|
||||
// if (valid) {
|
||||
// yield put(timeTicketCreateSuccess(data));
|
||||
// } else {
|
||||
// yield put(timeTicketCreateFailure(error));
|
||||
// }
|
||||
} catch (error) {
|
||||
yield put(timeTicketCreateFailure(error));
|
||||
}
|
||||
|
||||
@@ -14,3 +14,4 @@ export const selectCurrentTimeTicket = createSelector(
|
||||
[selectTimeTicketsState],
|
||||
(timeTickets) => timeTickets.timeTicket
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user