Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit b9446ea

Browse files
authored
✨ 활동 보고 뷰어 구현 (#314)
1 parent d05025d commit b9446ea

File tree

5 files changed

+93
-20
lines changed

5 files changed

+93
-20
lines changed

apis/types/council.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export interface CouncilReport {
2+
id: number;
3+
title: string;
4+
description: string;
5+
sequence: number;
6+
name: string;
7+
createdAt: string;
8+
prevId: number;
9+
prevTitle: string;
10+
nextId: number;
11+
nextTitle: string;
12+
}

apis/v2/council/report/[id].ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
import { deleteRequest, getRequest, putRequest } from '@/apis';
2+
import { CouncilReport } from '@/apis/types/council';
23
import { FETCH_TAG_COUNCIL_REPORT } from '@/constants/network';
34

4-
interface GETReportByIDResponse {
5-
id: number;
6-
title: string;
7-
description: string;
8-
sequence: number;
9-
name: string;
10-
createdAt: string;
11-
prevId: number;
12-
prevTitle: string;
13-
nextId: number;
14-
nextTitle: string;
15-
}
16-
175
export const getCouncilReport = (id: number) =>
18-
getRequest<GETReportByIDResponse>(`/v2/council/report/${id}`, undefined, {
6+
getRequest<CouncilReport>(`/v2/council/report/${id}`, undefined, {
197
next: { tags: [FETCH_TAG_COUNCIL_REPORT] },
208
});
219

2210
export const putCouncilReport = (id: number, formData: FormData) =>
23-
putRequest<GETReportByIDResponse>(`/v2/council/report/${id}`, {
11+
putRequest<CouncilReport>(`/v2/council/report/${id}`, {
2412
body: formData,
2513
jsessionID: true,
2614
});

app/[locale]/community/components/PostFooter.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useTranslations } from 'next-intl';
22

3+
import { CouncilReport } from '@/apis/types/council';
34
import { News } from '@/apis/types/news';
45
import { Notice } from '@/apis/types/notice';
56
import { Seminar } from '@/apis/types/seminar';
@@ -11,7 +12,7 @@ import PostDeleteButton from './PostDeleteButton';
1112

1213
type PostFooterProps = {
1314
postType: PostType;
14-
post: Notice | News | Seminar;
15+
post: Notice | News | Seminar | CouncilReport;
1516
id?: string;
1617
margin?: string;
1718
};
@@ -21,7 +22,7 @@ type AdjPost = {
2122
title: string;
2223
};
2324

24-
type PostType = 'notice' | 'seminar' | 'news';
25+
type PostType = 'notice' | 'seminar' | 'news' | 'council/report';
2526
type RowType = 'next' | 'prev';
2627

2728
export default function PostFooter({ post, margin = '', postType, id }: PostFooterProps) {
Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,77 @@
1+
import 'dayjs/locale/ko';
2+
3+
import dayjs from 'dayjs';
4+
import { getTranslations } from 'next-intl/server';
5+
6+
import { CouncilReport } from '@/apis/types/council';
7+
import PostFooter from '@/app/[locale]/community/components/PostFooter';
8+
import { StraightNode } from '@/components/common/Nodes';
9+
import HTMLViewer from '@/components/form/html/HTMLViewer';
10+
import { PAGE_PADDING_BOTTOM_TAILWIND } from '@/components/layout/pageLayout/paddings';
111
import PageLayout from '@/components/layout/pageLayout/PageLayout';
12+
import { councilReportList } from '@/constants/segmentNode';
13+
import { getMetadata } from '@/utils/metadata';
14+
15+
const council: CouncilReport = {
16+
id: 2,
17+
title: 'title',
18+
description: 'description',
19+
sequence: 1,
20+
name: 'name',
21+
createdAt: '2022-01-01T00:00:00.000Z',
22+
prevId: 1,
23+
prevTitle: 'prevTitle',
24+
nextId: 3,
25+
nextTitle: 'nextTitle',
26+
};
27+
28+
interface Props {
29+
params: Promise<{ id: number; locale: string }>;
30+
}
31+
32+
export async function generateMetadata({ params }: Props) {
33+
const { locale } = await params;
34+
// const { title } = await getCouncilReport(id);
35+
const { title } = council;
36+
37+
return await getMetadata({
38+
locale,
39+
node: councilReportList,
40+
metadata: { title },
41+
});
42+
}
43+
44+
export default async function CouncilReportPage({ params }: Props) {
45+
const { id, locale } = await params;
46+
const t = await getTranslations({ locale });
47+
48+
// const council = await getCouncilReport(id);
49+
50+
const { title, description, sequence, name, createdAt } = council;
51+
const author = `제${sequence}대 학생회 ${name}`;
52+
const dateStr = dayjs(createdAt).locale('ko').format('YYYY/MM/DD (ddd) A h:mm');
53+
54+
return (
55+
<PageLayout titleType="big" removePadding>
56+
<div className="flex flex-col gap-4 px-5 py-9 sm:pl-[100px] sm:pr-[340px]">
57+
<h2 className="text-[1.25rem] font-semibold leading-[1.4]">{title}</h2>
58+
<div className="flex gap-5 text-sm font-normal tracking-wide text-neutral-500">
59+
<p>
60+
{t('작성자')}: {author}
61+
</p>
62+
<p>
63+
{t('작성 날짜')}: {dateStr}
64+
</p>
65+
</div>
66+
</div>
267

3-
export default function CouncilReport({ params: { id } }: { params: { id: number } }) {
4-
return <PageLayout titleType="big">CouncilReport {id}</PageLayout>;
68+
<div
69+
className={`bg-neutral-50 px-5 pt-9 sm:pl-[100px] sm:pr-[340px] ${PAGE_PADDING_BOTTOM_TAILWIND}`}
70+
>
71+
<HTMLViewer htmlContent={description} wrapperClassName="mb-10" />
72+
<StraightNode />
73+
<PostFooter post={council} postType="council/report" id={id.toString()} margin="mt-12" />
74+
</div>
75+
</PageLayout>
76+
);
577
}

lint-staged.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
22
'src/**/*.{js,ts,jsx,tsx}': ['eslint --fix', 'prettier --write'],
33
'!(src/**/*.{js,ts,jsx,tsx})': 'prettier --ignore-unknown --write',
4-
'**/*.ts?(x)': () => 'tsc --noEmit',
4+
'**/*.ts?(x)': () => 'tsc -p tsconfig.json --noEmit',
55
};

0 commit comments

Comments
 (0)