import {
Refine,
LayoutProps,
useMenu,
useRouterContext,
} from "@pankod/refine-core";
import routerProvider from "@pankod/refine-react-router-v6";
import dataProvider from "@pankod/refine-simple-rest";
import {
MantineProvider,
Global,
NotificationsProvider,
notificationProvider,
LightTheme,
Box,
MantineHeader,
Group,
NavLink,
} from "@pankod/refine-mantine";
import { IconList, IconCategory, IconUsers } from "@tabler/icons";
import { PostList } from "./pages/posts";
const CustomLayout: React.FC<LayoutProps> = ({ children }) => {
const { menuItems, selectedKey } = useMenu();
const { Link } = useRouterContext();
return (
<Box sx={{ display: "flex", flexDirection: "column" }}>
<MantineHeader height={50} p="xs">
<Group>
{menuItems.map(({ route, label, icon }) => (
<Box key={route}>
<NavLink
component={Link}
to={route}
label={label}
icon={icon ?? <IconList />}
active={route === selectedKey}
/>
</Box>
))}
</Group>
</MantineHeader>
<Box>{children}</Box>
</Box>
);
};
const App = () => {
return (
<MantineProvider theme={LightTheme} withNormalizeCSS withGlobalStyles>
<Global styles={{ body: { WebkitFontSmoothing: "auto" } }} />
<NotificationsProvider position="top-right">
<Refine
routerProvider={routerProvider}
dataProvider={dataProvider(
"https://api.fake-rest.refine.dev",
)}
notificationProvider={notificationProvider}
Layout={CustomLayout}
resources={[
{
name: "posts",
list: PostList,
},
{
name: "categories",
list: DummyListPage,
icon: <IconCategory />,
},
{
name: "users",
list: DummyListPage,
icon: <IconUsers />,
},
]}
/>
</NotificationsProvider>
</MantineProvider>
);
};