Changeset 9d40151


Ignore:
Timestamp:
02/25/26 20:46:23 (5 months ago)
Author:
Mihail <mihail2.naumov@…>
Branches:
main
Children:
ad3c219
Parents:
4f2900a
Message:

Fixed total build price error and other small errors.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • components/BuildDetailsDialog.tsx

    r4f2900a r9d40151  
    125125        }
    126126    };
    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     }
    137127
    138128    if (!open) return null;
     
    273263                                                        size="large"
    274264                                                        startIcon={<AutoFixHighIcon/>}
    275                                                         onClick={handleCloneClick}
    276                                                     >
     265                                                        onClick={() => {
     266                                                            setCloningBuildId(details.id);
     267                                                            setCloneDialogOpen(true);
     268                                                        }}                                                    >
    277269                                                        Clone & Edit
    278270                                                    </Button>
  • database/drizzle/queries/components.ts

    r4f2900a r9d40151  
    10671067            );
    10681068
    1069         // const totalPrice = buildComponents.reduce((sum, c) =>
    1070         //     sum + (Number(c.price) * c.quantity), 0
    1071         // );
    1072 
    1073         // await tx
    1074         //     .update(buildsTable)
    1075         //     .set({
    1076         //         totalPrice: totalPrice.toFixed(2)
    1077         //     })
    1078         //     .where(
    1079         //         eq(buildsTable.id, buildId)
    1080         //     );
     1069        const totalPrice = buildComponents.reduce((sum, c) =>
     1070            sum + (Number(c.price) * c.quantity), 0
     1071        );
     1072
     1073        await tx
     1074            .update(buildsTable)
     1075            .set({
     1076                totalPrice: totalPrice.toFixed(2)
     1077            })
     1078            .where(
     1079                eq(buildsTable.id, buildId)
     1080            );
    10811081
    10821082        return buildId;
     
    11511151            );
    11521152
    1153         // const totalPrice = buildComponents.reduce((sum, c) =>
    1154         //     sum + (Number(c.price) * c.quantity), 0
    1155         // );
    1156 
    1157         // await tx
    1158         //     .update(buildsTable)
    1159         //     .set({
    1160         //         totalPrice: totalPrice.toFixed(2)
    1161         //     })
    1162         //     .where(
    1163         //         eq(buildsTable.id, buildId)
    1164         //     );
     1153        const totalPrice = buildComponents.reduce((sum, c) =>
     1154            sum + (Number(c.price) * c.quantity), 0
     1155        );
     1156
     1157        await tx
     1158            .update(buildsTable)
     1159            .set({
     1160                totalPrice: totalPrice.toFixed(2)
     1161            })
     1162            .where(
     1163                eq(buildsTable.id, buildId)
     1164            );
    11651165
    11661166        return componentId;
  • pages/dashboard/admin/+Page.tsx

    r4f2900a r9d40151  
    352352                            }}>
    353353                                {data.pendingBuilds.map((build: any) => (
    354                                     <Box key={build.id}>
     354                                    <Box key={build.id} sx={{
     355                                        display: 'flex',
     356                                        flexDirection: 'column',
     357                                        borderRadius: 2,
     358                                        overflow: 'hidden',
     359                                        bgcolor: 'background.paper'
     360                                    }}>
    355361                                        <BuildCard
    356362                                            build={build}
    357363                                            onClick={() => setSelectedBuildId(build.id)}
    358364                                        />
    359                                         <Box sx={{mt: 1, display: 'flex', gap: 1, justifyContent: 'center'}}>
    360                                             <Button
    361                                                 variant="contained"
    362                                                 color="warning"
    363                                                 size="small"
    364                                                 startIcon={<BuildIcon/>}
    365                                                 onClick={(e) => {
    366                                                     e.stopPropagation();
    367                                                     openBuildApproval(build.id, build.name);
    368                                                 }}
    369                                             >
    370                                                 Review
    371                                             </Button>
    372                                         </Box>
     365                                        <Button
     366                                            variant="contained"
     367                                            color="warning"
     368                                            size="small"
     369                                            fullWidth
     370                                            startIcon={<BuildIcon/>}
     371                                            onClick={(e) => {
     372                                                e.stopPropagation();
     373                                                openBuildApproval(build.id, build.name);
     374                                            }}
     375                                            sx={{borderRadius: 0}}
     376                                        >
     377                                            Review
     378                                        </Button>
    373379                                    </Box>
    374380                                ))}
     381
    375382                            </Box>
    376383                        )}
  • pages/forge/+Page.tsx

    r4f2900a r9d40151  
    22import {
    33    Container, Paper, Typography, Box, Table, TableBody, TableCell, TableContainer, TableHead, TableRow,
    4     Button, IconButton, Avatar, TextField, Grid, Chip, CircularProgress,
     4    Button, IconButton, Avatar, TextField, Chip, CircularProgress,
    55    Menu, MenuItem, ListItemIcon, Dialog, DialogTitle, DialogContent, DialogActions
    66} from '@mui/material';
     
    7474        if (buildId && buildName.trim()) {
    7575            const timeoutId = setTimeout(() => {
    76                 saveBuildState({buildId, name: buildName.trim(), description});
     76                saveBuildState({buildId, name: buildName.trim(), description}).catch(() => {
     77                });
    7778            }, 1000);
    7879
     
    326327        const slot = slots.find(s => s.id === slotId);
    327328        if (slot?.component) {
    328             handleRemovePart(slotId);
     329            handleRemovePart(slotId).catch(() => {
     330            });
    329331        }
    330332        setSlots(prev => prev.filter(s => s.id !== slotId));
     
    388390                severity: 'error'
    389391            });
     392            return;
    390393        } finally {
    391394            setIsSubmitting(false);
     
    402405            <Paper sx={{p: 4, mb: 0, bgcolor: '#ff8201', border: '1px solid #1e1e1e', color: 'white'}}>
    403406                <Typography variant="h4" align="center" fontWeight="bold">Forge Your Machine</Typography>
    404                 <Grid container spacing={2} justifyContent="center" sx={{mt: 2}}>
    405                     <Grid item xs={12} md={6}>
    406                         <TextField
    407                             fullWidth
    408                             label="Build Name *"
    409                             value={buildName}
    410                             onChange={e => setBuildName(e.target.value)}
    411                             sx={{bgcolor: '#1e1e1e', borderRadius: 1, color: 'white'}}
    412                         />
    413                     </Grid>
    414                 </Grid>
     407                <Box sx={{display: 'flex', justifyContent: 'center', mt: 2}}>
     408                    <TextField
     409                        label="Build Name *"
     410                        value={buildName}
     411                        onChange={e => setBuildName(e.target.value)}
     412                        sx={{bgcolor: '#1e1e1e', textAlign: 'center', borderRadius: 1, color: 'white', width: '200px'}}
     413                    />
     414                </Box>
     415
    415416            </Paper>
    416417
     
    580581                            sx: {
    581582                                position: 'absolute',
    582                                 top: '30%',
     583                                top: '46%',
    583584                                // left: '50%',
    584585                                // transform: 'translate(50%, +50%)',
Note: See TracChangeset for help on using the changeset viewer.