Changeset d07d68c


Ignore:
Timestamp:
02/19/26 23:17:54 (5 months ago)
Author:
Mihail <mihail2.naumov@…>
Branches:
main
Children:
4f2900a
Parents:
6270fa4
Message:

Fixed clone auth errors and component names in the component dialogs.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • components/BuildDetailsDialog.tsx

    r6270fa4 rd07d68c  
    22import {
    33    Dialog, DialogTitle, DialogContent, DialogActions, Button, Box, Typography,
    4     IconButton, Tab, Tabs, Table, TableBody, TableCell, TableRow, Rating, TextField, Avatar, Chip, Alert
     4    IconButton, Tab, Tabs, Table, TableBody, TableCell, TableRow, Rating, TextField, Avatar, Chip, Alert, Snackbar
    55} from '@mui/material';
    66import CloseIcon from '@mui/icons-material/Close';
     
    3434    const [ratingVal, setRatingVal] = useState(5);
    3535
     36    const [snackbar, setSnackbar] = useState<{
     37        open: boolean;
     38        message: string;
     39        severity: 'error' | 'warning' | 'info' | 'success';
     40    }>({
     41        open: false,
     42        message: '',
     43        severity: 'warning'
     44    });
     45
    3646    useEffect(() => {
    3747        if (open && buildId !== null) {
     
    95105        if (!cloningBuildId) return;
    96106
     107        if(!currentUser){
     108            window.location.href="/auth/login";
     109            return;
     110        }
     111
    97112        try {
    98113            const newBuildId = await onCloneBuild({buildId: cloningBuildId});
     
    101116            setCloningBuildId(null);
    102117        } catch (e) {
    103             alert("Failed to clone build. Please try again.");
     118            // alert("Failed to clone build. Please try again.");
     119            setCloneDialogOpen(false);
     120            setSnackbar({
     121                open: true,
     122                message: 'Failed to clone build. Please try again!',
     123                severity: 'error'
     124            })
    104125        }
    105126    };
     127
     128    const handleCloneClick = () => {
     129        if(!currentUser){
     130            window.location.href="/auth/login";
     131            return;
     132        }
     133
     134        setCloningBuildId(details.id);
     135        setCloneDialogOpen(true);
     136    }
    106137
    107138    if (!open) return null;
     
    242273                                                        size="large"
    243274                                                        startIcon={<AutoFixHighIcon/>}
    244                                                         onClick={() => {
    245                                                             setCloningBuildId(details.id);
    246                                                             setCloneDialogOpen(true);
    247                                                         }}
     275                                                        onClick={handleCloneClick}
    248276                                                    >
    249277                                                        Clone & Edit
     
    362390                </DialogActions>
    363391            </Dialog>
     392            <Snackbar
     393                open={snackbar.open}
     394                autoHideDuration={5000}
     395                onClose={() => setSnackbar(prev => ({...prev, open: false}))}
     396                anchorOrigin={{vertical: 'bottom', horizontal: 'center'}}
     397            >
     398                <Alert
     399                    onClose={() => setSnackbar(prev => ({...prev, open: false}))}
     400                    severity={snackbar.severity}
     401                    variant="filled"
     402                    sx={{width: '100%'}}
     403                >
     404                    {snackbar.message}
     405                </Alert>
     406            </Snackbar>
    364407        </>
    365408    );
  • components/ComponentDialog.tsx

    r6270fa4 rd07d68c  
    308308                                Browsing:
    309309                            </Box>
    310                             <b> {category === 'gpu' ? 'GRAPHICS CARDS' : category === 'memory_card' ? 'STORAGE EXPANSION CARDS' : category?.toUpperCase()}</b>
     310                            <b> {
     311                                category === 'gpu' ? 'GRAPHICS CARDS'
     312                                    : category === 'memory_card' ? 'STORAGE EXPANSION CARDS'
     313                                        : category === 'power_supply' ? 'POWER SUPPLIES'
     314                                            : category === 'network_card' ? 'NETWORK CARDS'
     315                                                : category === 'network_adapters' ? 'NETWORK ADAPTERS'
     316                                                    : category === 'sound_card' ? 'SOUND CARDS'
     317                                                        : category === 'optical_drive' ? 'OPTICAL DRIVES'
     318                                                            : category?.toUpperCase()}</b>
    311319                            {mode === 'forge' && currentBuildId && (
    312320                                <Typography
  • pages/dashboard/admin/+Page.tsx

    r6270fa4 rd07d68c  
    9797        setApprovalLoading(true);
    9898        try {
    99             await onSetBuildApprovalStatus({buildId: buildApprovalDialog.buildId, isApproved: false});
     99            await onSetBuildApprovalStatus({
     100                buildId: buildApprovalDialog.buildId,
     101                isApproved: false,
     102            });
    100103            setBuildApprovalDialog({open: false, buildId: null, buildName: ''});
    101104            loadData();
    102105        } catch (e) {
     106            console.error("Reject error:", e); // 🔧 add this
    103107            alert("Reject failed");
    104108        } finally {
  • pages/forge/+Page.tsx

    r6270fa4 rd07d68c  
    491491
    492492                                <TableCell align="right" width="15%" sx={{verticalAlign: 'top', pt: 2}}>
    493                                     {slot.component && (
    494                                         <Box sx={{
    495                                             display: 'flex',
    496                                             gap: 1,
    497                                             justifyContent: 'flex-end',
    498                                             alignItems: 'center'
    499                                         }}>
    500                                             {(slot.type === 'memory' || slot.type === 'storage') && (
    501                                                 <>
    502                                                     <IconButton
    503                                                         size="small"
    504                                                         color="primary"
    505                                                         onClick={() => handleDecrementComponent(slot.id)}
    506                                                         disabled={(slot.component.quantity || 1) <= 1}
    507                                                         sx={{
    508                                                             bgcolor: 'action.hover',
    509                                                             '&:disabled': {bgcolor: 'action.disabledBackground'}
    510                                                         }}
    511                                                     >
    512                                                         <RemoveIcon/>
    513                                                     </IconButton>
    514 
    515                                                     <Typography
    516                                                         variant="body2"
    517                                                         sx={{
    518                                                             minWidth: '20px',
    519                                                             textAlign: 'center',
    520                                                             fontWeight: 'bold'
    521                                                         }}
    522                                                     >
    523                                                         {slot.component.quantity || 1}
    524                                                     </Typography>
    525 
    526                                                     <IconButton
    527                                                         size="small"
    528                                                         color="primary"
    529                                                         onClick={() => handleIncrementComponent(slot.id)}
    530                                                         sx={{bgcolor: 'action.hover'}}
    531                                                     >
    532                                                         <AddIcon/>
    533                                                     </IconButton>
    534                                                 </>
    535                                             )}
    536 
     493                                    <Box sx={{
     494                                        display: 'flex',
     495                                        gap: 1,
     496                                        justifyContent: 'flex-end',
     497                                        alignItems: 'center'
     498                                    }}>
     499                                        {slot.component && (
     500                                            <>
     501                                                {(slot.type === 'memory' || slot.type === 'storage') && (
     502                                                    <>
     503                                                        <IconButton
     504                                                            size="small"
     505                                                            color="primary"
     506                                                            onClick={() => handleDecrementComponent(slot.id)}
     507                                                            disabled={(slot.component.quantity || 1) <= 1}
     508                                                            sx={{
     509                                                                bgcolor: 'action.hover',
     510                                                                '&:disabled': {bgcolor: 'action.disabledBackground'}
     511                                                            }}
     512                                                        >
     513                                                            <RemoveIcon/>
     514                                                        </IconButton>
     515
     516                                                        <Typography
     517                                                            variant="body2"
     518                                                            sx={{
     519                                                                minWidth: '20px',
     520                                                                textAlign: 'center',
     521                                                                fontWeight: 'bold'
     522                                                            }}
     523                                                        >
     524                                                            {slot.component.quantity || 1}
     525                                                        </Typography>
     526
     527                                                        <IconButton
     528                                                            size="small"
     529                                                            color="primary"
     530                                                            onClick={() => handleIncrementComponent(slot.id)}
     531                                                            sx={{bgcolor: 'action.hover'}}
     532                                                        >
     533                                                            <AddIcon/>
     534                                                        </IconButton>
     535                                                    </>
     536                                                )}
     537
     538                                                <IconButton
     539                                                    color="error"
     540                                                    onClick={() => handleRemovePart(slot.id)}
     541                                                >
     542                                                    <DeleteIcon/>
     543                                                </IconButton>
     544                                            </>
     545                                        )}
     546
     547                                        {!slot.required && (
    537548                                            <IconButton
    538                                                 color="error"
    539                                                 onClick={() => handleRemovePart(slot.id)}
     549                                                color="warning"
     550                                                onClick={() => handleDeleteSlot(slot.id)}
    540551                                            >
    541                                                 <DeleteIcon/>
     552                                                <CloseIcon/>
    542553                                            </IconButton>
    543 
    544                                             {!slot.required && (
    545                                                 <IconButton
    546                                                     color="warning"
    547                                                     onClick={() => handleDeleteSlot(slot.id)}
    548                                                 >
    549                                                     <CloseIcon/>
    550                                                 </IconButton>
    551                                             )}
    552                                         </Box>
    553                                     )}
     554                                        )}
     555                                    </Box>
    554556                                </TableCell>
    555557                            </TableRow>
     
    631633                    disabled={isSubmitting}
    632634                >
    633                     {isSubmitting ? <CircularProgress size={24}/> : 'Submit Build For Review'}
     635                    {isSubmitting ? <CircularProgress size={24}/> : 'Save Build'}
    634636                </Button>
    635637            </Box>
Note: See TracChangeset for help on using the changeset viewer.