From 3d4e82bc45f6021362e18c8390548c4b699cc012 Mon Sep 17 00:00:00 2001 From: Xevion Date: Tue, 5 Sep 2023 14:46:04 -0500 Subject: [PATCH] Use common Layout component, place common title in Layout --- src/components/Layout.tsx | 22 ++++++++++++++-------- src/pages/_document.tsx | 4 +--- src/pages/index.tsx | 5 +++-- src/pages/login.tsx | 6 ++++-- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index 944ec45..7e010e7 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -1,5 +1,6 @@ import { FunctionComponent } from 'react'; import { classNames } from '@/utils/client'; +import Head from 'next/head'; export type LayoutProps = { className?: string; @@ -8,14 +9,19 @@ export type LayoutProps = { const Layout: FunctionComponent = ({ children, className }) => { return ( -
- {children} -
+ <> + + bus-reminder + +
+ {children} +
+ ); }; diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index e3e7f6b..da2bc05 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -3,9 +3,7 @@ import { Html, Head, Main, NextScript } from 'next/document'; export default function Document() { return ( - - bus-reminder - +
diff --git a/src/pages/index.tsx b/src/pages/index.tsx index f7dd18a..ea31b31 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -13,6 +13,7 @@ import { fetchConfiguration } from '@/db'; import { useForm } from 'react-hook-form'; import { ConfigurationSchema } from '@/timing'; import { useRouter } from 'next/router'; +import Layout from '@/components/Layout'; type Props = { config: string; @@ -101,7 +102,7 @@ const IndexPage: NextPage = ({ config }) => { } return ( -
+
@@ -151,7 +152,7 @@ const IndexPage: NextPage = ({ config }) => {
-
+ ); }; diff --git a/src/pages/login.tsx b/src/pages/login.tsx index a9e56ae..1e5174b 100644 --- a/src/pages/login.tsx +++ b/src/pages/login.tsx @@ -2,6 +2,7 @@ import { NextPage } from 'next'; import { useForm } from 'react-hook-form'; import { useState } from 'react'; import { useRouter } from 'next/router'; +import Layout from '@/components/Layout'; const LoginPage: NextPage = () => { type FormProps = { token: string }; @@ -11,6 +12,7 @@ const LoginPage: NextPage = () => { async function onSubmit(data: FormProps) { const response = await fetch(`/api/check?key=${data.token}`); + if (response.status === 200) { setError(false); router.push({ pathname: '/', query: { key: data.token } }).then(); @@ -18,7 +20,7 @@ const LoginPage: NextPage = () => { } return ( -
+
@@ -52,7 +54,7 @@ const LoginPage: NextPage = () => {
-
+ ); };