Skip to content

Commit

Permalink
πŸ› μ†Œμ‹νƒ­ κ²€μˆ˜ (#300)
Browse files Browse the repository at this point in the history
  • Loading branch information
yeolyi authored Feb 5, 2025
1 parent 0aff5ba commit f299c3e
Show file tree
Hide file tree
Showing 30 changed files with 90 additions and 57 deletions.
4 changes: 2 additions & 2 deletions actions/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { revalidateTag } from 'next/cache';

import { postNews } from '@/apis/v1/news';
import { deleteNews, patchNews } from '@/apis/v1/news/[id]';
import { postNews } from '@/apis/v2/news';
import { deleteNews, patchNews } from '@/apis/v2/news/[id]';
import { FETCH_TAG_NEWS } from '@/constants/network';
import { news } from '@/constants/segmentNode';
import { redirectKo } from '@/i18n/routing';
Expand Down
4 changes: 2 additions & 2 deletions actions/notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { revalidateTag } from 'next/cache';

import { batchDeleteNotice, batchUnpinNotice, postNotice } from '@/apis/v1/notice';
import { deleteNotice, patchNotice } from '@/apis/v1/notice/[id]';
import { batchDeleteNotice, batchUnpinNotice, postNotice } from '@/apis/v2/notice';
import { deleteNotice, patchNotice } from '@/apis/v2/notice/[id]';
import { FETCH_TAG_NOTICE } from '@/constants/network';
import { notice } from '@/constants/segmentNode';
import { redirectKo } from '@/i18n/routing';
Expand Down
4 changes: 2 additions & 2 deletions actions/seminar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { revalidateTag } from 'next/cache';

import { postSeminar } from '@/apis/v1/seminar';
import { deleteSeminar, patchSeminar } from '@/apis/v1/seminar/[id]';
import { postSeminar } from '@/apis/v2/seminar';
import { deleteSeminar, patchSeminar } from '@/apis/v2/seminar/[id]';
import { FETCH_TAG_SEMINAR } from '@/constants/network';
import { seminar } from '@/constants/segmentNode';
import { redirectKo } from '@/i18n/routing';
Expand Down
7 changes: 5 additions & 2 deletions apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ const _fetch = async (url: string, method: string, init?: CredentialRequestInit)

const resp = await fetch(url, { ...init, method, headers });

// server action μ—λŸ¬ 처리λ₯Ό μœ„ν•΄ status code만 κΉ”λ”ν•˜κ²Œ λ‹΄μŒ
if (!resp.ok) throw new Error(resp.status.toString());
if (!resp.ok) {
console.error(`${method} ${url} failed: ${resp.status}`);
// server action μ—λŸ¬ 처리λ₯Ό μœ„ν•΄ status code만 κΉ”λ”ν•˜κ²Œ λ‹΄μŒ
throw new Error(resp.status.toString());
}

return resp;
};
5 changes: 2 additions & 3 deletions apis/v1/index.ts β†’ apis/v2/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { getRequest } from '@/apis';
import { MainResponse } from '@/apis/types/main';
import { FETCH_TAG_NEWS, FETCH_TAG_NOTICE } from '@/constants/network';

import { getRequest } from '..';

