318 lines
10 KiB
TypeScript
318 lines
10 KiB
TypeScript
import React, { useState } from 'react';
|
|
import {
|
|
Card,
|
|
CardMedia,
|
|
CardContent,
|
|
CardActions,
|
|
Typography,
|
|
Box,
|
|
Button,
|
|
Chip,
|
|
Dialog,
|
|
DialogTitle,
|
|
DialogContent,
|
|
IconButton,
|
|
} from '@mui/material';
|
|
import { CheckCircle2, FileText, Info, X, SlidersHorizontal, Package } from 'lucide-react';
|
|
import { Product } from '../../../types';
|
|
import { useQuote } from '../../../context/QuoteContext';
|
|
import { SpecTable } from '../SpecTable/SpecTable';
|
|
|
|
interface ProductCardProps {
|
|
product: Product;
|
|
}
|
|
|
|
export const ProductCard: React.FC<ProductCardProps> = ({ product }) => {
|
|
const [detailOpen, setDetailOpen] = useState(false);
|
|
const { openQuoteModal } = useQuote();
|
|
|
|
const handleQuoteClick = () => {
|
|
openQuoteModal(product.name);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Card
|
|
sx={{
|
|
height: '100%',
|
|
display: 'flex',
|
|
flexDirection: 'column',
|
|
position: 'relative',
|
|
overflow: 'hidden',
|
|
transition: 'all 0.35s cubic-bezier(0.165, 0.84, 0.44, 1)',
|
|
bgcolor: '#FFFFFF',
|
|
border: '1px solid rgba(27, 77, 62, 0.1)',
|
|
'&:hover': {
|
|
transform: 'translateY(-6px)',
|
|
boxShadow: '0 16px 36px rgba(27, 77, 62, 0.14)',
|
|
borderColor: product.accentColor,
|
|
'& .product-card-img': {
|
|
transform: 'scale(1.05)',
|
|
},
|
|
},
|
|
}}
|
|
>
|
|
{/* Top Badge */}
|
|
<Box
|
|
sx={{
|
|
position: 'absolute',
|
|
top: 14,
|
|
left: 14,
|
|
zIndex: 2,
|
|
}}
|
|
>
|
|
<Chip
|
|
label={product.badge}
|
|
size="small"
|
|
sx={{
|
|
bgcolor: 'rgba(16, 42, 34, 0.88)',
|
|
color: '#D49B24',
|
|
backdropFilter: 'blur(8px)',
|
|
fontWeight: 700,
|
|
fontSize: '0.74rem',
|
|
border: '1px solid rgba(212, 155, 36, 0.4)',
|
|
boxShadow: '0 4px 10px rgba(0,0,0,0.15)',
|
|
}}
|
|
/>
|
|
</Box>
|
|
|
|
{/* Product Image */}
|
|
<Box sx={{ position: 'relative', overflow: 'hidden', height: 240, bgcolor: '#F0EDE5' }}>
|
|
<CardMedia
|
|
component="img"
|
|
image={product.image}
|
|
alt={product.name}
|
|
className="product-card-img"
|
|
sx={{
|
|
height: '100%',
|
|
width: '100%',
|
|
objectFit: 'cover',
|
|
transition: 'transform 0.5s ease',
|
|
}}
|
|
/>
|
|
<Box
|
|
sx={{
|
|
position: 'absolute',
|
|
bottom: 0,
|
|
left: 0,
|
|
right: 0,
|
|
height: 40,
|
|
background: 'linear-gradient(to top, rgba(0,0,0,0.4) 0%, transparent 100%)',
|
|
}}
|
|
/>
|
|
</Box>
|
|
|
|
{/* Content */}
|
|
<CardContent sx={{ p: 3, flexGrow: 1, display: 'flex', flexDirection: 'column' }}>
|
|
<Box sx={{ mb: 1 }}>
|
|
<Typography variant="caption" sx={{ color: product.accentColor, fontWeight: 700, letterSpacing: '0.04em' }}>
|
|
{product.hindiName}
|
|
</Typography>
|
|
<Typography
|
|
variant="h5"
|
|
component="h3"
|
|
sx={{
|
|
fontWeight: 800,
|
|
color: '#13201A',
|
|
fontSize: { xs: '1.25rem', md: '1.38rem' },
|
|
mt: 0.2,
|
|
mb: 1,
|
|
}}
|
|
>
|
|
{product.name}
|
|
</Typography>
|
|
</Box>
|
|
|
|
<Typography
|
|
variant="body2"
|
|
sx={{
|
|
color: '#4A5B53',
|
|
lineHeight: 1.6,
|
|
mb: 2.5,
|
|
display: '-webkit-box',
|
|
WebkitLineClamp: 3,
|
|
WebkitBoxOrient: 'vertical',
|
|
overflow: 'hidden',
|
|
}}
|
|
>
|
|
{product.shortDesc}
|
|
</Typography>
|
|
|
|
{/* Quick Specifications list */}
|
|
<Box
|
|
sx={{
|
|
p: 1.8,
|
|
borderRadius: 2,
|
|
bgcolor: 'rgba(27, 77, 62, 0.035)',
|
|
border: '1px solid rgba(27, 77, 62, 0.08)',
|
|
mb: 2.5,
|
|
mt: 'auto',
|
|
}}
|
|
>
|
|
<Typography variant="caption" sx={{ fontWeight: 700, color: '#1B4D3E', display: 'block', mb: 1 }}>
|
|
Key Export Parameters:
|
|
</Typography>
|
|
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 0.6 }}>
|
|
<Box sx={{ display: 'flex', gap: 1, alignItems: 'center' }}>
|
|
<CheckCircle2 size={14} color="#2D7560" />
|
|
<Typography variant="caption" sx={{ color: '#33443C' }}>
|
|
<strong>Origin:</strong> {product.specifications.origin.split('/')[0]}
|
|
</Typography>
|
|
</Box>
|
|
<Box sx={{ display: 'flex', gap: 1, alignItems: 'center' }}>
|
|
<CheckCircle2 size={14} color="#2D7560" />
|
|
<Typography variant="caption" sx={{ color: '#33443C' }}>
|
|
<strong>Mesh:</strong> {product.specifications.meshFineness}
|
|
</Typography>
|
|
</Box>
|
|
<Box sx={{ display: 'flex', gap: 1, alignItems: 'center' }}>
|
|
<CheckCircle2 size={14} color="#2D7560" />
|
|
<Typography variant="caption" sx={{ color: '#33443C' }}>
|
|
<strong>MOQ:</strong> {product.moq}
|
|
</Typography>
|
|
</Box>
|
|
</Box>
|
|
</Box>
|
|
|
|
{/* Buyer customizable tags */}
|
|
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.6, mb: 1 }}>
|
|
{product.customizableParameters.slice(0, 3).map((param) => (
|
|
<Chip
|
|
key={param}
|
|
label={param}
|
|
size="small"
|
|
variant="outlined"
|
|
sx={{
|
|
fontSize: '0.68rem',
|
|
borderColor: 'rgba(27, 77, 62, 0.15)',
|
|
color: '#4A5B53',
|
|
}}
|
|
/>
|
|
))}
|
|
</Box>
|
|
</CardContent>
|
|
|
|
{/* Card Actions */}
|
|
<CardActions sx={{ p: 3, pt: 0, gap: 1.2 }}>
|
|
<Button
|
|
variant="outlined"
|
|
size="medium"
|
|
fullWidth
|
|
startIcon={<Info size={16} />}
|
|
onClick={() => setDetailOpen(true)}
|
|
sx={{
|
|
borderColor: 'rgba(27, 77, 62, 0.25)',
|
|
color: '#1B4D3E',
|
|
fontWeight: 600,
|
|
'&:hover': {
|
|
borderColor: '#1B4D3E',
|
|
bgcolor: 'rgba(27, 77, 62, 0.05)',
|
|
},
|
|
}}
|
|
>
|
|
Full Specs
|
|
</Button>
|
|
|
|
<Button
|
|
variant="contained"
|
|
color="secondary"
|
|
size="medium"
|
|
fullWidth
|
|
startIcon={<FileText size={16} />}
|
|
onClick={handleQuoteClick}
|
|
sx={{
|
|
fontWeight: 700,
|
|
}}
|
|
>
|
|
Inquire Price
|
|
</Button>
|
|
</CardActions>
|
|
</Card>
|
|
|
|
{/* Detail Dialog */}
|
|
<Dialog
|
|
open={detailOpen}
|
|
onClose={() => setDetailOpen(false)}
|
|
maxWidth="md"
|
|
fullWidth
|
|
slotProps={{
|
|
paper: {
|
|
sx: {
|
|
borderRadius: 3,
|
|
p: { xs: 1, sm: 2 },
|
|
},
|
|
},
|
|
}}
|
|
>
|
|
<DialogTitle
|
|
sx={{
|
|
display: 'flex',
|
|
justifyContent: 'space-between',
|
|
alignItems: 'center',
|
|
pb: 1,
|
|
}}
|
|
>
|
|
<Box>
|
|
<Typography variant="caption" sx={{ color: product.accentColor, fontWeight: 700, textTransform: 'uppercase' }}>
|
|
Export Specifications & Quality Standards
|
|
</Typography>
|
|
<Typography variant="h4" sx={{ fontWeight: 800, color: '#13201A' }}>
|
|
{product.name}
|
|
</Typography>
|
|
</Box>
|
|
<IconButton onClick={() => setDetailOpen(false)}>
|
|
<X size={22} />
|
|
</IconButton>
|
|
</DialogTitle>
|
|
|
|
<DialogContent dividers sx={{ pt: 2.5 }}>
|
|
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 3 }}>
|
|
{/* Description */}
|
|
<Typography variant="body1" sx={{ color: '#34453E', lineHeight: 1.7 }}>
|
|
{product.fullDesc}
|
|
</Typography>
|
|
|
|
{/* Specifications Table */}
|
|
<Box>
|
|
<Typography variant="h6" sx={{ fontWeight: 700, color: '#1B4D3E', mb: 1.5, display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
<SlidersHorizontal size={20} color="#D49B24" />
|
|
Technical & Regulatory Specifications
|
|
</Typography>
|
|
<SpecTable specifications={product.specifications} accentColor={product.accentColor} />
|
|
</Box>
|
|
|
|
{/* Buyer Customization Note */}
|
|
<Box sx={{ p: 2.5, borderRadius: 2.5, bgcolor: 'rgba(212, 155, 36, 0.08)', border: '1px dashed #D49B24' }}>
|
|
<Typography variant="subtitle2" sx={{ fontWeight: 700, color: '#7E5B10', mb: 0.5, display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
<Package size={18} />
|
|
Custom Order Flexibility for Importers:
|
|
</Typography>
|
|
<Typography variant="body2" sx={{ color: '#55421A' }}>
|
|
We process, mill, and pack this product according to your exact target market specifications (custom mesh size, color ASTA values, heat Scoville levels, moisture control, and private label bags).
|
|
</Typography>
|
|
</Box>
|
|
|
|
{/* Action inside dialog */}
|
|
<Box sx={{ display: 'flex', flexDirection: { xs: 'column', sm: 'row' }, gap: 2, justifyContent: 'flex-end' }}>
|
|
<Button variant="outlined" onClick={() => setDetailOpen(false)}>
|
|
Close Window
|
|
</Button>
|
|
<Button
|
|
variant="contained"
|
|
color="secondary"
|
|
startIcon={<FileText size={18} />}
|
|
onClick={() => {
|
|
setDetailOpen(false);
|
|
openQuoteModal(product.name);
|
|
}}
|
|
>
|
|
Request Quotation for {product.name}
|
|
</Button>
|
|
</Box>
|
|
</Box>
|
|
</DialogContent>
|
|
</Dialog>
|
|
</>
|
|
);
|
|
};
|