import React, { ReactNode } from 'react';
import { StyleSheet } from 'react-native';
import { TouchableComponent } from '../TouchableComponent';
import { Box } from '../Box';
import { Normalize } from '../../utils/normalize';
import { LeftComponent, RightComponent } from './components';
type ProductProps = {
image?: string;
referenceName: string;
brand: string;
sku: number | string;
packaging: string;
quantity?: number;
currentQuantity?: number;
placeholder?: string;
date?: string;
};
type StyleAndLogicProps = {
onPress?: () => void;
onLongPress?: () => void;
onPressImage?: () => void;
onLongPressOnImage?: () => void;
icon?: 'approved' | 'rejected' | 'warn' | ReactNode;
height?: number | string;
titleLines?: number;
borderRadius?: number;
disabled?: boolean;
bottomContent?: ReactNode;
};
type CardProps = ProductProps & StyleAndLogicProps;
export const ProductCardV2 = ({
onPress,
onLongPress,
onPressImage,
onLongPressOnImage,
image,
referenceName,
brand,
sku,
packaging,
quantity,
currentQuantity,
icon,
height = Normalize(204),
borderRadius = Normalize(4),
titleLines = 2,
disabled = false,
bottomContent,
placeholder,
date,
}: CardProps) => {
const onPressOnImageAction = disabled ? undefined : onPressImage;
const onLongPressOnImageAction = disabled ? undefined : onLongPressOnImage;
const halfOpacityIfDisabled = disabled
? stylesProductCard.halfOpacity
: stylesProductCard.fullOpaque;
if ((onPress || onLongPress) && !disabled) {
return (
);
}
return (
);
};
const stylesProductCard = StyleSheet.create({
fullOpaque: { opacity: 1 },
halfOpacity: { opacity: 0.5 },
});