diff --git a/src/components/LoadingScreen.tsx b/src/components/LoadingScreen.tsx index 86a30a3..7c44cd9 100644 --- a/src/components/LoadingScreen.tsx +++ b/src/components/LoadingScreen.tsx @@ -1,5 +1,16 @@ import { Box } from "@mui/material"; +import useBackDrop from "hooks/useBackDrop"; +import { useEffect } from "react"; export default function LoadingScreen() { + const { setShowBackDrop } = useBackDrop(); + + useEffect(() => { + setShowBackDrop(true); + return () => { + setShowBackDrop(false); + }; + }, []); + return Loading...; } diff --git a/src/hooks/useNavigateCustom.ts b/src/hooks/useNavigateCustom.ts index 6f39fc3..6e684c8 100644 --- a/src/hooks/useNavigateCustom.ts +++ b/src/hooks/useNavigateCustom.ts @@ -2,6 +2,7 @@ import { useLocation, useNavigate } from "react-router"; import { Dictionary } from "@types"; import { PageID } from "pages"; import { getPath } from "routes/path"; +import { scrollToTop } from "utils/page"; export default function useNavigateCustom() { const navigate = useNavigate(); @@ -54,6 +55,8 @@ export default function useNavigateCustom() { navigate(newPath); } } + + scrollToTop("auto"); }; return { navigate, navigateWhenChanged }; } diff --git a/src/layouts/dashbord/navigator.tsx b/src/layouts/dashbord/navigator.tsx index b9cca77..a1afe79 100644 --- a/src/layouts/dashbord/navigator.tsx +++ b/src/layouts/dashbord/navigator.tsx @@ -69,10 +69,22 @@ export default function Navigator(props: DrawerProps) { const { userId, name } = useAuth(); + const { navigateWhenChanged } = useNavigateCustom(); + + const navigateToDashboardOverview = () => { + navigateWhenChanged(getPath(PageID.DASHBOARD_OVERVIEW)); + }; + const categories: Group[] = [ { - label: "管理", - children: [], + label: "App", + children: [ + { + label: "契約", + icon: , + id: PageID.DASHBOARD_CONTRACT_LIST, + }, + ], }, { label: "アカウント", @@ -86,6 +98,7 @@ export default function Navigator(props: DrawerProps) { MyPage diff --git a/src/pages/dashboard/contract/detail.tsx b/src/pages/dashboard/contract/detail.tsx new file mode 100644 index 0000000..505c488 --- /dev/null +++ b/src/pages/dashboard/contract/detail.tsx @@ -0,0 +1,94 @@ +import { + Box, + Button, + Grid, + Paper, + Stack, + Table, + TableBody, + TableCell, + TableRow, + Typography, +} from "@mui/material"; +import { PageID, TabID } from "pages"; +import useDashboard from "hooks/useDashBoard"; +import { useEffect } from "react"; +import useNavigateCustom from "hooks/useNavigateCustom"; + +export default function ContractDetail() { + const { setHeaderTitle, setTabs } = useDashboard( + PageID.DASHBOARD_CONTRACT_DETAIL, + TabID.NONE + ); + const { navigate } = useNavigateCustom(); + + useEffect(() => { + setHeaderTitle("契約詳細"); + setTabs(null); + }, []); + return ( + + + + + + + 契約情報 + + + + 駐車場名 + A駐車場 + + + 区画 + 1-1 + + + 契約期間 + 2023/8/1-2024/7/31 + + +
+
+ + お支払い状況 + + + + 2023/09 + 未請求 + + + 2023/08 + 支払済み + + + 2023/07 + 支払済み + + + +
+
+ + 各種申請 + + + + + + + + + +
+
+ ); +} diff --git a/src/pages/dashboard/contract/list.tsx b/src/pages/dashboard/contract/list.tsx new file mode 100644 index 0000000..75f665d --- /dev/null +++ b/src/pages/dashboard/contract/list.tsx @@ -0,0 +1,51 @@ +import { Box, Button, Grid, Paper, Typography } from "@mui/material"; +import { PageID, TabID } from "pages"; +import useDashboard from "hooks/useDashBoard"; +import { useEffect } from "react"; +import useNavigateCustom from "hooks/useNavigateCustom"; +import { getPath } from "routes/path"; + +export default function ContractList() { + const { setHeaderTitle, setTabs } = useDashboard( + PageID.DASHBOARD_CONTRACT_LIST, + TabID.NONE + ); + + const { navigateWhenChanged } = useNavigateCustom(); + + const items = [ + { parkingName: "A駐車場", position: "1" }, + { parkingName: "B駐車場", position: "1-1" }, + ]; + + const moveToDetail = () => { + navigateWhenChanged( + getPath(PageID.DASHBOARD_CONTRACT_DETAIL, { + query: { + id: "test-test", + }, + }) + ); + }; + + useEffect(() => { + setHeaderTitle("契約一覧"); + setTabs(null); + }, []); + return ( + + + {items.map((item) => { + return ( + + + {item.parkingName} + 区画:{item.position} + + + ); + })} + + + ); +} diff --git a/src/pages/index.ts b/src/pages/index.ts index b2d1344..dddb00c 100644 --- a/src/pages/index.ts +++ b/src/pages/index.ts @@ -7,6 +7,9 @@ export const PageID = { DASHBOARD_OVERVIEW: id++, + DASHBOARD_CONTRACT_LIST: id++, + DASHBOARD_CONTRACT_DETAIL: id++, + PAGE_403: id++, PAGE_404: id++, } as const; diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 10866db..b154861 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -41,6 +41,14 @@ const DashboardRoutes = (): RouteObject => { path: getRoute(PageID.DASHBOARD_OVERVIEW), element: , }, + { + path: getRoute(PageID.DASHBOARD_CONTRACT_LIST), + element: , + }, + { + path: getRoute(PageID.DASHBOARD_CONTRACT_DETAIL), + element: , + }, ]; return { @@ -73,6 +81,12 @@ const Logout = Loadable(lazy(() => import("pages/auth/logout"))); //ダッシュボード ---------------------------- const Dashboard = Loadable(lazy(() => import("pages/dashboard"))); +const ContractList = Loadable( + lazy(() => import("pages/dashboard/contract/list")) +); +const ContractDetail = Loadable( + lazy(() => import("pages/dashboard/contract/detail")) +); // その他 --------------------------------- diff --git a/src/routes/path.ts b/src/routes/path.ts index 2af49e1..d39fbbc 100644 --- a/src/routes/path.ts +++ b/src/routes/path.ts @@ -28,6 +28,15 @@ const getTabId = (key: PathKey): TabID => { } }; +const PATHS_DASHBOARD = { + [makePathKey(PageID.DASHBOARD_OVERVIEW)]: "/dashboard", + // --契約----------------------- + [makePathKey(PageID.DASHBOARD_CONTRACT_LIST)]: + "/dashboard/contract/list/:page", + [makePathKey(PageID.DASHBOARD_CONTRACT_DETAIL)]: + "/dashboard/contract/detail/:id", +}; + const PATHS = { [makePathKey(PageID.NONE)]: "/", @@ -35,7 +44,8 @@ const PATHS = { [makePathKey(PageID.LOGIN)]: "/login", [makePathKey(PageID.LOGOUT)]: "/logout", - [makePathKey(PageID.DASHBOARD_OVERVIEW)]: "/dashboard", + // ダッシュボード---------------- + ...PATHS_DASHBOARD, // その他 [makePathKey(PageID.PAGE_403)]: "403", diff --git a/src/utils/page.ts b/src/utils/page.ts index f9c9976..4185357 100644 --- a/src/utils/page.ts +++ b/src/utils/page.ts @@ -1,3 +1,5 @@ -export const scrollToTop = () => { - window.scroll({ top: 0, behavior: "smooth" }); +export const scrollToTop = ( + behavior: ScrollBehavior | undefined = "smooth" +) => { + window.scroll({ top: 0, behavior }); };