Skip to content

Commit

Permalink
Add notices page
Browse files Browse the repository at this point in the history
  • Loading branch information
taedonn committed Nov 6, 2023
1 parent adc3dbb commit 866ea12
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 2 deletions.
15 changes: 15 additions & 0 deletions prisma/migrations/20231106003732_add_notices/migration.sql
Original file line number Diff line number Diff line change
@@ -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;
13 changes: 12 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down Expand Up @@ -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])
}
7 changes: 6 additions & 1 deletion src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,13 @@ export default function Header (
<span className="text-[13px] ml-[6px] text-theme-10/80 group-hover:text-theme-10 tlg:group-hover:text-theme-10/80 dark:text-theme-9/80 group-hover:dark:text-theme-9 tlg:group-hover:dark:text-theme-9/80">깃허브</span>
</Link>
{/* eslint-disable-next-line @next/next/no-html-link-for-pages */}
<a href="/notices" className="group flex flex-row justify-start items-center mt-[5px]">
<svg className="w-[12px] ml-px fill-theme-10/80 group-hover:fill-theme-10 dark:fill-theme-9/80 group-hover:dark:fill-theme-9" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M48 24C48 10.7 37.3 0 24 0S0 10.7 0 24V64 350.5 400v88c0 13.3 10.7 24 24 24s24-10.7 24-24V388l80.3-20.1c41.1-10.3 84.6-5.5 122.5 13.4c44.2 22.1 95.5 24.8 141.7 7.4l34.7-13c12.5-4.7 20.8-16.6 20.8-30V66.1c0-23-24.2-38-44.8-27.7l-9.6 4.8c-46.3 23.2-100.8 23.2-147.1 0c-35.1-17.6-75.4-22-113.5-12.5L48 52V24zm0 77.5l96.6-24.2c27-6.7 55.5-3.6 80.4 8.8c54.9 27.4 118.7 29.7 175 6.8V334.7l-24.4 9.1c-33.7 12.6-71.2 10.7-103.4-5.4c-48.2-24.1-103.3-30.1-155.6-17.1L48 338.5v-237z"/></svg>
<span className="text-[13px] ml-[7px] text-theme-10/80 group-hover:text-theme-10 tlg:group-hover:text-theme-10/80 dark:text-theme-9/80 group-hover:dark:text-theme-9 tlg:group-hover:dark:text-theme-9/80">공지사항</span>
</a>
{/* eslint-disable-next-line @next/next/no-html-link-for-pages */}
<a href="/issue/font" className="group flex flex-row justify-start items-center mt-[5px]">
<svg className="w-[12px] ml-px mb-px fill-theme-yellow" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M480 32c0-12.9-7.8-24.6-19.8-29.6s-25.7-2.2-34.9 6.9L381.7 53c-48 48-113.1 75-181 75H192 160 64c-35.3 0-64 28.7-64 64v96c0 35.3 28.7 64 64 64l0 128c0 17.7 14.3 32 32 32h64c17.7 0 32-14.3 32-32V352l8.7 0c67.9 0 133 27 181 75l43.6 43.6c9.2 9.2 22.9 11.9 34.9 6.9s19.8-16.6 19.8-29.6V300.4c18.6-8.8 32-32.5 32-60.4s-13.4-51.6-32-60.4V32zm-64 76.7V240 371.3C357.2 317.8 280.5 288 200.7 288H192V192h8.7c79.8 0 156.5-29.8 215.3-83.3z"/></svg>
<svg className="w-[13px] ml-px mb-px fill-theme-yellow" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M480 32c0-12.9-7.8-24.6-19.8-29.6s-25.7-2.2-34.9 6.9L381.7 53c-48 48-113.1 75-181 75H192 160 64c-35.3 0-64 28.7-64 64v96c0 35.3 28.7 64 64 64l0 128c0 17.7 14.3 32 32 32h64c17.7 0 32-14.3 32-32V352l8.7 0c67.9 0 133 27 181 75l43.6 43.6c9.2 9.2 22.9 11.9 34.9 6.9s19.8-16.6 19.8-29.6V300.4c18.6-8.8 32-32.5 32-60.4s-13.4-51.6-32-60.4V32zm-64 76.7V240 371.3C357.2 317.8 280.5 288 200.7 288H192V192h8.7c79.8 0 156.5-29.8 215.3-83.3z"/></svg>
<span className="text-[13px] ml-[7px] text-theme-10/80 group-hover:text-theme-10 tlg:group-hover:text-theme-10/80 dark:text-theme-9/80 group-hover:dark:text-theme-9 tlg:group-hover:dark:text-theme-9/80">폰트 제보하기</span>
</a>
{/* eslint-disable-next-line @next/next/no-html-link-for-pages */}
Expand Down
110 changes: 110 additions & 0 deletions src/pages/notices.tsx
Original file line number Diff line number Diff line change
@@ -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 부분*/}
<NextSeo
title={"공지사항 · 폰트 아카이브"}
description={"공지사항 - 상업용 무료 한글 폰트 저장소"}
/>

