fixed urls (hardcoded /admin) to admin navigation
This commit is contained in:
@@ -51,7 +51,7 @@ function Dashboard({ basePath }: { basePath: string }) {
|
|||||||
transition: 'transform 0.2s',
|
transition: 'transform 0.2s',
|
||||||
'&:hover': { transform: 'translateY(-4px)', boxShadow: 4 }
|
'&:hover': { transform: 'translateY(-4px)', boxShadow: 4 }
|
||||||
}}
|
}}
|
||||||
onClick={() => navigate(`${basePath}/${res.name}`)}
|
onClick={() => navigate(`/admin/${res.name}`)}
|
||||||
>
|
>
|
||||||
<Typography variant="h6" color="primary">{res.pluralLabel}</Typography>
|
<Typography variant="h6" color="primary">{res.pluralLabel}</Typography>
|
||||||
<Typography variant="body2" color="text.secondary">Manage {res.pluralLabel.toLowerCase()}</Typography>
|
<Typography variant="body2" color="text.secondary">Manage {res.pluralLabel.toLowerCase()}</Typography>
|
||||||
@@ -88,7 +88,7 @@ function AdminApp({ basePath }: { basePath: string }) {
|
|||||||
<AdminLayout
|
<AdminLayout
|
||||||
username={currentUser.username}
|
username={currentUser.username}
|
||||||
onLogout={logout}
|
onLogout={logout}
|
||||||
onSelectResource={(name) => navigate(`${basePath}/${name}`)}
|
onSelectResource={(name) => navigate(`/admin/${name}`)}
|
||||||
resources={config?.resources || []}
|
resources={config?.resources || []}
|
||||||
>
|
>
|
||||||
<Routes>
|
<Routes>
|
||||||
|
|||||||
@@ -104,12 +104,12 @@ export default function EnhancedTable({
|
|||||||
<GridActionsCellItem
|
<GridActionsCellItem
|
||||||
icon={<VisibilityIcon />}
|
icon={<VisibilityIcon />}
|
||||||
label="View"
|
label="View"
|
||||||
onClick={() => navigate(`/${config.name}/${params.id}`)}
|
onClick={() => navigate(`/admin/${config.name}/${params.id}`)}
|
||||||
/>,
|
/>,
|
||||||
<GridActionsCellItem
|
<GridActionsCellItem
|
||||||
icon={<EditIcon />}
|
icon={<EditIcon />}
|
||||||
label="Edit"
|
label="Edit"
|
||||||
onClick={() => navigate(`/${config.name}/edit/${params.id}`)}
|
onClick={() => navigate(`/admin/${config.name}/edit/${params.id}`)}
|
||||||
/>,
|
/>,
|
||||||
<GridActionsCellItem
|
<GridActionsCellItem
|
||||||
icon={<DeleteIcon />}
|
icon={<DeleteIcon />}
|
||||||
@@ -222,8 +222,8 @@ function MobileCardRow({ row, config, onDelete, onNavigate, navigate }: any) {
|
|||||||
<MoreVertIcon fontSize="small" />
|
<MoreVertIcon fontSize="small" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Menu anchorEl={anchorEl} open={open} onClose={handleClose}>
|
<Menu anchorEl={anchorEl} open={open} onClose={handleClose}>
|
||||||
<MenuItem onClick={() => { handleClose(); navigate(`/${config.name}/${id}`); }}>View</MenuItem>
|
<MenuItem onClick={() => { handleClose(); navigate(`/admin/${config.name}/${id}`); }}>View</MenuItem>
|
||||||
<MenuItem onClick={() => { handleClose(); navigate(`/${config.name}/edit/${id}`); }}>Edit</MenuItem>
|
<MenuItem onClick={() => { handleClose(); navigate(`/admin/${config.name}/edit/${id}`); }}>Edit</MenuItem>
|
||||||
<MenuItem onClick={() => { handleClose(); onDelete(id); }} sx={{ color: 'error.main' }}>Delete</MenuItem>
|
<MenuItem onClick={() => { handleClose(); onDelete(id); }} sx={{ color: 'error.main' }}>Delete</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -242,7 +242,7 @@ function MobileCardRow({ row, config, onDelete, onNavigate, navigate }: any) {
|
|||||||
</Box>
|
</Box>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<CardActions sx={{ justifyContent: 'flex-end', px: 2, pb: 2 }}>
|
<CardActions sx={{ justifyContent: 'flex-end', px: 2, pb: 2 }}>
|
||||||
<Button size="small" onClick={() => navigate(`/${config.name}/${id}`)}>View Details</Button>
|
<Button size="small" onClick={() => navigate(`/admin/${config.name}/${id}`)}>View Details</Button>
|
||||||
</CardActions>
|
</CardActions>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
@@ -359,7 +359,7 @@ function FieldRenderer({ params, field, fieldKey, config, onNavigate, navigate,
|
|||||||
label={value}
|
label={value}
|
||||||
size="small"
|
size="small"
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={(e) => { e.stopPropagation(); navigate(`/${config.name}/${params.row[config.primaryKey]}`); }}
|
onClick={(e) => { e.stopPropagation(); navigate(`/admin/${config.name}/${params.row[config.primaryKey]}`); }}
|
||||||
sx={{ cursor: 'pointer', fontWeight: 'bold' }}
|
sx={{ cursor: 'pointer', fontWeight: 'bold' }}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -48,11 +48,11 @@ export default function ResourceView({ config, onNavigateToResource }: ResourceV
|
|||||||
const deleteMutation = useDelete();
|
const deleteMutation = useDelete();
|
||||||
|
|
||||||
const handleEdit = (item: any) => {
|
const handleEdit = (item: any) => {
|
||||||
navigate(`/${config.name}/edit/${item[config.primaryKey]}`);
|
navigate(`/admin/${config.name}/edit/${item[config.primaryKey]}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCreate = () => {
|
const handleCreate = () => {
|
||||||
navigate(`/${config.name}/create`);
|
navigate(`/admin/${config.name}/create`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSave = async (formData: any) => {
|
const handleSave = async (formData: any) => {
|
||||||
@@ -62,7 +62,7 @@ export default function ResourceView({ config, onNavigateToResource }: ResourceV
|
|||||||
} else {
|
} else {
|
||||||
await createMutation.mutateAsync(formData);
|
await createMutation.mutateAsync(formData);
|
||||||
}
|
}
|
||||||
navigate(`/${config.name}`);
|
navigate(`/admin/${config.name}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Save failed:', err);
|
console.error('Save failed:', err);
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ export default function ResourceView({ config, onNavigateToResource }: ResourceV
|
|||||||
onEdit={handleEdit}
|
onEdit={handleEdit}
|
||||||
onDelete={handleDelete}
|
onDelete={handleDelete}
|
||||||
onCreate={handleCreate}
|
onCreate={handleCreate}
|
||||||
onNavigateToResource={(res, id) => navigate(`/${res}/${id}`)}
|
onNavigateToResource={(res, id) => navigate(`/admin/${res}/${id}`)}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Paper sx={{ p: 4 }}>
|
<Paper sx={{ p: 4 }}>
|
||||||
@@ -98,10 +98,10 @@ export default function ResourceView({ config, onNavigateToResource }: ResourceV
|
|||||||
config={config}
|
config={config}
|
||||||
initialData={isCreate ? null : itemQuery.data}
|
initialData={isCreate ? null : itemQuery.data}
|
||||||
onSave={handleSave}
|
onSave={handleSave}
|
||||||
onCancel={() => navigate(`/${config.name}`)}
|
onCancel={() => navigate(`/admin/${config.name}`)}
|
||||||
loading={createMutation.isPending || updateMutation.isPending}
|
loading={createMutation.isPending || updateMutation.isPending}
|
||||||
readOnly={isView}
|
readOnly={isView}
|
||||||
onEditClick={() => navigate(`/${config.name}/edit/${id}`)}
|
onEditClick={() => navigate(`/admin/${config.name}/edit/${id}`)}
|
||||||
/>
|
/>
|
||||||
</Paper>
|
</Paper>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user