| 1 | import React from 'react';
|
|---|
| 2 | import { Card, CardMedia, CardContent, Typography, Box, Chip } from '@mui/material';
|
|---|
| 3 | import StarIcon from '@mui/icons-material/Star';
|
|---|
| 4 | // import PersonIcon from '@mui/icons-material/Person';
|
|---|
| 5 |
|
|---|
| 6 | export default function BuildCard({ build, onClick }: { build: any, onClick: () => void }) {
|
|---|
| 7 | const formattedPrice = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'EUR' }).format(build.total_price || 0);
|
|---|
| 8 |
|
|---|
| 9 | return (
|
|---|
| 10 | <Card
|
|---|
| 11 | sx={{ height: '100%', display: 'flex', flexDirection: 'column', cursor: 'pointer', transition: 'all 0.2s', '&:hover': { transform: 'translateY(-4px)', boxShadow: 6 } }}
|
|---|
| 12 | onClick={onClick}
|
|---|
| 13 | >
|
|---|
| 14 | <CardMedia
|
|---|
| 15 | component="img"
|
|---|
| 16 | height="160"
|
|---|
| 17 | image={build.img_url || "https://placehold.co/600x400?text=PC+Build"}
|
|---|
| 18 | alt={build.name}
|
|---|
| 19 | />
|
|---|
| 20 | <CardContent sx={{ flexGrow: 1, pb: 1 }}>
|
|---|
| 21 | <Typography gutterBottom variant="h6" noWrap title={build.name}>
|
|---|
| 22 | {build.name}
|
|---|
| 23 | </Typography>
|
|---|
| 24 |
|
|---|
| 25 | {/*Ne se renderira user-ot*/}
|
|---|
| 26 | <Box sx={{ display: 'flex', alignItems: 'center', mb: 1, color: 'text.secondary' }}>
|
|---|
| 27 | {/* <PersonIcon sx={{ fontSize: 16, mr: 0.5 }} />*/}
|
|---|
| 28 | {/* <Typography variant="caption">{build.user || 'Unknown'}</Typography>*/}
|
|---|
| 29 | </Box>
|
|---|
| 30 |
|
|---|
| 31 | <Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mt: 'auto' }}>
|
|---|
| 32 | <Chip label={formattedPrice} size="small" color="primary" variant="outlined" />
|
|---|
| 33 | <Box sx={{ display: 'flex', alignItems: 'center' }}>
|
|---|
| 34 | <StarIcon fontSize="small" sx={{ color: '#faaf00', mr: 0.5 }} />
|
|---|
| 35 | <Typography variant="body2" fontWeight="bold">
|
|---|
| 36 | {Number(build.avgRating || 5).toFixed(1)}
|
|---|
| 37 | </Typography>
|
|---|
| 38 | </Box>
|
|---|
| 39 | </Box>
|
|---|
| 40 | </CardContent>
|
|---|
| 41 | </Card>
|
|---|
| 42 | );
|
|---|
| 43 | } |
|---|