From 69c9fd6bef98878ab04880e55f64b54ad19908fb Mon Sep 17 00:00:00 2001 From: Vishesh 'ironeagle' Bangotra Date: Tue, 7 Apr 2026 11:26:56 +0530 Subject: [PATCH] fixed urls (hardcoded /admin) to admin navigation --- react-openapi/Admin.tsx | 4 ++-- react-openapi/components/EnhancedTable.tsx | 12 ++++++------ react-openapi/components/ResourceView.tsx | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/react-openapi/Admin.tsx b/react-openapi/Admin.tsx index e1ae5c2..738495d 100644 --- a/react-openapi/Admin.tsx +++ b/react-openapi/Admin.tsx @@ -51,7 +51,7 @@ function Dashboard({ basePath }: { basePath: string }) { transition: 'transform 0.2s', '&:hover': { transform: 'translateY(-4px)', boxShadow: 4 } }} - onClick={() => navigate(`${basePath}/${res.name}`)} + onClick={() => navigate(`/admin/${res.name}`)} > {res.pluralLabel} Manage {res.pluralLabel.toLowerCase()} @@ -88,7 +88,7 @@ function AdminApp({ basePath }: { basePath: string }) { navigate(`${basePath}/${name}`)} + onSelectResource={(name) => navigate(`/admin/${name}`)} resources={config?.resources || []} > diff --git a/react-openapi/components/EnhancedTable.tsx b/react-openapi/components/EnhancedTable.tsx index ee1e158..9e00a1c 100644 --- a/react-openapi/components/EnhancedTable.tsx +++ b/react-openapi/components/EnhancedTable.tsx @@ -104,12 +104,12 @@ export default function EnhancedTable({ } label="View" - onClick={() => navigate(`/${config.name}/${params.id}`)} + onClick={() => navigate(`/admin/${config.name}/${params.id}`)} />, } label="Edit" - onClick={() => navigate(`/${config.name}/edit/${params.id}`)} + onClick={() => navigate(`/admin/${config.name}/edit/${params.id}`)} />, } @@ -222,8 +222,8 @@ function MobileCardRow({ row, config, onDelete, onNavigate, navigate }: any) { - { handleClose(); navigate(`/${config.name}/${id}`); }}>View - { handleClose(); navigate(`/${config.name}/edit/${id}`); }}>Edit + { handleClose(); navigate(`/admin/${config.name}/${id}`); }}>View + { handleClose(); navigate(`/admin/${config.name}/edit/${id}`); }}>Edit { handleClose(); onDelete(id); }} sx={{ color: 'error.main' }}>Delete @@ -242,7 +242,7 @@ function MobileCardRow({ row, config, onDelete, onNavigate, navigate }: any) { - + ); @@ -359,7 +359,7 @@ function FieldRenderer({ params, field, fieldKey, config, onNavigate, navigate, label={value} size="small" 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' }} /> ); diff --git a/react-openapi/components/ResourceView.tsx b/react-openapi/components/ResourceView.tsx index 4ec0c49..f770d45 100644 --- a/react-openapi/components/ResourceView.tsx +++ b/react-openapi/components/ResourceView.tsx @@ -48,11 +48,11 @@ export default function ResourceView({ config, onNavigateToResource }: ResourceV const deleteMutation = useDelete(); const handleEdit = (item: any) => { - navigate(`/${config.name}/edit/${item[config.primaryKey]}`); + navigate(`/admin/${config.name}/edit/${item[config.primaryKey]}`); }; const handleCreate = () => { - navigate(`/${config.name}/create`); + navigate(`/admin/${config.name}/create`); }; const handleSave = async (formData: any) => { @@ -62,7 +62,7 @@ export default function ResourceView({ config, onNavigateToResource }: ResourceV } else { await createMutation.mutateAsync(formData); } - navigate(`/${config.name}`); + navigate(`/admin/${config.name}`); } catch (err) { console.error('Save failed:', err); } @@ -90,7 +90,7 @@ export default function ResourceView({ config, onNavigateToResource }: ResourceV onEdit={handleEdit} onDelete={handleDelete} onCreate={handleCreate} - onNavigateToResource={(res, id) => navigate(`/${res}/${id}`)} + onNavigateToResource={(res, id) => navigate(`/admin/${res}/${id}`)} /> ) : ( @@ -98,10 +98,10 @@ export default function ResourceView({ config, onNavigateToResource }: ResourceV config={config} initialData={isCreate ? null : itemQuery.data} onSave={handleSave} - onCancel={() => navigate(`/${config.name}`)} + onCancel={() => navigate(`/admin/${config.name}`)} loading={createMutation.isPending || updateMutation.isPending} readOnly={isView} - onEditClick={() => navigate(`/${config.name}/edit/${id}`)} + onEditClick={() => navigate(`/admin/${config.name}/edit/${id}`)} /> )}