Files
imexmobile/components/job-list-item/job-list-item.component.jsx
2021-02-08 22:32:47 -08:00

76 lines
2.4 KiB
JavaScript

import { Ionicons } from "@expo/vector-icons";
import { useNavigation } from "@react-navigation/native";
import { Body, H3, Icon, ListItem, Right } from "native-base";
import React from "react";
import { useTranslation } from "react-i18next";
import { Text } from "react-native";
import { TouchableOpacity } from "react-native-gesture-handler";
import Swipeable from "react-native-gesture-handler/Swipeable";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { setCameraJob, setCameraJobId } from "../../redux/app/app.actions";
import styles from "../styles";
const mapStateToProps = createStructuredSelector({
//currentUser: selectCurrentUser
});
const mapDispatchToProps = (dispatch) => ({
setCameraJobId: (id) => dispatch(setCameraJobId(id)),
setCameraJob: (job) => dispatch(setCameraJob(job)),
});
export function JobListItem({ setCameraJob, setCameraJobId, item }) {
const { t } = useTranslation();
const navigation = useNavigation();
const RenderRightAction = () => {
const navigation = useNavigation();
const { t } = useTranslation();
return (
<TouchableOpacity
style={[styles.swipe_view, styles.swipe_view_blue]}
onPress={() => {
setCameraJobId(item.id);
setCameraJob(item);
navigation.navigate("CameraTab");
}}
>
<Ionicons name="ios-camera" size={24} color="white" />
{/* <Text style={styles.swipe_text}>
{t("joblist.actions.swipecamera")}
</Text> */}
</TouchableOpacity>
);
};
const onPress = () => {
navigation.push("JobDetail", {
jobId: item.id,
title: item.ro_number || t("general.labels.na"),
});
};
return (
<Swipeable renderRightActions={() => <RenderRightAction />}>
<TouchableOpacity onPress={onPress}>
<ListItem>
<H3>{item.ro_number || t("general.labels.na")}</H3>
<Body style={{ marginLeft: 10 }}>
<Text>{`${item.ownr_fn || ""} ${item.ownr_ln || ""} ${
item.ownr_co_nm || ""
} - ${item.v_model_yr || ""} ${item.v_make_desc || ""} ${
item.v_model_desc || ""
}`}</Text>
</Body>
<Right>
<Icon active name="arrow-forward" />
</Right>
</ListItem>
</TouchableOpacity>
</Swipeable>
);
}
export default connect(mapStateToProps, mapDispatchToProps)(JobListItem);