{/* 헤더 */}
<Header
isMac={isMac}
theme={params.theme}
user={params.user}
page={""}
license={""}
lang={""}
type={""}
sort={""}
source={""}
handleTextChange={emptyFn}
handleLicenseOptionChange={emptyFn}
handleLangOptionChange={emptyFn}
handleTypeOptionChange={emptyFn}
handleSortOptionChange={emptyFn}
handleSearch={emptyFn}
/>

{/* 고정 메뉴 */}
<Tooltip/>

{/* 메인 */}
<div className='w-[100%] flex flex-col justify-center items-center py-[60px]'>
<div className='w-[720px] tmd:w-[100%] flex flex-col justify-center items-start'>
<div className='flex items-center mb-[16px]'>
<h2 className='text-[24px] text-theme-3 dark:text-theme-9 font-medium'>공지사항</h2>
<h3 className='text-[16px] ml-[16px] text-theme-5 dark:text-theme-7'>폰트 업데이트 & 소식</h3>
</div>
<div className='relative mb-[32px]'>
<svg className='w-[14px] absolute left-[18px] top-[50%] translate-y-[-50%] fill-theme-5 dark:fill-theme-7' xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"/></svg>
<input type="text" id="search" placeholder="검색어 입력" className="w-[300px] h-[40px] text-[14px] pl-[40px] pr-[20px] border rounded-full border-theme-7 dark:border-theme-5 text-theme-5 dark:text-theme-7 placeholder:text-theme-5 dark:placeholder:text-theme-7 bg-transparent"/>
</div>
<div className='flex items-center gap-[8px] mb-[32px]'>
<div>
<input type="radio" id="all" name="type" className="hidden peer" defaultChecked/>
<label htmlFor='all' className='w-[80px] h-[34px] text-[14px] pt-px flex justify-center items-center cursor-pointer border rounded-full border-theme-3 dark:border-theme-9 peer-checked:border-theme-yellow peer-checked:dark:border-theme-blue-1 text-theme-3 dark:text-theme-9 peer-checked:text-theme-3 peer-checked:dark:text-theme-blue-2 peer-checked:bg-theme-yellow peer-checked:dark:bg-theme-blue-1'>전체</label>
</div>
<div>
<input type="radio" id="service" name="type" className="hidden peer"/>
<label htmlFor='service' className='w-[80px] h-[34px] text-[14px] pt-px flex justify-center items-center cursor-pointer border rounded-full border-theme-3 dark:border-theme-9 peer-checked:border-theme-yellow peer-checked:dark:border-theme-blue-1 text-theme-3 dark:text-theme-9 peer-checked:text-theme-3 peer-checked:dark:text-theme-blue-2 peer-checked:bg-theme-yellow peer-checked:dark:bg-theme-blue-1'>서비스</label>
</div>
<div>
<input type="radio" id="font" name="type" className="hidden peer"/>
<label htmlFor='font' className='w-[80px] h-[34px] text-[14px] pt-px flex justify-center items-center cursor-pointer border rounded-full border-theme-3 dark:border-theme-9 peer-checked:border-theme-yellow peer-checked:dark:border-theme-blue-1 text-theme-3 dark:text-theme-9 peer-checked:text-theme-3 peer-checked:dark:text-theme-blue-2 peer-checked:bg-theme-yellow peer-checked:dark:bg-theme-blue-1'>폰트</label>
</div>
</div>
</div>
</div>
</>
);
}

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;

0 comments on commit 866ea12

Please sign in to comment.