import React from 'react'; import { View, Text, StyleSheet, TouchableOpacity, useWindowDimensions } from 'react-native'; import { useRouter } from 'expo-router'; import { Ionicons } from '@expo/vector-icons'; import { colors, spacing, borderRadius } from '../constants/theme'; import { StockBadge } from './StockBadge'; import { Medicine } from '../types'; const TABLET_MIN_WIDTH = 768; interface MedicineCardProps { medicine: Medicine; } export function MedicineCard({ medicine }: MedicineCardProps) { const router = useRouter(); const { width } = useWindowDimensions(); const isTablet = width >= TABLET_MIN_WIDTH; const handlePress = () => { router.push(`/medicine/${medicine.nregistro}`); }; return ( {medicine.name} {medicine.stock != null && } {medicine.active_ingredient}{medicine.dosage ? ` - ${medicine.dosage}` : ''} {medicine.precio != null ? `${medicine.precio.toFixed(2)} €` : 'Sin precio'} {medicine.laboratory} ); } const styles = StyleSheet.create({ card: { backgroundColor: colors.card, borderRadius: borderRadius.lg, padding: spacing.md, marginHorizontal: spacing.lg, marginVertical: spacing.xs, shadowColor: '#000', shadowOffset: { width: 0, height: 2 }, shadowOpacity: 0.06, shadowRadius: 8, elevation: 2, }, cardTablet: { padding: spacing.lg, maxWidth: 700, alignSelf: 'center', width: '100%', }, header: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: spacing.xs, }, name: { flex: 1, fontSize: 16, fontWeight: '600', color: colors.text, marginRight: spacing.sm, }, nameTablet: { fontSize: 18, }, principioActivo: { fontSize: 14, color: colors.textSecondary, marginBottom: spacing.sm, }, footer: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }, priceContainer: { flexDirection: 'row', alignItems: 'center', }, price: { fontSize: 14, fontWeight: '600', color: colors.primary, marginLeft: spacing.xs, }, priceTablet: { fontSize: 16, }, labContainer: { flexDirection: 'row', alignItems: 'center', flex: 1, justifyContent: 'flex-end', }, laboratorio: { fontSize: 12, color: colors.textSecondary, marginLeft: spacing.xs, maxWidth: 120, }, laboratorioTablet: { fontSize: 14, maxWidth: 200, }, });