From 866ea126ccbee43a6d379cd84740f07bd95db05d Mon Sep 17 00:00:00 2001 From: taeho Date: Mon, 6 Nov 2023 10:51:38 +0900 Subject: [PATCH] Add notices page --- .../20231106003732_add_notices/migration.sql | 15 +++ prisma/schema.prisma | 13 ++- src/components/header.tsx | 7 +- src/pages/notices.tsx | 110 ++++++++++++++++++ 4 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 prisma/migrations/20231106003732_add_notices/migration.sql create mode 100644 src/pages/notices.tsx diff --git a/prisma/migrations/20231106003732_add_notices/migration.sql b/prisma/migrations/20231106003732_add_notices/migration.sql new file mode 100644 index 00000000..4fbd10dc --- /dev/null +++ b/prisma/migrations/20231106003732_add_notices/migration.sql @@ -0,0 +1,15 @@ +-- AlterTable +ALTER TABLE `fonts` MODIFY `show_type` BOOLEAN NOT NULL DEFAULT false; + +-- CreateTable +CREATE TABLE `fontsNotice` ( + `notice_id` INTEGER NOT NULL AUTO_INCREMENT, + `notice_type` VARCHAR(191) NOT NULL, + `notice_title` VARCHAR(191) NOT NULL, + `notice_content` TEXT NOT NULL, + `notice_created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + `notice_updated_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + + INDEX `fontsNotice_notice_id_idx`(`notice_id`), + PRIMARY KEY (`notice_id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 40c25f7f..227e3495 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -39,7 +39,7 @@ model fonts { license String @db.Text created_at DateTime @default(now()) updated_at DateTime @default(now()) @updatedAt - show_type Boolean @default(true) + show_type Boolean @default(false) liked_user fontsLiked[] comments fontsComment[] @@ -160,4 +160,15 @@ model fontsBugReport { issue_created_at DateTime @default(now()) @@index([issue_id]) +} + +model fontsNotice { + notice_id Int @id @default(autoincrement()) + notice_type String + notice_title String + notice_content String @db.Text + notice_created_at DateTime @default(now()) + notice_updated_at DateTime @default(now()) @updatedAt + + @@index([notice_id]) } \ No newline at end of file diff --git a/src/components/header.tsx b/src/components/header.tsx index b3f3f7a8..c6fae6ff 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -584,8 +584,13 @@ export default function Header ( 깃허브 {/* eslint-disable-next-line @next/next/no-html-link-for-pages */} + + + 공지사항 + + {/* eslint-disable-next-line @next/next/no-html-link-for-pages */} - + 폰트 제보하기 {/* eslint-disable-next-line @next/next/no-html-link-for-pages */} diff --git a/src/pages/notices.tsx b/src/pages/notices.tsx new file mode 100644 index 00000000..6c207ac9 --- /dev/null +++ b/src/pages/notices.tsx @@ -0,0 +1,110 @@ +// next hooks +import { NextSeo } from 'next-seo'; + +// api +import { CheckIfSessionExists } from './api/user/checkifsessionexists'; +import { FetchUserInfo } from './api/user/fetchuserinfo'; + +// components +import Header from "@/components/header"; +import Tooltip from '@/components/tooltip'; + +const Notices = ({params}: any) => { + // 디바이스 체크 + const isMac: boolean = params.userAgent.includes("Mac OS") ? true : false; + + // 빈 함수 + const emptyFn = () => { return; } + + return ( + <> + {/* Head 부분*/} + + + {/* 헤더 */} +
+ + {/* 고정 메뉴 */} + + + {/* 메인 */} +
+
+
+

공지사항

+

폰트 업데이트 & 소식

+
+
+ + +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + ); +} + +export async function getServerSideProps(ctx: any) { + try { + // 필터링 쿠키 체크 + const cookieTheme = ctx.req.cookies.theme === undefined ? "dark" : ctx.req.cookies.theme; + + // 디바이스 체크 + const userAgent = ctx.req ? ctx.req.headers['user-agent'] : navigator.userAgent; + + // 쿠키에 저장된 세션ID가 유효하면, 유저 정보 가져오기 + const user = ctx.req.cookies.session === undefined ? null : ( + await CheckIfSessionExists(ctx.req.cookies.session) === true + ? await FetchUserInfo(ctx.req.cookies.session) + : null + ) + + return { + props: { + params: { + theme: cookieTheme, + userAgent: userAgent, + user: JSON.parse(JSON.stringify(user)), + } + } + } + } + catch (error) { + console.log(error); + } +} + +export default Notices; \ No newline at end of file