source: components/BuildCard.tsx@ d4842f4

main
Last change on this file since d4842f4 was 1bf6e1f, checked in by Mihail <mihail2.naumov@…>, 7 months ago

Implemented part of the frontend (index, user, completedBuilds).

  • Property mode set to 100644
File size: 2.3 KB
Line 
1import React from 'react';
2import { Card, CardMedia, CardContent, Typography, Box, Chip } from '@mui/material';
3import StarIcon from '@mui/icons-material/Star';
4import PersonIcon from '@mui/icons-material/Person';
5
6export default function BuildCard({ build, onClick }: { build: any, onClick: () => void }) {
7 const formattedPrice = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).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 <Typography variant="h6" gutterBottom noWrap title={build.cpu}>{build.cpu}</Typography>
30 <Typography variant="h6" gutterBottom noWrap title={build.gpu}>{build.gpu}</Typography>
31 </Box>
32
33 <Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mt: 'auto' }}>
34 <Chip label={formattedPrice} size="small" color="primary" variant="outlined" />
35 <Box sx={{ display: 'flex', alignItems: 'center' }}>
36 <StarIcon fontSize="small" sx={{ color: '#faaf00', mr: 0.5 }} />
37 <Typography variant="body2" fontWeight="bold">
38 {Number(build.avg_rating || 5).toFixed(1)}
39 </Typography>
40 </Box>
41 </Box>
42 </CardContent>
43 </Card>
44 );
45}
Note: See TracBrowser for help on using the repository browser.