Index: components/BuildDetailsDialog.tsx
===================================================================
--- components/BuildDetailsDialog.tsx	(revision 8a7f936ef2c6040183ae33f4b63947eecf8bf3b2)
+++ components/BuildDetailsDialog.tsx	(revision b6e1b3c446e18031dea6a3444f7ec467670f9f2d)
@@ -10,8 +10,18 @@
 import PersonIcon from "@mui/icons-material/Person";
 import {onGetBuildDetails, onSetReview, onToggleFavorite, onCloneBuild, onSetRating} from '../pages/+Layout.telefunc';
-
-const formatPrice = (price: any) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(Number(price) || 0);
-
-export default function BuildDetailsDialog({ open, buildId, onClose, currentUser }: any) {
+import {onGetBuildState} from '../pages/forge/forge.telefunc';
+
+const formatPrice = (price: any) => new Intl.NumberFormat('en-US', {
+    style: 'currency',
+    currency: 'USD'
+}).format(Number(price) || 0);
+
+export default function BuildDetailsDialog({open, buildId, onClose, currentUser, isDashboardView = false}: {
+    open: boolean;
+    buildId: number | null;
+    onClose: () => void;
+    currentUser: any;
+    isDashboardView?: boolean;
+}) {
     const [details, setDetails] = useState<any>(null);
     const [loading, setLoading] = useState(false);
@@ -19,15 +29,17 @@
     const [cloneDialogOpen, setCloneDialogOpen] = useState(false);
     const [cloningBuildId, setCloningBuildId] = useState<number | null>(null);
+    const [isOwner, setIsOwner] = useState(false);
 
     const [reviewText, setReviewText] = useState("");
     const [ratingVal, setRatingVal] = useState(5);
 
+    // Main details fetch
     useEffect(() => {
-        if (open && buildId) {
+        if (open && buildId !== null && typeof buildId === 'number') {
             setLoading(true);
             setReviewText("");
             setRatingVal(5);
 
-            onGetBuildDetails({ buildId })
+            onGetBuildDetails({buildId})
                 .then(data => {
                     setDetails(data);
@@ -39,17 +51,29 @@
     }, [open, buildId]);
 
+    // Ownership check for edit button
+    useEffect(() => {
+        if (open && buildId !== null && typeof buildId === 'number') {
+            onGetBuildState({ buildId })  // ← Only buildId, no userId!
+                .then(state => {
+                    setIsOwner(!!state);
+                })
+                .catch(() => setIsOwner(false));
+        } else {
+            setIsOwner(false);
+        }
+    }, [open, buildId]);
+
     const handleFavorite = async () => {
-        if (!currentUser) return alert("Please login to favorite builds.");
-        const res = await onToggleFavorite({ buildId });
-        setDetails((prev: any) => ({ ...prev, isFavorite: res }));
+        if (!currentUser || buildId === null) return alert("Please login to favorite builds.");
+        const res = await onToggleFavorite({buildId});
+        setDetails((prev: any) => ({...prev, isFavorite: res}));
     };
 
     const handleSubmitReview = async () => {
-        if (!currentUser) return alert("Please login to review.");
+        if (!currentUser || buildId === null) return alert("Please login to review.");
 
         await onSetReview({
             buildId,
             content: reviewText,
-            // rating: ratingVal
         });
 
@@ -57,7 +81,7 @@
             buildId,
             value: ratingVal
-        })
-
-        const refreshed = await onGetBuildDetails({ buildId });
+        });
+
+        const refreshed = await onGetBuildDetails({buildId});
         setDetails(refreshed);
     };
@@ -68,7 +92,5 @@
         try {
             const newBuildId = await onCloneBuild({ buildId: cloningBuildId });
-
             window.location.href = `/forge?buildId=${newBuildId}`;
-
             setCloneDialogOpen(false);
             setCloningBuildId(null);
@@ -78,5 +100,4 @@
     };
 
-
     if (!open) return null;
 
@@ -85,30 +106,44 @@
             <Dialog open={open} onClose={onClose} maxWidth="md" fullWidth scroll="paper">
                 {loading || !details ? (
-                    <Box sx={{ p: 5, textAlign: 'center' }}>Loading Forge Schematics...</Box>
+                    <Box sx={{p: 5, textAlign: 'center'}}>Loading Forge Schematics...</Box>
                 ) : (
                     <>
-                        <DialogTitle sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', bgcolor: '#ff8201' }}>
+                        <DialogTitle sx={{
+                            display: 'flex',
+                            justifyContent: 'space-between',
+                            alignItems: 'center',
+                            bgcolor: '#ff8201'
+                        }}>
                             <Box>
                                 <Typography variant="h5" fontWeight="bold">{details.name}</Typography>
-                                <Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
-                                    <PersonIcon sx={{ fontSize: 16 }} />
+                                <Box sx={{display: 'flex', alignItems: 'center', gap: 1}}>
+                                    <PersonIcon sx={{fontSize: 16}}/>
                                     <Typography variant="subtitle2" color="text.secondary" fontWeight="bold">
                                         by {details.creator}
                                     </Typography>
-                                    <Chip label={formatPrice(details.totalPrice)} size="small" color="primary" variant="outlined" />
+                                    <Chip label={formatPrice(details.totalPrice)} size="small" color="primary"
+                                          variant="outlined"/>
                                 </Box>
                             </Box>
-                            <IconButton onClick={onClose}><CloseIcon /></IconButton>
+                            <IconButton onClick={onClose}><CloseIcon/></IconButton>
                         </DialogTitle>
 
-                        <DialogContent sx={{ p: 0 }}>
-                            <Box sx={{ borderBottom: 1, borderColor: 'divider', px: 2, bgcolor: 'primary', position: 'sticky', top: 0, zIndex: 1 }}>
+                        <DialogContent sx={{p: 0}}>
+                            <Box sx={{
+                                borderBottom: 1,
+                                borderColor: 'divider',
+                                px: 2,
+                                bgcolor: 'primary',
+                                position: 'sticky',
+                                top: 0,
+                                zIndex: 1
+                            }}>
                                 <Tabs value={tabIndex} onChange={(_, v) => setTabIndex(v)}>
-                                    <Tab label="Specs" />
-                                    <Tab label={`Reviews (${details.ratingStatistics.ratingCount})`} />
+                                    <Tab label="Specs"/>
+                                    <Tab label={`Reviews (${details.ratingStatistics.ratingCount})`}/>
                                 </Tabs>
                             </Box>
 
-                            <Box sx={{ p: 3 }}>
+                            <Box sx={{p: 3}}>
                                 {tabIndex === 0 && (
                                     <Grid container spacing={2}>
@@ -118,9 +153,9 @@
                                                     {details.components.map((comp: any) => (
                                                         <TableRow key={comp.id}>
-                                                            <TableCell sx={{ width: 50 }}>
+                                                            <TableCell sx={{width: 50}}>
                                                                 <Avatar
                                                                     src={comp.img_url || undefined}
                                                                     variant="rounded"
-                                                                    sx={{ width: 45, height: 45, bgcolor: '#ff8201'}}
+                                                                    sx={{width: 45, height: 45, bgcolor: '#ff8201'}}
                                                                 >
                                                                     {comp.type?.substring(0, 3)?.toUpperCase()}
@@ -128,5 +163,8 @@
                                                             </TableCell>
                                                             <TableCell>
-                                                                <Typography variant="body2" color="text.secondary" sx={{ fontSize: '0.75rem', textTransform: 'uppercase' }}>
+                                                                <Typography variant="body2" color="text.secondary" sx={{
+                                                                    fontSize: '0.75rem',
+                                                                    textTransform: 'uppercase'
+                                                                }}>
                                                                     {comp.type}
                                                                 </Typography>
@@ -135,12 +173,20 @@
                                                                 </Typography>
                                                             </TableCell>
-                                                            <TableCell align="right" sx={{ fontWeight: 'bold', color: '#ff8201' }}>
+                                                            <TableCell align="right"
+                                                                       sx={{fontWeight: 'bold', color: '#ff8201'}}>
                                                                 {formatPrice(comp.price)}
                                                             </TableCell>
                                                         </TableRow>
                                                     ))}
-                                                    <TableRow sx={{ bgcolor: '#424343' }}>
-                                                        <TableCell colSpan={2} sx={{ fontWeight: 'bold', color: '#ff8201' }}>TOTAL</TableCell>
-                                                        <TableCell align="right" sx={{ fontWeight: 'bold', fontSize: '1.1rem', color: 'primary.main' }}>
+                                                    <TableRow sx={{bgcolor: '#424343'}}>
+                                                        <TableCell colSpan={2} sx={{
+                                                            fontWeight: 'bold',
+                                                            color: '#ff8201'
+                                                        }}>TOTAL</TableCell>
+                                                        <TableCell align="right" sx={{
+                                                            fontWeight: 'bold',
+                                                            fontSize: '1.1rem',
+                                                            color: 'primary.main'
+                                                        }}>
                                                             {formatPrice(details.totalPrice)}
                                                         </TableCell>
@@ -151,28 +197,46 @@
 
                                         <Grid item xs={12} md={4}>
-                                            <Box sx={{ bgcolor: '#424343', p: 2, borderRadius: 2, mb: 2 }}>
-                                                <Typography color="primary.main" gutterBottom fontWeight="bold">Builder's Notes</Typography>
-                                                <Typography color="primary.main" variant="body2" sx={{ fontStyle: 'italic' }}>
+                                            <Box sx={{bgcolor: '#424343', p: 2, borderRadius: 2, mb: 2}}>
+                                                <Typography color="primary.main" gutterBottom fontWeight="bold">Builder's
+                                                    Notes</Typography>
+                                                <Typography color="primary.main" variant="body2"
+                                                            sx={{fontStyle: 'italic'}}>
                                                     "{details.description || "No notes provided."}"
                                                 </Typography>
                                             </Box>
 
-                                            <Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
-                                                <Button
-                                                    variant="contained"
-                                                    color="primary"
-                                                    size="large"
-                                                    startIcon={<AutoFixHighIcon />}
-                                                    onClick={() => {
-                                                        setCloningBuildId(details.id);
-                                                        setCloneDialogOpen(true);
-                                                    }}
-                                                >
-                                                    Clone & Edit
-                                                </Button>
+                                            <Box sx={{display: 'flex', flexDirection: 'column', gap: 1}}>
+                                                {isDashboardView && isOwner ? (
+                                                    <Button
+                                                        variant="contained"
+                                                        color="primary"
+                                                        size="large"
+                                                        startIcon={<AutoFixHighIcon/>}
+                                                        onClick={() => {
+                                                            window.location.href = `/forge?buildId=${details.id}`;
+                                                            onClose();
+                                                        }}
+                                                    >
+                                                        Edit Build
+                                                    </Button>
+                                                ) : (
+                                                    <Button
+                                                        variant="contained"
+                                                        color="primary"
+                                                        size="large"
+                                                        startIcon={<AutoFixHighIcon/>}
+                                                        onClick={() => {
+                                                            setCloningBuildId(details.id);
+                                                            setCloneDialogOpen(true);
+                                                        }}
+                                                    >
+                                                        Clone & Edit
+                                                    </Button>
+                                                )}
                                                 <Button
                                                     variant={details.isFavorite ? "contained" : "outlined"}
                                                     color={details.isFavorite ? "error" : "primary"}
-                                                    startIcon={details.isFavorite ? <FavoriteIcon /> : <FavoriteBorderIcon />}
+                                                    startIcon={details.isFavorite ? <FavoriteIcon/> :
+                                                        <FavoriteBorderIcon/>}
                                                     onClick={handleFavorite}
                                                 >
@@ -186,17 +250,29 @@
                                 {tabIndex === 1 && (
                                     <Box>
-                                        <Box sx={{ display: 'flex', alignItems: 'center', gap: 2, mb: 4, p: 2, bgcolor: '#5e5e5e', borderRadius: 2 }}>
-                                            <Typography variant="h3" fontWeight="bold">{details.ratingStatistics.averageRating.toFixed(1)}</Typography>
+                                        <Box sx={{
+                                            display: 'flex',
+                                            alignItems: 'center',
+                                            gap: 2,
+                                            mb: 4,
+                                            p: 2,
+                                            bgcolor: '#5e5e5e',
+                                            borderRadius: 2
+                                        }}>
+                                            <Typography variant="h3"
+                                                        fontWeight="bold">{details.ratingStatistics.averageRating.toFixed(1)}</Typography>
                                             <Box>
-                                                <Rating value={details.ratingStatistics.averageRating} readOnly precision={0.5} />
-                                                <Typography variant="body2" color="text.secondary">{details.ratingStatistics.ratingCount} ratings</Typography>
+                                                <Rating value={details.ratingStatistics.averageRating} readOnly
+                                                        precision={0.5}/>
+                                                <Typography variant="body2"
+                                                            color="text.secondary">{details.ratingStatistics.ratingCount} ratings</Typography>
                                             </Box>
                                         </Box>
 
                                         {currentUser && details.userId !== currentUser.id && (
-                                            <Box sx={{ mb: 4, p: 2, border: '1px solid #ddd', borderRadius: 2 }}>
+                                            <Box sx={{mb: 4, p: 2, border: '1px solid #ddd', borderRadius: 2}}>
                                                 <Typography variant="subtitle2" gutterBottom>Your Review</Typography>
-                                                <Box sx={{ display: 'flex', alignItems: 'center', mb: 1 }}>
-                                                    <Rating value={ratingVal} onChange={(_, v) => setRatingVal(v || 5)} />
+                                                <Box sx={{display: 'flex', alignItems: 'center', mb: 1}}>
+                                                    <Rating value={ratingVal}
+                                                            onChange={(_, v) => setRatingVal(v || 5)}/>
                                                 </Box>
                                                 <TextField
@@ -207,5 +283,5 @@
                                                     value={reviewText}
                                                     onChange={(e) => setReviewText(e.target.value)}
-                                                    sx={{ mb: 1 }}
+                                                    sx={{mb: 1}}
                                                 />
                                                 <Button size="small" variant="contained" onClick={handleSubmitReview}>
@@ -216,15 +292,21 @@
 
                                         {currentUser && details.userId === currentUser.id && (
-                                            <Alert severity="info" sx={{ mb: 4 }}>
+                                            <Alert severity="info" sx={{mb: 4}}>
                                                 You cannot rate your own builds.
                                             </Alert>
                                         )}
 
-                                        <Box sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
+                                        <Box sx={{display: 'flex', flexDirection: 'column', gap: 2}}>
                                             {details.reviews.map((rev: any, i: number) => (
-                                                <Box key={i} sx={{ pb: 2, borderBottom: '1px solid #eee' }}>
-                                                    <Box sx={{ display: 'flex', justifyContent: 'space-between', mb: 0.5 }}>
-                                                        <Typography fontWeight="bold" variant="body2">{rev.username}</Typography>
-                                                        <Typography variant="caption" color="text.secondary">{rev.createdAt}</Typography>
+                                                <Box key={i} sx={{pb: 2, borderBottom: '1px solid #eee'}}>
+                                                    <Box sx={{
+                                                        display: 'flex',
+                                                        justifyContent: 'space-between',
+                                                        mb: 0.5
+                                                    }}>
+                                                        <Typography fontWeight="bold"
+                                                                    variant="body2">{rev.username}</Typography>
+                                                        <Typography variant="caption"
+                                                                    color="text.secondary">{rev.createdAt}</Typography>
                                                     </Box>
                                                     <Typography variant="body2">{rev.content}</Typography>
@@ -232,5 +314,6 @@
                                             ))}
                                             {details.reviews.length === 0 && (
-                                                <Typography color="text.secondary" align="center">No reviews yet. Be the first!</Typography>
+                                                <Typography color="text.secondary" align="center">No reviews yet. Be the
+                                                    first!</Typography>
                                             )}
                                         </Box>
