Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(admin): added redirect to main page #301

Merged
merged 5 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
vgeffer marked this conversation as resolved.
Show resolved Hide resolved
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 (
<>
vgeffer marked this conversation as resolved.
Show resolved Hide resolved
<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} />
}
Loading