diff --git a/src/components/ProductDetails/index.tsx b/src/components/ProductDetails/index.tsx index ac381436..4c73ba61 100644 --- a/src/components/ProductDetails/index.tsx +++ b/src/components/ProductDetails/index.tsx @@ -1,6 +1,7 @@ import React, { createContext, useContext } from 'react'; -import { View } from 'react-native'; +import { TouchableOpacity, View } from 'react-native'; import { Chip, Divider, Caption as PaperCaption, Title as PaperTitle, Text } from 'react-native-paper'; +import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; import { HYPHEN } from '../../constants'; import Product from '../../data/product/Product'; @@ -10,6 +11,9 @@ export type ProductDetailsItem = { icon?: string; label: string; value: string | number | null; + secondaryValue?: string | null; + onPress?: () => void; + accessibilityLabel?: string; }; type ProductContextType = { @@ -85,20 +89,45 @@ function List({ items }: { items: ProductDetailsItem[] }) { return ( {items.map((item) => ( - + ))} ); } -function Item({ icon, label, value }: ProductDetailsItem) { - return ( - - - {label}: {value ?? HYPHEN} - - +function Item({ icon, label, value, secondaryValue, onPress, accessibilityLabel }: ProductDetailsItem) { + const content = ( + + + + {label}: {value ?? HYPHEN} + {secondaryValue ? ( + {`, ${secondaryValue}`} + ) : null} + + + {onPress ? : null} + ); + + if (onPress) { + return ( + + {content} + + ); + } + + return content; } function Separator() { diff --git a/src/components/ProductDetails/styles.ts b/src/components/ProductDetails/styles.ts index f6741d80..34e071f1 100644 --- a/src/components/ProductDetails/styles.ts +++ b/src/components/ProductDetails/styles.ts @@ -19,13 +19,25 @@ export default StyleSheet.create({ borderRadius: 4, alignItems: 'center' }, + pressableChipText: { + paddingRight: 24 + }, chipText: { fontSize: 12, color: Theme.colors.text }, + itemChevron: { + position: 'absolute', + right: Theme.spacing.small, + top: 12, + color: Theme.colors.secondaryForeground + }, fontBold: { fontWeight: 'bold' }, + secondaryValue: { + color: Theme.colors.secondaryForeground + }, title: { fontSize: 18, color: Theme.colors.text, diff --git a/src/screens/Picking/CustomerDetails.tsx b/src/screens/Picking/CustomerDetails.tsx new file mode 100644 index 00000000..2d654dbc --- /dev/null +++ b/src/screens/Picking/CustomerDetails.tsx @@ -0,0 +1,87 @@ +import React from 'react'; +import { Modal, TouchableOpacity, View } from 'react-native'; +import { Divider, Text } from 'react-native-paper'; +import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; + +import { ProductDetails } from '../../components/ProductDetails'; +import { HYPHEN } from '../../constants'; +import { DestinationAddress } from '../../types/picking'; +import styles from './customerDetailsStyles'; + +type CustomerDetailsProps = { + name?: string; + address?: DestinationAddress | null; +}; + +function compact(parts: Array) { + return parts.filter(Boolean).join(', '); +} + +function AddressDetails({ address }: { address?: DestinationAddress | null }) { + const addressLine1 = address?.address || HYPHEN; + const locality = compact([address?.city, address?.stateOrProvince, address?.postalCode]); + const hasAddress = Boolean( + address?.address || address?.address2 || locality || address?.country || address?.description + ); + + return ( + <> + {addressLine1} + {address?.address2 ? {address.address2} : null} + {locality ? {locality} : null} + {address?.country ? {address.country} : null} + {address?.description ? {address.description} : null} + {!hasAddress ? ( + No delivery address is available in customer master data. + ) : null} + + ); +} + +export function CustomerDetails({ name, address }: CustomerDetailsProps) { + const [visible, setVisible] = React.useState(false); + + return ( + <> + setVisible(true)} + /> + + setVisible(false)}> + + + + + CUSTOMER + {name || HYPHEN} + + setVisible(false)} + > + + + + + + + + + + SHIP TO ADDRESS + + + + + + + + ); +} diff --git a/src/screens/Picking/PickingPickLocationScreen.tsx b/src/screens/Picking/PickingPickLocationScreen.tsx index b63169be..2e8e9a86 100644 --- a/src/screens/Picking/PickingPickLocationScreen.tsx +++ b/src/screens/Picking/PickingPickLocationScreen.tsx @@ -11,6 +11,7 @@ import { EMPTY_STRING, HYPHEN } from '../../constants'; import { navigate } from '../../NavigationService'; import { RootState } from '../../redux/reducers'; import { parseFromISODateToLocaleString } from '../../utils/utils'; +import { CustomerDetails } from './CustomerDetails'; import { usePickingContext } from './PickingContext'; import { ReallocateModal } from './ReallocateModal'; import styles from './styles'; @@ -89,12 +90,12 @@ export default function PickingPickLocationScreen() { icon: 'identifier', label: 'Order Number', value: currentTask.requisitionNumber || HYPHEN - }, - { - icon: 'map-marker', - label: currentTask.destinationLocationType || 'Destination', - value: currentTask.destination || HYPHEN - }, + } + ]} + /> + + + + + + + + + +