Changeset 958bc89 for components
- Timestamp:
- 12/29/25 04:34:44 (6 months ago)
- Branches:
- main
- Children:
- 41a2f81
- Parents:
- f46bf5c
- Location:
- components
- Files:
-
- 1 added
- 2 edited
-
AddComponentDialog.tsx (added)
-
BuildCard.tsx (modified) (6 diffs)
-
BuildDetailsDialog.tsx (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
components/BuildCard.tsx
rf46bf5c r958bc89 1 1 import React, {useEffect, useState} from 'react'; 2 import {Card, CardContent, CardMedia, Typography, Box, Chip } from '@mui/material';2 import {Card, CardContent, CardMedia, Typography, Box, Chip, CircularProgress} from '@mui/material'; 3 3 import StarIcon from '@mui/icons-material/Star'; 4 4 import {onGetBuildDetails} from "../pages/+Layout.telefunc"; … … 7 7 const [caseImage, setCaseImage] = useState<string>("https://placehold.co/600x400?text=PC+Build"); 8 8 const [imageLoading, setImageLoading] = useState(true); 9 const [details, setDetails] = useState<any>(null); 9 10 10 11 const formattedPrice = new Intl.NumberFormat('en-US', { … … 14 15 15 16 useEffect(() => { 17 setImageLoading(true); 16 18 onGetBuildDetails({buildId: build.id}) 17 .then(details => { 18 const caseComponent = details.components.find((c: any) => c.type === 'case'); 19 setCaseImage(caseComponent?.imgUrl || caseComponent?.imgUrl || "https://placehold.co/600x400?text=PC+Build"); 19 .then(fullDetails => { 20 setDetails(fullDetails); 21 22 const caseComponent = fullDetails.components?.find((c: any) => c.type === 'case'); 23 setCaseImage( 24 caseComponent?.imgUrl || 25 "https://placehold.co/600x400?text=PC+Build" 26 ); 20 27 }) 21 .catch(() => { 28 .catch((error) => { 29 console.error("Failed to load build details:", error); 30 setDetails(null); 22 31 }) 23 .finally(() => setImageLoading(false)); 32 .finally(() => { 33 setImageLoading(false); 34 }); 24 35 }, [build.id]); 36 37 if (imageLoading) { 38 return ( 39 <Card sx={{width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center'}}> 40 <CircularProgress /> 41 </Card> 42 ); 43 } 25 44 26 45 return ( … … 44 63 <CardMedia 45 64 component="img" 46 image={caseImage || '/placeholder-pc.png'}65 image={caseImage} 47 66 alt={build.name} 48 67 sx={{ … … 60 79 61 80 <CardContent sx={{flexGrow: 1, display: 'flex', flexDirection: 'column', justifyContent: 'space-between'}}> 81 <Box sx={{mb: 1}}> 82 <Typography variant="h6" component="div" fontWeight="bold"> 83 {build.name} 84 </Typography> 85 </Box> 86 62 87 <Box sx={{mb: 2}}> 63 <Typography variant="h6" component="div" fontWeight="bold" wrap title={build.name}> 64 {build.name} 88 <Typography 89 variant="body2" 90 color="text.secondary" 91 sx={{fontStyle: 'italic', fontSize: '0.875rem'}} 92 > 93 {details?.description || "No description provided."} 65 94 </Typography> 66 95 </Box> … … 75 104 /> 76 105 <Box sx={{display: 'flex', alignItems: 'center'}}> 77 <StarIcon sx={{color: '#faaf00', fontSize: 20, m r: 0.5}}/>106 <StarIcon sx={{color: '#faaf00', fontSize: 20, ml: 1}}/> 78 107 <Typography variant="body2" fontWeight="bold"> 79 {Number(build.avgRating || 5).toFixed(1)}108 {Number(build.avgRating || 0).toFixed(1)} 80 109 </Typography> 81 110 </Box> -
components/BuildDetailsDialog.tsx
rf46bf5c r958bc89 1 import React, { useEffect, useState} from 'react';1 import React, {useEffect, useState} from 'react'; 2 2 import { 3 3 Dialog, DialogTitle, DialogContent, DialogActions, Button, Grid, Box, Typography, … … 51 51 }, [open, buildId]); 52 52 53 // Ownership check for edit button54 53 useEffect(() => { 55 54 if (open && buildId !== null && typeof buildId === 'number') { 56 onGetBuildState({ buildId }) // ← Only buildId, no userId!55 onGetBuildState({buildId}) 57 56 .then(state => { 58 57 setIsOwner(!!state); … … 91 90 92 91 try { 93 const newBuildId = await onCloneBuild({ buildId: cloningBuildId});92 const newBuildId = await onCloneBuild({buildId: cloningBuildId}); 94 93 window.location.href = `/forge?buildId=${newBuildId}`; 95 94 setCloneDialogOpen(false);
Note:
See TracChangeset
for help on using the changeset viewer.