export const getMain = () =>
getRequest<MainResponse>('/v1', undefined, {
getRequest<MainResponse>('/v2', undefined, {
next: { tags: [FETCH_TAG_NEWS, FETCH_TAG_NOTICE] },
});
6 changes: 3 additions & 3 deletions apis/v1/news/[id].ts β†’ apis/v2/news/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { PostSearchQueryParams } from '@/apis/types/post';
import { FETCH_TAG_NEWS } from '@/constants/network';

export const getNewsDetail = (id: number, params?: PostSearchQueryParams) =>
getRequest(`/v1/news/${id}`, params, {
getRequest(`/v2/news/${id}`, params, {
next: { tags: [FETCH_TAG_NEWS] },
jsessionID: true,
}) as Promise<News>;

export const deleteNews = (id: number) => deleteRequest(`/v1/news/${id}`, { jsessionID: true });
export const deleteNews = (id: number) => deleteRequest(`/v2/news/${id}`, { jsessionID: true });

export const patchNews = async (id: number, formData: FormData) => {
await patchRequest(`/v1/news/${id}`, { body: formData, jsessionID: true });
await patchRequest(`/v2/news/${id}`, { body: formData, jsessionID: true });
};
4 changes: 2 additions & 2 deletions apis/v1/news/index.ts β†’ apis/v2/news/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { PostSearchQueryParams } from '@/apis/types/post';
import { FETCH_TAG_NEWS } from '@/constants/network';

export const getNewsPosts = (params: PostSearchQueryParams) =>
getRequest('/v1/news', params, {
getRequest('/v2/news', params, {
next: { tags: [FETCH_TAG_NEWS] },
jsessionID: true,
}) as Promise<NewsPreviewList>;

export const postNews = async (formData: FormData) => {
return postRequest('/v1/news', { body: formData, jsessionID: true }) as Promise<{ id: number }>;
return postRequest('/v2/news', { body: formData, jsessionID: true }) as Promise<{ id: number }>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { NewsSearchResult, SearchParam } from '@/apis/types/search';
import { FETCH_TAG_NEWS } from '@/constants/network';

export const searchNews = (params: SearchParam) =>
getRequest('/v1/news/totalSearch', params, {
getRequest('/v2/news/totalSearch', params, {
next: { tags: [FETCH_TAG_NEWS] },
}) as Promise<NewsSearchResult>;
6 changes: 3 additions & 3 deletions apis/v1/notice/[id].ts β†’ apis/v2/notice/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { PostSearchQueryParams } from '@/apis/types/post';
import { FETCH_TAG_NOTICE } from '@/constants/network';

export const getNoticePostDetail = (id: number, params: PostSearchQueryParams) =>
getRequest(`/v1/notice/${id}`, params, {
getRequest(`/v2/notice/${id}`, params, {
next: { tags: [FETCH_TAG_NOTICE] },
jsessionID: true,
}) as Promise<Notice>;

export const patchNotice = (id: number, formData: FormData) =>
patchRequest(`/v1/notice/${id}`, { body: formData, jsessionID: true });
patchRequest(`/v2/notice/${id}`, { body: formData, jsessionID: true });

export const deleteNotice = (id: number) => deleteRequest(`/v1/notice/${id}`, { jsessionID: true });
export const deleteNotice = (id: number) => deleteRequest(`/v2/notice/${id}`, { jsessionID: true });
8 changes: 4 additions & 4 deletions apis/v1/notice/index.ts β†’ apis/v2/notice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ import { PostSearchQueryParams } from '@/apis/types/post';
import { FETCH_TAG_NOTICE } from '@/constants/network';

export const getNoticePosts = (params: PostSearchQueryParams) =>
getRequest('/v1/notice', params, {
getRequest('/v2/notice', params, {
next: { tags: [FETCH_TAG_NOTICE] },
jsessionID: true,
}) as Promise<NoticePreviewList>;

export const postNotice = async (formData: FormData) => {
return postRequest('/v1/notice', { body: formData, jsessionID: true }) as Promise<{
return postRequest('/v2/notice', { body: formData, jsessionID: true }) as Promise<{
id: number;
}>;
};

export const batchDeleteNotice = async (ids: Set<number>) => {
await deleteRequest('/v1/notice', {
await deleteRequest('/v2/notice', {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ idList: Array.from(ids) }),
jsessionID: true,
});
};

export const batchUnpinNotice = async (ids: Set<number>) => {
await patchRequest('/v1/notice', {
await patchRequest('/v2/notice', {
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ idList: Array.from(ids) }),
jsessionID: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { NoticeSearchResult, SearchParam } from '@/apis/types/search';
import { FETCH_TAG_NOTICE } from '@/constants/network';

export const searchNotice = (params: SearchParam) =>
getRequest('/v1/notice/totalSearch', params, {
getRequest('/v2/notice/totalSearch', params, {
next: { tags: [FETCH_TAG_NOTICE] },
}) as Promise<NoticeSearchResult>;
6 changes: 3 additions & 3 deletions apis/v1/seminar/[id].ts β†’ apis/v2/seminar/[id].ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { Seminar } from '@/apis/types/seminar';
import { FETCH_TAG_SEMINAR } from '@/constants/network';

export const getSeminarPost = async (id: number, params: PostSearchQueryParams) => {
return getRequest(`/v1/seminar/${id}`, params, {
return getRequest(`/v2/seminar/${id}`, params, {
next: { tags: [FETCH_TAG_SEMINAR] },
jsessionID: true,
}) as Promise<Seminar>;
};

export const patchSeminar = async (id: number, formData: FormData) => {
await patchRequest(`/v1/seminar/${id}`, { body: formData, jsessionID: true });
await patchRequest(`/v2/seminar/${id}`, { body: formData, jsessionID: true });
};

export const deleteSeminar = async (id: number) =>
deleteRequest(`/v1/seminar/${id}`, { jsessionID: true });
deleteRequest(`/v2/seminar/${id}`, { jsessionID: true });
4 changes: 2 additions & 2 deletions apis/v1/seminar/index.ts β†’ apis/v2/seminar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { SeminarPreviewList } from '@/apis/types/seminar';
import { FETCH_TAG_SEMINAR } from '@/constants/network';

export const getSeminarPosts = async (params: PostSearchQueryParams) => {
return getRequest('/v1/seminar', params, {
return getRequest('/v2/seminar', params, {
next: { tags: [FETCH_TAG_SEMINAR] },
jsessionID: true,
}) as Promise<SeminarPreviewList>;
};

export const postSeminar = async (formData: FormData) => {
return postRequest('/v1/seminar', { body: formData, jsessionID: true }) as Promise<{
return postRequest('/v2/seminar', { body: formData, jsessionID: true }) as Promise<{
id: number;
}>;
};
2 changes: 1 addition & 1 deletion app/[locale]/community/news/[id]/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getNewsDetail } from '@/apis/v1/news/[id]';
import { getNewsDetail } from '@/apis/v2/news/[id]';

import EditNewsPageContent from './EditNewsPageContent';

Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/community/news/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Suspense } from 'react';

import { PostSearchQueryParams } from '@/apis/types/post';
import { getNewsDetail } from '@/apis/v1/news/[id]';
import { getNewsDetail } from '@/apis/v2/news/[id]';
import PostFallback from '@/app/[locale]/community/components/PostFallback';
import InvalidIDFallback from '@/components/common/InvalidIDFallback';
import PageLayout from '@/components/layout/pageLayout/PageLayout';
Expand Down
16 changes: 14 additions & 2 deletions app/[locale]/community/news/components/NewsEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,20 @@ export default function NewsEditor({ defaultValues, onCancel, onSubmit, onDelete
}
}}
/>
<Form.Checkbox label="메인-μ€‘μš” μ•ˆλ‚΄μ— ν‘œμ‹œ" name="isImportant" />
<Form.Checkbox label="메인-μŠ¬λΌμ΄λ“œμ‡Όμ— ν‘œμ‹œ" name="isSlide" />
<Form.Checkbox
label="메인-μ€‘μš” μ•ˆλ‚΄μ— ν‘œμ‹œ"
name="isImportant"
onChange={(isImportant) => {
if (isImportant) setValue('isPrivate', false);
}}
/>
<Form.Checkbox
label="메인-μŠ¬λΌμ΄λ“œμ‡Όμ— ν‘œμ‹œ"
name="isSlide"
onChange={(isImportant) => {
if (isImportant) setValue('isPrivate', false);
}}
/>
<p className="text-xs font-light tracking-wide text-neutral-700">
* β€˜μŠ¬λΌμ΄λ“œμ‡Όμ— ν‘œμ‹œβ€™ 글은 λŒ€ν‘œμ΄λ―Έμ§€κ°€ μ²¨λΆ€λ˜μ–΄μžˆλŠ”μ§€ 확인 λ°”λžλ‹ˆλ‹€.
</p>
Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/community/news/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { notFound } from 'next/navigation';
import { Suspense } from 'react';

import { PostSearchQueryParams } from '@/apis/types/post';
import { getNewsPosts } from '@/apis/v1/news';
import { getNewsPosts } from '@/apis/v2/news';
import NewsPageContent from '@/app/[locale]/community/news/components/NewsPageContent';
import PageLayout from '@/components/layout/pageLayout/PageLayout';
import { news } from '@/constants/segmentNode';
Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/community/notice/[id]/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getNoticePostDetail } from '@/apis/v1/notice/[id]';
import { getNoticePostDetail } from '@/apis/v2/notice/[id]';
import EditNoticePageContent from '@/app/[locale]/community/notice/[id]/edit/EditNoticePageContent';

interface EditNoticePageProps {
Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/community/notice/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Suspense } from 'react';

import { PostSearchQueryParams } from '@/apis/types/post';
import { getNoticePostDetail } from '@/apis/v1/notice/[id]';
import { getNoticePostDetail } from '@/apis/v2/notice/[id]';
import PostFallback from '@/app/[locale]/community/components/PostFallback';
import InvalidIDFallback from '@/components/common/InvalidIDFallback';
import PageLayout from '@/components/layout/pageLayout/PageLayout';
Expand Down
16 changes: 14 additions & 2 deletions app/[locale]/community/notice/components/NoticeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,20 @@ export default function NoticeEditor({ defaultValues, onCancel, onSubmit, onDele
}
}}
/>
<Form.Checkbox label="λͺ©λ‘ 상단에 κ³ μ •" name="isFixed" />
<Form.Checkbox label="메인-μ€‘μš” μ•ˆλ‚΄μ— ν‘œμ‹œ" name="isImportant" />
<Form.Checkbox
label="λͺ©λ‘ 상단에 κ³ μ •"
name="isPinned"
onChange={(isImportant) => {
if (isImportant) setValue('isPrivate', false);
}}
/>
<Form.Checkbox
label="메인-μ€‘μš” μ•ˆλ‚΄μ— ν‘œμ‹œ"
name="isImportant"
onChange={(isImportant) => {
if (isImportant) setValue('isPrivate', false);
}}
/>
</div>
</Fieldset>
<Form.Action
Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/community/notice/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { notFound } from 'next/navigation';
import { Suspense } from 'react';

import { PostSearchQueryParams } from '@/apis/types/post';
import { getNoticePosts } from '@/apis/v1/notice';
import { getNoticePosts } from '@/apis/v2/notice';
import NoticePageContent from '@/app/[locale]/community/notice/NoticePageContent';
import PageLayout from '@/components/layout/pageLayout/PageLayout';
import { notice } from '@/constants/segmentNode';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export default function EditSeminarPageContent({ id, data }: { id: number; data:
return (
<PageLayout title="μ„Έλ―Έλ‚˜ νŽΈμ§‘" titleType="big" titleMargin="mb-[2.25rem]" hideNavbar>
<SeminarEditor
onCancel={onCancel}
onSubmit={onSubmit}
onCancelAction={onCancel}
onSubmitAction={onSubmit}
onDelete={onDelete}
defaultValues={defaultValues}
/>
Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/community/seminar/[id]/edit/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getSeminarPost } from '@/apis/v1/seminar/[id]';
import { getSeminarPost } from '@/apis/v2/seminar/[id]';
import EditSeminarPageContent from '@/app/[locale]/community/seminar/[id]/edit/EditSeminarPageContent';

interface EditNoticePageProps {
Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/community/seminar/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Suspense } from 'react';

import { PostSearchQueryParams } from '@/apis/types/post';
import { getSeminarPost } from '@/apis/v1/seminar/[id]';
import { getSeminarPost } from '@/apis/v2/seminar/[id]';
import PostFallback from '@/app/[locale]/community/components/PostFallback';
import InvalidIDFallback from '@/components/common/InvalidIDFallback';
import PageLayout from '@/components/layout/pageLayout/PageLayout';
Expand Down
19 changes: 13 additions & 6 deletions app/[locale]/community/seminar/components/SeminarEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { FormProvider, useForm, useFormContext, useWatch } from 'react-hook-form';

import Fieldset from '@/components/form/Fieldset';
Expand Down Expand Up @@ -33,12 +31,17 @@ export interface SeminarFormData {

interface Props {
defaultValues?: SeminarFormData;
onCancel: () => void;
onSubmit: (formData: SeminarFormData) => Promise<void>;
onCancelAction: () => void;
onSubmitAction: (formData: SeminarFormData) => Promise<void>;
onDelete?: () => Promise<void>;
}

export default function SeminarEditor({ defaultValues, onCancel, onSubmit, onDelete }: Props) {
export default function SeminarEditor({
defaultValues,
onCancelAction,
onSubmitAction,
onDelete,
}: Props) {
const formMethods = useForm<SeminarFormData>({
defaultValues: defaultValues ?? {
title: '',
Expand Down Expand Up @@ -154,7 +157,11 @@ export default function SeminarEditor({ defaultValues, onCancel, onSubmit, onDel
</div>
</Fieldset>

<Form.Action onCancel={onCancel} onSubmit={handleSubmit(onSubmit)} onDelete={onDelete} />
<Form.Action
onCancel={onCancelAction}
onSubmit={handleSubmit(onSubmitAction)}
onDelete={onDelete}
/>
</Form>
</FormProvider>
);
Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/community/seminar/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function SeminarCreatePage() {

return (
<PageLayout title="μ„Έλ―Έλ‚˜ μž‘μ„±" titleType="big" titleMargin="mb-[2.25rem]" hideNavbar>
<SeminarEditor onCancel={onCancel} onSubmit={onSubmit} />
<SeminarEditor onCancelAction={onCancel} onSubmitAction={onSubmit} />
</PageLayout>
);
}
2 changes: 1 addition & 1 deletion app/[locale]/community/seminar/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { notFound } from 'next/navigation';
import { Suspense } from 'react';

import { PostSearchQueryParams } from '@/apis/types/post';
import { getSeminarPosts } from '@/apis/v1/seminar';
import { getSeminarPosts } from '@/apis/v2/seminar';
import LoginVisible from '@/components/common/LoginVisible';
import PageLayout from '@/components/layout/pageLayout/PageLayout';
import { seminar } from '@/constants/segmentNode';
Expand Down
2 changes: 1 addition & 1 deletion app/[locale]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getTranslations } from 'next-intl/server';

import { MainImportant } from '@/apis/types/main';
import { getMain } from '@/apis/v1';
import { getMain } from '@/apis/v2';
import GraphicSection from '@/app/[locale]/components/GraphicSection';
import NewsSection from '@/app/[locale]/components/NewsSection';
import NoticeSection from '@/app/[locale]/components/NoticeSection';
Expand Down
6 changes: 3 additions & 3 deletions app/[locale]/search/fetchContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import { searchAbout } from '@/apis/v1/about/search/top';
import { searchAcademics } from '@/apis/v1/academics/search/top';
import { searchAdmissions } from '@/apis/v1/admissions/search/top';
import { searchMember } from '@/apis/v1/member/search/top';
import { searchNews } from '@/apis/v1/news/totalSearch';
import { searchNotice } from '@/apis/v1/notice/totalSearch';
import { getSeminarPosts } from '@/apis/v1/seminar';
import { searchNews } from '@/apis/v2/news/totalSearch';
import { searchNotice } from '@/apis/v2/notice/totalSearch';
import { getSeminarPosts } from '@/apis/v2/seminar';
import { searchResearch } from '@/apis/v2/research/search/top';

import { TreeNode } from './helper/SearchSubNavbar';
Expand Down
2 changes: 1 addition & 1 deletion components/layout/pageLayout/paddings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const PAGE_PADDING_LEFT_PX = 100;
export const PAGE_PADDING_RIGHT_PX = 360;
export const PAGE_PADDING_TOP_PX = 44;
export const PAGE_PADDING_BOTTOM_TAILWIND = '150px';
export const PAGE_PADDING_BOTTOM_TAILWIND = 'pb-[150px]';

0 comments on commit f299c3e

Please sign in to comment.