diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index a3a377742..386e13116 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -18,8 +18,8 @@ jobs: username: ${{secrets.SSH_USER}} key: ${{secrets.SSH_KEY}} script: | - cd ~/csereal_web + cd ~/csereal-web + git pull npm run build - pm2 stop csereal_front - pm2 --name csereal_front start npm -- start + pm2 restart csereal_front diff --git a/actions/index.ts b/actions/index.ts index 1a27baf71..48758a3d0 100644 --- a/actions/index.ts +++ b/actions/index.ts @@ -2,6 +2,25 @@ import { cookies } from 'next/headers'; import { BASE_URL, checkError } from '@/apis'; +import { objToQueryString } from '@/utils/convertParams'; + +export const getRequest = async (url: string, params: object = {}, init?: RequestInit) => { + const queryString = objToQueryString(params); + const fetchUrl = `${BASE_URL}${url}${queryString}`; + const jsessionId = cookies().get('JSESSIONID'); + const response = await fetch(fetchUrl, { + ...init, + method: 'GET', + headers: { + Cookie: `JSESSIONID=${jsessionId?.value}`, + ...init?.headers, + }, + }); + checkError(response); + const responseData = await response.json(); + return responseData as T; +}; + export const deleteRequest = async (url: string, init?: RequestInit) => { const fetchUrl = `${BASE_URL}${url}`; const jsessionId = cookies().get('JSESSIONID'); diff --git a/actions/noticeActions.ts b/actions/noticeActions.ts index 23f85c438..c47a84952 100644 --- a/actions/noticeActions.ts +++ b/actions/noticeActions.ts @@ -3,15 +3,27 @@ import { revalidateTag } from 'next/cache'; import { redirect } from 'next/navigation'; +import { NoticePreviewList, Notice } from '@/types/notice'; import { notice } from '@/types/page'; +import { PostSearchQueryParams } from '@/types/post'; import { getPath } from '@/utils/page'; -import { deleteRequest, patchRequest } from '.'; +import { deleteRequest, getRequest, patchRequest } from '.'; const noticeApiPath = '/notice'; const noticePath = getPath(notice); +export const getNoticePosts = (params: PostSearchQueryParams) => + getRequest(noticeApiPath, params, { + next: { tags: ['notice'] }, + }) as Promise; + +export const getNoticePostDetail = (id: number, params: PostSearchQueryParams) => + getRequest(`${noticeApiPath}/${id}`, params, { + next: { tags: ['notice'] }, + }) as Promise; + export const batchDeleteAction = async (ids: Set) => { try { await deleteRequest(noticeApiPath, { diff --git a/apis/notice.ts b/apis/notice.ts index 80fe1ab1d..3625a6b56 100644 --- a/apis/notice.ts +++ b/apis/notice.ts @@ -1,21 +1,11 @@ import { Notice, NoticePreviewList, POSTNoticeBody, PatchNoticeBody } from '@/types/notice'; import { PostSearchQueryParams } from '@/types/post'; -import { - deleteRequestWithCookie, - getRequest, - patchRequestWithCookie, - postRequestWithCookie, -} from '.'; +import { deleteRequestWithCookie, patchRequestWithCookie, postRequestWithCookie } from '.'; +import { getRequest } from '../actions'; const noticePath = '/notice'; -export const getNoticePosts = (params: PostSearchQueryParams) => - getRequest(noticePath, params, { next: { tags: ['notice'] } }) as Promise; - -export const getNoticePostDetail = (id: number, params: PostSearchQueryParams) => - getRequest(`${noticePath}/${id}`, params, { next: { tags: ['notice'] } }) as Promise; - export const postNotice = async (body: POSTNoticeBody) => { const formData = new FormData(); formData.append( diff --git a/app/[locale]/community/notice/[id]/edit/page.tsx b/app/[locale]/community/notice/[id]/edit/page.tsx index e5637e12f..1443a0410 100644 --- a/app/[locale]/community/notice/[id]/edit/page.tsx +++ b/app/[locale]/community/notice/[id]/edit/page.tsx @@ -1,4 +1,4 @@ -import { getNoticePostDetail } from '@/apis/notice'; +import { getNoticePostDetail } from '@/actions/noticeActions'; import EditNoticePageContent from '@/components/notice/EditNoticePageContent'; diff --git a/app/[locale]/community/notice/[id]/page.tsx b/app/[locale]/community/notice/[id]/page.tsx index 59608b0c8..53842bcf1 100644 --- a/app/[locale]/community/notice/[id]/page.tsx +++ b/app/[locale]/community/notice/[id]/page.tsx @@ -1,4 +1,4 @@ -import { getNoticePostDetail } from '@/apis/notice'; +import { getNoticePostDetail } from '@/actions/noticeActions'; import AdjPostNav from '@/components/common/AdjPostNav'; import Attachments from '@/components/common/Attachments'; diff --git a/app/[locale]/community/notice/create/page.tsx b/app/[locale]/community/notice/create/page.tsx index f61f69bd3..7e2a6e3eb 100644 --- a/app/[locale]/community/notice/create/page.tsx +++ b/app/[locale]/community/notice/create/page.tsx @@ -24,7 +24,7 @@ export default function NoticeCreatePage() { const handleCancel = () => router.push(noticePath); const handleComplete = async (content: PostEditorContent) => { - console.log(content.description); + console.log(content.isPrivate); canSubmit(content); const attachments = content.attachments.filter(isLocalFile).map((x) => x.file); diff --git a/app/[locale]/community/notice/page.tsx b/app/[locale]/community/notice/page.tsx index 81a73b607..8e374b215 100644 --- a/app/[locale]/community/notice/page.tsx +++ b/app/[locale]/community/notice/page.tsx @@ -1,4 +1,4 @@ -import { getNoticePosts } from '@/apis/notice'; +import { getNoticePosts } from '@/actions/noticeActions'; import NoticePageContent from '@/components/notice/NoticePageContent'; diff --git a/components/notice/EditNoticePageContent.tsx b/components/notice/EditNoticePageContent.tsx index 8ce66e6fc..13d54b950 100644 --- a/components/notice/EditNoticePageContent.tsx +++ b/components/notice/EditNoticePageContent.tsx @@ -1,11 +1,11 @@ 'use client'; import { useRouter } from 'next/navigation'; -import { startTransition, useTransition } from 'react'; +import { useTransition } from 'react'; import { noticeDeleteAction, revalidateNoticeTag } from '@/actions/noticeActions'; -import { deleteNotice, patchNotice } from '@/apis/notice'; +import { patchNotice } from '@/apis/notice'; import PostEditor from '@/components/editor/PostEditor'; import {