From 34ef9371c2756b0d277ec0df14c934df95bf73dd Mon Sep 17 00:00:00 2001 From: Katsukiniwa Date: Wed, 28 Feb 2024 16:05:15 +0900 Subject: [PATCH] chore: update --- admin/src/app/layout.tsx | 6 +- admin/src/app/loading.tsx | 26 ++++ admin/src/app/page.tsx | 11 +- admin/src/components/QuestionCard.tsx | 2 +- admin/src/components/Sidebar.tsx | 144 ++++++++++++++++++ admin/src/lib/data.ts | 3 +- .../components/layouts/NavigationHeader.tsx | 3 + 7 files changed, 188 insertions(+), 7 deletions(-) create mode 100644 admin/src/app/loading.tsx create mode 100644 admin/src/components/Sidebar.tsx diff --git a/admin/src/app/layout.tsx b/admin/src/app/layout.tsx index 6c2bad2..e980901 100644 --- a/admin/src/app/layout.tsx +++ b/admin/src/app/layout.tsx @@ -2,6 +2,7 @@ import type { Metadata } from "next"; import { Inter } from "next/font/google"; import "./globals.css"; import { NavigationHeader } from "@/components/NavigationHeader"; +import { Sidebar } from "@/components/Sidebar"; const inter = Inter({ subsets: ["latin"] }); @@ -19,7 +20,10 @@ export default function RootLayout({ - {children} +
+ + {children} +
); diff --git a/admin/src/app/loading.tsx b/admin/src/app/loading.tsx new file mode 100644 index 0000000..fdeb56b --- /dev/null +++ b/admin/src/app/loading.tsx @@ -0,0 +1,26 @@ +/** + * @link https://flowbite.com/docs/components/spinner + */ +export default function Loading() { + return ( +
+ + Loading top page... +
+ ); +} diff --git a/admin/src/app/page.tsx b/admin/src/app/page.tsx index e25a24f..5c2ed5a 100644 --- a/admin/src/app/page.tsx +++ b/admin/src/app/page.tsx @@ -2,13 +2,15 @@ import { CategoryLabel } from "@/components/CategoryLabel"; import { QuestionCard } from "@/components/QuestionCard"; import { getCategories, getQuestions } from "@/lib/data"; +export const dynamic = "force-dynamic"; + export default async function Home() { const categories = await getCategories(); const questions = await getQuestions(); return ( -
-
+
+

カテゴリから探す

@@ -18,7 +20,8 @@ export default async function Home() { ))}
-
+ +

人気の質問から探す

@@ -33,7 +36,7 @@ export default async function Home() { ))}
-
+

最新の質問から探す

diff --git a/admin/src/components/QuestionCard.tsx b/admin/src/components/QuestionCard.tsx index 28237a6..c7474a8 100644 --- a/admin/src/components/QuestionCard.tsx +++ b/admin/src/components/QuestionCard.tsx @@ -18,7 +18,7 @@ export const QuestionCard = ({ id, title, content }: Props) => {

{content}

Read more diff --git a/admin/src/components/Sidebar.tsx b/admin/src/components/Sidebar.tsx new file mode 100644 index 0000000..9b06616 --- /dev/null +++ b/admin/src/components/Sidebar.tsx @@ -0,0 +1,144 @@ +export const Sidebar = () => { + return ( +
+
+
+ Menu +
+
+ +
+ ); +}; diff --git a/admin/src/lib/data.ts b/admin/src/lib/data.ts index 247afcb..6252bf2 100644 --- a/admin/src/lib/data.ts +++ b/admin/src/lib/data.ts @@ -1,4 +1,5 @@ export const getCategories = async () => { + await new Promise((resolve) => setTimeout(resolve, 3000)) const res = await fetch('http://localhost:3000/categories', { method: "GET", headers: { @@ -38,7 +39,7 @@ export const getQuestions = async () => { } }).then(res => res.json()) - return res as { + return res.filter((_: any, index: number) => index < 6) as { id: number, title: string, content: string diff --git a/frontend/src/components/layouts/NavigationHeader.tsx b/frontend/src/components/layouts/NavigationHeader.tsx index c0ed218..4449229 100644 --- a/frontend/src/components/layouts/NavigationHeader.tsx +++ b/frontend/src/components/layouts/NavigationHeader.tsx @@ -43,6 +43,9 @@ export const NavigationHeader = () => {