Changeset a744c90 for pages


Ignore:
Timestamp:
01/28/26 12:13:13 (5 months ago)
Author:
Tome <gjorgievtome@…>
Branches:
main
Children:
1d8f088
Parents:
e03e6fb (diff), 87b79bc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'origin/main'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pages/dashboard/admin/+Page.tsx

    re03e6fb ra744c90  
    5151    const [adminComment, setAdminComment] = useState("");
    5252
     53    const [createComponentDialog, setCreateComponentDialog] = useState<{
     54        open: boolean;
     55        suggestion: any | null;
     56    }>({open: false, suggestion: null});
     57
    5358    const loadData = () => {
    5459        setLoading(true);
     
    143148    if (loading) {
    144149        return (
    145             <Container maxWidth="xl" sx={{mt: 4, mb: 10, display: 'flex', justifyContent: 'center', alignItems: 'center', minHeight: '50vh'}}>
    146                 <CircularProgress />
     150            <Container maxWidth="xl" sx={{
     151                mt: 4,
     152                mb: 10,
     153                display: 'flex',
     154                justifyContent: 'center',
     155                alignItems: 'center',
     156                minHeight: '50vh'
     157            }}>
     158                <CircularProgress/>
    147159            </Container>
    148160        );
     
    196208                                size="large"
    197209                                fullWidth
    198                                 startIcon={<BuildIcon />}
     210                                startIcon={<BuildIcon/>}
    199211                                onClick={() => setAddDialogOpen(true)}
    200                                 sx={{ mb: 2 }}
     212                                sx={{mb: 2}}
    201213                            >
    202214                                Add Component
     
    213225                                    <MemoryIcon color="secondary" sx={{mr: 1}}/>
    214226                                    <Typography variant="h6" fontWeight="bold">
    215                                         Suggested Components ({data.componentSuggestions?.length || 0})
     227                                        Component Suggestions ({data.componentSuggestions?.length || 0})
    216228                                    </Typography>
    217229                                </Box>
    218230
    219231                                {data.componentSuggestions?.length === 0 ? (
    220                                     <Typography color="text.secondary">No pending suggestions.</Typography>
     232                                    <Typography color="text.secondary">No suggestions.</Typography>
    221233                                ) : (
    222234                                    <Table size="small">
     
    226238                                                <TableCell>Type</TableCell>
    227239                                                <TableCell>User</TableCell>
     240                                                <TableCell>Status</TableCell>
    228241                                                <TableCell align="right">Actions</TableCell>
    229242                                            </TableRow>
     
    245258                                                    <TableCell>{sug.componentType?.toUpperCase()}</TableCell>
    246259                                                    <TableCell>{sug.userId}</TableCell>
     260                                                    <TableCell>
     261                                                        <Chip
     262                                                            label={sug.status || 'pending'}
     263                                                            size="small"
     264                                                            color={
     265                                                                sug.status === 'approved' ? 'success' :
     266                                                                    sug.status === 'rejected' ? 'error' :
     267                                                                        'default'
     268                                                            }
     269                                                        />
     270                                                    </TableCell>
    247271                                                    <TableCell align="right">
    248                                                         <IconButton
    249                                                             size="small"
    250                                                             color="success"
    251                                                             onClick={() => openSuggestionReview(sug.id, 'approved')}
    252                                                         >
    253                                                             <CheckCircleIcon/>
    254                                                         </IconButton>
    255                                                         <IconButton
    256                                                             size="small"
    257                                                             color="error"
    258                                                             onClick={() => openSuggestionReview(sug.id, 'rejected')}
    259                                                         >
    260                                                             <CancelIcon/>
    261                                                         </IconButton>
     272                                                        {sug.status === 'pending' ? (
     273                                                            <>
     274                                                                <IconButton
     275                                                                    size="small"
     276                                                                    color="success"
     277                                                                    onClick={() => openSuggestionReview(sug.id, 'approved')}
     278                                                                >
     279                                                                    <CheckCircleIcon/>
     280                                                                </IconButton>
     281                                                                <IconButton
     282                                                                    size="small"
     283                                                                    color="error"
     284                                                                    onClick={() => openSuggestionReview(sug.id, 'rejected')}
     285                                                                >
     286                                                                    <CancelIcon/>
     287                                                                </IconButton>
     288                                                            </>
     289                                                        ) : sug.status === 'approved' ? (
     290                                                            <Button
     291                                                                size="small"
     292                                                                variant="contained"
     293                                                                color="warning"
     294                                                                startIcon={<AddIcon/>}
     295                                                                onClick={() => setCreateComponentDialog({
     296                                                                    open: true,
     297                                                                    suggestion: sug
     298                                                                })}
     299                                                            >
     300                                                                Create
     301                                                            </Button>
     302                                                        ) : (
     303                                                            <Typography variant="caption" color="text.secondary">
     304                                                                {sug.adminComment || 'Rejected'}
     305                                                            </Typography>
     306                                                        )}
    262307                                                    </TableCell>
    263308                                                </TableRow>
     
    299344                                                            color="warning"
    300345                                                            size="small"
    301                                                             startIcon={<BuildIcon />}
     346                                                            startIcon={<BuildIcon/>}
    302347                                                            onClick={(e) => {
    303348                                                                e.stopPropagation();
     
    337382                                                            color="error"
    338383                                                            size="small"
    339                                                             startIcon={<DeleteIcon />}
     384                                                            startIcon={<DeleteIcon/>}
    340385                                                            onClick={(e) => {
    341386                                                                e.stopPropagation();
     
    358403            </Grid>
    359404
    360             <Dialog open={suggestionDialog.open} onClose={() => setSuggestionDialog({...suggestionDialog, open: false})}>
     405            <Dialog open={suggestionDialog.open}
     406                    onClose={() => setSuggestionDialog({...suggestionDialog, open: false})}>
    361407                <DialogTitle>Review Component Suggestion</DialogTitle>
    362408                <DialogContent>
     
    369415                        value={adminComment}
    370416                        onChange={(e) => setAdminComment(e.target.value)}
    371                         sx={{ mt: 2 }}
     417                        sx={{mt: 2}}
    372418                    />
    373419                </DialogContent>
     
    448494                        color="error"
    449495                        disabled={deleteLoading}
    450                         startIcon={deleteLoading ? <CircularProgress size={20}/> : <DeleteIcon />}
     496                        startIcon={deleteLoading ? <CircularProgress size={20}/> : <DeleteIcon/>}
    451497                    >
    452498                        {deleteLoading ? 'Deleting...' : 'Delete Build'}
     
    471517                }}
    472518            />
     519
     520            <AddComponentDialog
     521                open={createComponentDialog.open}
     522                onClose={() => setCreateComponentDialog({ open: false, suggestion: null })}
     523                onSuccess={() => {
     524                    loadData();
     525                    setCreateComponentDialog({ open: false, suggestion: null });
     526                }}
     527                prefillData={createComponentDialog.suggestion ? {
     528                    type: createComponentDialog.suggestion.componentType,
     529                    suggestionLink: createComponentDialog.suggestion.link,
     530                    suggestionDescription: createComponentDialog.suggestion.description
     531                } : undefined}
     532            />
    473533        </Container>
    474534    );
Note: See TracChangeset for help on using the changeset viewer.