Ignore:
File:
1 edited

Legend:

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

    r87b79bc r958bc89  
    5151    const [adminComment, setAdminComment] = useState("");
    5252
    53     const [createComponentDialog, setCreateComponentDialog] = useState<{
    54         open: boolean;
    55         suggestion: any | null;
    56     }>({open: false, suggestion: null});
    57 
    5853    const loadData = () => {
    5954        setLoading(true);
     
    148143    if (loading) {
    149144        return (
    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/>
     145            <Container maxWidth="xl" sx={{mt: 4, mb: 10, display: 'flex', justifyContent: 'center', alignItems: 'center', minHeight: '50vh'}}>
     146                <CircularProgress />
    159147            </Container>
    160148        );
     
    208196                                size="large"
    209197                                fullWidth
    210                                 startIcon={<BuildIcon/>}
     198                                startIcon={<BuildIcon />}
    211199                                onClick={() => setAddDialogOpen(true)}
    212                                 sx={{mb: 2}}
     200                                sx={{ mb: 2 }}
    213201                            >
    214202                                Add Component
     
    225213                                    <MemoryIcon color="secondary" sx={{mr: 1}}/>
    226214                                    <Typography variant="h6" fontWeight="bold">
    227                                         Component Suggestions ({data.componentSuggestions?.length || 0})
     215                                        Suggested Components ({data.componentSuggestions?.length || 0})
    228216                                    </Typography>
    229217                                </Box>
    230218
    231219                                {data.componentSuggestions?.length === 0 ? (
    232                                     <Typography color="text.secondary">No suggestions.</Typography>
     220                                    <Typography color="text.secondary">No pending suggestions.</Typography>
    233221                                ) : (
    234222                                    <Table size="small">
     
    238226                                                <TableCell>Type</TableCell>
    239227                                                <TableCell>User</TableCell>
    240                                                 <TableCell>Status</TableCell>
    241228                                                <TableCell align="right">Actions</TableCell>
    242229                                            </TableRow>
     
    258245                                                    <TableCell>{sug.componentType?.toUpperCase()}</TableCell>
    259246                                                    <TableCell>{sug.userId}</TableCell>
    260                                                     <TableCell>
    261                                                         <Chip
    262                                                             label={sug.status || 'pending'}
     247                                                    <TableCell align="right">
     248                                                        <IconButton
    263249                                                            size="small"
    264                                                             color={
    265                                                                 sug.status === 'approved' ? 'success' :
    266                                                                     sug.status === 'rejected' ? 'error' :
    267                                                                         'default'
    268                                                             }
    269                                                         />
    270                                                     </TableCell>
    271                                                     <TableCell align="right">
    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                                                         )}
     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>
    307262                                                    </TableCell>
    308263                                                </TableRow>
     
    344299                                                            color="warning"
    345300                                                            size="small"
    346                                                             startIcon={<BuildIcon/>}
     301                                                            startIcon={<BuildIcon />}
    347302                                                            onClick={(e) => {
    348303                                                                e.stopPropagation();
     
    382337                                                            color="error"
    383338                                                            size="small"
    384                                                             startIcon={<DeleteIcon/>}
     339                                                            startIcon={<DeleteIcon />}
    385340                                                            onClick={(e) => {
    386341                                                                e.stopPropagation();
     
    403358            </Grid>
    404359
    405             <Dialog open={suggestionDialog.open}
    406                     onClose={() => setSuggestionDialog({...suggestionDialog, open: false})}>
     360            <Dialog open={suggestionDialog.open} onClose={() => setSuggestionDialog({...suggestionDialog, open: false})}>
    407361                <DialogTitle>Review Component Suggestion</DialogTitle>
    408362                <DialogContent>
     
    415369                        value={adminComment}
    416370                        onChange={(e) => setAdminComment(e.target.value)}
    417                         sx={{mt: 2}}
     371                        sx={{ mt: 2 }}
    418372                    />
    419373                </DialogContent>
     
    494448                        color="error"
    495449                        disabled={deleteLoading}
    496                         startIcon={deleteLoading ? <CircularProgress size={20}/> : <DeleteIcon/>}
     450                        startIcon={deleteLoading ? <CircularProgress size={20}/> : <DeleteIcon />}
    497451                    >
    498452                        {deleteLoading ? 'Deleting...' : 'Delete Build'}
     
    517471                }}
    518472            />
    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             />
    533473        </Container>
    534474    );
Note: See TracChangeset for help on using the changeset viewer.