Skip to content

Commit

Permalink
feat(admin): added redirect to main page
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeffer committed Dec 10, 2023
1 parent 646e8cf commit efde40d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/Admin/Admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {FC} from 'react'
import {Admin as ReactAdmin, Resource} from 'react-admin'

import {dataProvider} from './dataProvider'
import {AdminLayout} from './layout'
import {FlatpageCreate} from './resources/base/flat-page/FlatpageCreate'
import {FlatpageEdit} from './resources/base/flat-page/FlatpageEdit'
import {FlatpageList} from './resources/base/flat-page/FlatpageList'
Expand All @@ -26,7 +27,7 @@ export const Admin: FC = () => {
const authProvider = useAuthProvider()

return (
<ReactAdmin authProvider={authProvider} dataProvider={dataProvider}>
<ReactAdmin authProvider={authProvider} dataProvider={dataProvider} layout={AdminLayout}>
<Resource name="cms/post" list={PostList} edit={PostEdit} show={PostShow} create={PostCreate} />
<Resource name="competition/series" list={SeriesList} edit={SeriesEdit} show={SeriesShow} />
<Resource name="competition/event" list={EventList} edit={EventEdit} show={EventShow} create={EventCreate} />
Expand Down
25 changes: 25 additions & 0 deletions src/components/Admin/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import HomeIcon from '@mui/icons-material/Home'
import {Box, IconButton, Tooltip} from '@mui/material'
import {useRouter} from 'next/router'
import {AppBar, Layout, LayoutProps} from 'react-admin'

const AppMenuBar = () => {
const router = useRouter()

return (
<>
<AppBar position="relative">
<Box flex={1} />
<Tooltip title="Back to main page">
<IconButton color="inherit" onClick={() => router.push('/')}>
<HomeIcon />
</IconButton>
</Tooltip>
</AppBar>
</>
)
}

export const AdminLayout = (props: LayoutProps) => {
return <Layout {...props} appBar={AppMenuBar} />
}

0 comments on commit efde40d

Please sign in to comment.