Skip to content

Commit

Permalink
fix: admin dashboard画面のレイアウトを直し、全てのページで同じにする
Browse files Browse the repository at this point in the history
  • Loading branch information
rito528 committed Apr 12, 2024
1 parent fa98792 commit cf126ec
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 12 deletions.
60 changes: 60 additions & 0 deletions src/app/(authed)/admin/_components/AdminNavigationBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use client';

import {
Typography,
Box,
AppBar,
Toolbar,
Link,
Paper,
IconButton,
InputBase,
} from '@mui/material';
import SearchIcon from '@mui/icons-material/Search';
import Image from 'next/image';

const SearchField = () => {
return (
<Paper
component="form"
sx={{ p: '2px 4px', display: 'flex', alignItems: 'center', width: 400 }}
>
<IconButton sx={{ p: '10px' }} aria-label="search">
<SearchIcon />
</IconButton>
<InputBase
sx={{ ml: 1, flex: 1 }}
placeholder="Search..."
inputProps={{ 'aria-label': 'search...' }}
/>
</Paper>
);
};

const NavBar = () => {
return (
<Box sx={{ flexGrow: 1 }}>
<AppBar
position="fixed"
sx={{ zIndex: (theme) => theme.zIndex.drawer + 1 }}
>
<Toolbar>
<Image
src="/favicon.ico"
width={32}
height={32}
alt={'seichi-portal logo'}
/>
<Typography variant="h6" component="div" sx={{ flexGrow: 1 }}>
<Link href="/admin" color="#fff" sx={{ textDecoration: 'none' }}>
Seichi Portal Admin
</Link>
</Typography>
<SearchField />
</Toolbar>
</AppBar>
</Box>
);
};

export default NavBar;
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
'use client';

import { Star } from '@mui/icons-material';
import { styled, Grid, Typography, MenuList, MenuItem } from '@mui/material';
import { styled, Typography, MenuList, MenuItem } from '@mui/material';
import Drawer from '@mui/material/Drawer';

const Demo = styled('div')(({ theme }) => ({
backgroundColor: theme.palette.background.paper,
color: theme.palette.text.primary,
}));

const drawerWidth = 240;

const DashboardMenu = () => {
return (
<Grid item xs={12} md={6}>
<Drawer
variant="permanent"
sx={{
width: drawerWidth,
[`& .MuiDrawer-paper`]: { width: drawerWidth, boxSizing: 'border-box' },
}}
>
<Typography sx={{ mt: 4, mb: 2 }} variant="h6" component="div">
Menu
</Typography>
Expand All @@ -25,7 +35,7 @@ const DashboardMenu = () => {
})}
</MenuList>
</Demo>
</Grid>
</Drawer>
);
};

Expand Down
2 changes: 0 additions & 2 deletions src/app/(authed)/admin/forms/create/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
'use client';

import DashboardMenu from '@/components/DashboardMenu';
import { CreateFormComponent } from '@/features/form/components/CreateForm';
const Home = () => {
return (
<>
<DashboardMenu />
<CreateFormComponent />
</>
);
Expand Down
2 changes: 0 additions & 2 deletions src/app/(authed)/admin/forms/edit/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { redirect } from 'next/navigation';
import useSWR from 'swr';
import DashboardMenu from '@/components/DashboardMenu';
import { EditFormComponent } from '@/features/form/components/editForm';
import type { Form } from '@/_schemas/formSchema';

Expand All @@ -21,7 +20,6 @@ const Home = ({ params }: { params: { id: number } }) => {

return (
<>
<DashboardMenu />
<EditFormComponent form={data} />
</>
);
Expand Down
2 changes: 0 additions & 2 deletions src/app/(authed)/admin/forms/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { redirect } from 'next/navigation';
import useSWR from 'swr';
import DashboardMenu from '@/components/DashboardMenu';
import {
CreateFormButton,
Forms,
Expand All @@ -24,7 +23,6 @@ const Home = () => {

return (
<>
<DashboardMenu />
<CreateFormButton />
<Forms forms={forms} />
</>
Expand Down
6 changes: 4 additions & 2 deletions src/app/(authed)/admin/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import '../../globals.css';
import { Inter } from 'next/font/google';
import NavBar from '@/components/NavBar';
import { AuthenticatedTemplate } from '@/features/user/components/AuthenticatedTemplate';
import { MsalProvider } from '@/features/user/components/MsalProvider';
import { NeedToSignin } from '@/features/user/components/NeedToSignin';
import { UnauthenticatedTemplate } from '@/features/user/components/UnauthenticatedTemplate';
import styles from '../../page.module.css';
import type { Metadata } from 'next';
import type { ReactNode } from 'react';
import AdminNavigationBar from './_components/AdminNavigationBar';
import DashboardMenu from './_components/DashboardMenu';

const inter = Inter({ subsets: ['latin'] });

Expand All @@ -22,7 +23,8 @@ const RootLayout = ({ children }: { children: ReactNode }) => {
<body className={inter.className}>
<main className={styles['main']}>
<MsalProvider>
<NavBar />
<AdminNavigationBar />
<DashboardMenu />
<AuthenticatedTemplate>{children}</AuthenticatedTemplate>
<UnauthenticatedTemplate>
<NeedToSignin />
Expand Down
2 changes: 1 addition & 1 deletion src/app/(authed)/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { redirect } from 'next/navigation';
import useSWR from 'swr';
import DataTable from '@/components/Dashboard';
import DashboardMenu from '@/components/DashboardMenu';
import type { BatchAnswer } from '@/_schemas/formSchema';
import DashboardMenu from './_components/DashboardMenu';

const Home = () => {
const fetcher = (url: string) => fetch(url).then((res) => res.json());
Expand Down

0 comments on commit cf126ec

Please sign in to comment.