From 9c315c608376ecbd270025679cdb93e63567da34 Mon Sep 17 00:00:00 2001 From: rachel4w2 Date: Fri, 10 Nov 2023 04:19:27 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20:=20=ED=94=84=EB=A1=9C=EC=A0=9D?= =?UTF-8?q?=ED=8A=B8=20=ED=8F=B4=EB=8D=94=20=EA=B5=AC=EC=A1=B0=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 폴더 구조를 app 아래 project, recruitment로 구분 --- frontend/src/app/layout.tsx | 5 +- .../(read)/post/[postId]/page.tsx | 24 +++--- .../(search)/search-post/[postName]/page.tsx | 8 +- .../(search)/search-user/[userName]/page.tsx | 6 +- .../(submit)/modification/page.tsx | 31 +++---- .../{ => project}/(submit)/new-post/page.tsx | 16 ++-- .../app/{ => project}/(user)/login/error.tsx | 0 .../app/{ => project}/(user)/login/page.tsx | 10 +-- .../(user)/profile/[userName]/page.tsx | 8 +- .../app/{ => project}/(user)/profile/page.tsx | 2 +- .../(user)/registration/error.tsx | 0 .../(user)/registration/page.tsx | 12 +-- frontend/src/app/project/layout.tsx | 9 ++ frontend/src/app/{ => project}/page.tsx | 12 +-- frontend/src/app/recruitment/layout.tsx | 9 ++ .../{(error)/error => recruitment}/page.tsx | 0 .../general/{NavBar.tsx => ProjectNavBar.tsx} | 12 +-- .../components/general/RecruitmentNavBar.tsx | 7 ++ .../components/{ => project}/main/Banner.tsx | 2 +- .../{ => project}/main/ProjectCard.tsx | 10 +-- .../{ => project}/read/GptModal.tsx | 16 ++-- .../{ => project}/read/PutReply.tsx | 2 +- .../{ => project}/read/ReadReReply.tsx | 8 +- .../{ => project}/read/ReadReply.tsx | 10 +-- .../components/{ => project}/read/Reply.tsx | 2 +- .../{ => project}/read/ToastViewer.tsx | 2 +- .../{ => project}/read/WriteReReply.tsx | 4 +- .../{ => project}/submit/imageUploader.tsx | 4 +- .../submit/techStackSelection.tsx | 4 +- .../{ => project}/submit/toastUIEditor.tsx | 4 +- .../{ => project}/user/FollowListModal.tsx | 6 +- .../{ => project}/user/WritedPost.tsx | 2 +- frontend/yarn.lock | 82 ++++++++++++------- 33 files changed, 187 insertions(+), 142 deletions(-) rename frontend/src/app/{ => project}/(read)/post/[postId]/page.tsx (93%) rename frontend/src/app/{ => project}/(search)/search-post/[postName]/page.tsx (90%) rename frontend/src/app/{ => project}/(search)/search-user/[userName]/page.tsx (94%) rename frontend/src/app/{ => project}/(submit)/modification/page.tsx (88%) rename frontend/src/app/{ => project}/(submit)/new-post/page.tsx (93%) rename frontend/src/app/{ => project}/(user)/login/error.tsx (100%) rename frontend/src/app/{ => project}/(user)/login/page.tsx (96%) rename frontend/src/app/{ => project}/(user)/profile/[userName]/page.tsx (94%) rename frontend/src/app/{ => project}/(user)/profile/page.tsx (95%) rename frontend/src/app/{ => project}/(user)/registration/error.tsx (100%) rename frontend/src/app/{ => project}/(user)/registration/page.tsx (96%) create mode 100644 frontend/src/app/project/layout.tsx rename frontend/src/app/{ => project}/page.tsx (91%) create mode 100644 frontend/src/app/recruitment/layout.tsx rename frontend/src/app/{(error)/error => recruitment}/page.tsx (100%) rename frontend/src/components/general/{NavBar.tsx => ProjectNavBar.tsx} (92%) create mode 100644 frontend/src/components/general/RecruitmentNavBar.tsx rename frontend/src/components/{ => project}/main/Banner.tsx (97%) rename frontend/src/components/{ => project}/main/ProjectCard.tsx (92%) rename frontend/src/components/{ => project}/read/GptModal.tsx (98%) rename frontend/src/components/{ => project}/read/PutReply.tsx (98%) rename frontend/src/components/{ => project}/read/ReadReReply.tsx (94%) rename frontend/src/components/{ => project}/read/ReadReply.tsx (95%) rename frontend/src/components/{ => project}/read/Reply.tsx (99%) rename frontend/src/components/{ => project}/read/ToastViewer.tsx (94%) rename frontend/src/components/{ => project}/read/WriteReReply.tsx (96%) rename frontend/src/components/{ => project}/submit/imageUploader.tsx (95%) rename frontend/src/components/{ => project}/submit/techStackSelection.tsx (96%) rename frontend/src/components/{ => project}/submit/toastUIEditor.tsx (95%) rename frontend/src/components/{ => project}/user/FollowListModal.tsx (95%) rename frontend/src/components/{ => project}/user/WritedPost.tsx (96%) diff --git a/frontend/src/app/layout.tsx b/frontend/src/app/layout.tsx index 5e8299c0..b8733d8a 100644 --- a/frontend/src/app/layout.tsx +++ b/frontend/src/app/layout.tsx @@ -2,7 +2,6 @@ import './globals.css' import type { Metadata } from 'next' import { Inter } from 'next/font/google' import Provider from '../components/general/Provider' -import NavBar from '../components/general/NavBar' const inter = Inter({ subsets: ['latin'] }) @@ -19,9 +18,7 @@ export default function RootLayout({ return ( - - {children} - + {children} ) diff --git a/frontend/src/app/(read)/post/[postId]/page.tsx b/frontend/src/app/project/(read)/post/[postId]/page.tsx similarity index 93% rename from frontend/src/app/(read)/post/[postId]/page.tsx rename to frontend/src/app/project/(read)/post/[postId]/page.tsx index 2fa9d733..45c0a546 100644 --- a/frontend/src/app/(read)/post/[postId]/page.tsx +++ b/frontend/src/app/project/(read)/post/[postId]/page.tsx @@ -4,11 +4,11 @@ import Image from 'next/image' import { useEffect, useState, useCallback } from 'react' import { useRouter } from 'next/navigation' import { useRecoilState, useRecoilValue } from 'recoil' -import gptIcon from '../../../../../public/images/svg/gptIcon.svg' -import ProfileIcon from '../../../../../public/images/svg/profileIcon.svg' -import GptModal from '../../../../components/read/GptModal' -import ToastViewer from '../../../../components/read/ToastViewer' -import Reply from '../../../../components/read/Reply' +import gptIcon from '../../../../../../public/images/svg/gptIcon.svg' +import ProfileIcon from '../../../../../../public/images/svg/profileIcon.svg' +import GptModal from '../../../../../components/project/read/GptModal' +import ToastViewer from '../../../../../components/project/read/ToastViewer' +import Reply from '../../../../../components/project/read/Reply' import { contentsState, @@ -16,8 +16,8 @@ import { titleState, tldrState, refreshState, -} from '../../../../utils/atoms' -import AllStacks from '../../../../utils/stacks' +} from '../../../../../utils/atoms' +import AllStacks from '../../../../../utils/stacks' type ReadReplyObject = { commentId: number @@ -54,11 +54,11 @@ export default function ReadingPage({ params }: ParamsType) { }, [isOpenModal]) function toWrite() { - router.push('/write') + router.push('/project/write') } function toModify() { - router.push('/modify') + router.push('/project/modification') } // GET요청 보내서 데이터 가져오고 받은 데이터 변수에 넣어주는 함수 async function getData() { @@ -79,7 +79,7 @@ export default function ReadingPage({ params }: ParamsType) { alert('프로젝트 상세 조회 실패') throw new Error('프로젝트 상세 조회 실패') } - router.push('/') + router.push('/project') } const resData = await res.json() @@ -119,10 +119,10 @@ export default function ReadingPage({ params }: ParamsType) { alert('프로젝트 삭제 실패') throw new Error('프로젝트 삭제 실패') } - router.push('/') + router.push('/project') } else { alert('프로젝트 삭제 성공') - router.push('/') + router.push('/project') } } } diff --git a/frontend/src/app/(search)/search-post/[postName]/page.tsx b/frontend/src/app/project/(search)/search-post/[postName]/page.tsx similarity index 90% rename from frontend/src/app/(search)/search-post/[postName]/page.tsx rename to frontend/src/app/project/(search)/search-post/[postName]/page.tsx index d9bb46f6..8750ee56 100644 --- a/frontend/src/app/(search)/search-post/[postName]/page.tsx +++ b/frontend/src/app/project/(search)/search-post/[postName]/page.tsx @@ -3,9 +3,9 @@ import { useEffect, useState } from 'react' import { useRouter } from 'next/navigation' -import WriteIcon from '../../../../../public/images/svg/pencil-square.svg' -import Banner from '../../../../components/main/Banner' -import ProjectCard from '../../../../components/main/ProjectCard' +import WriteIcon from '../../../../../../public/images/svg/pencil-square.svg' +import Banner from '../../../../../components/project/main/Banner' +import ProjectCard from '../../../../../components/project/main/ProjectCard' type DataObject = { id: number @@ -27,7 +27,7 @@ export default function SearchProjectPage({ params }: ParamsType) { const router = useRouter() // react-router-dom useNavigate 사용 선언 function toWrite() { - router.push('/write') + router.push('/project/write') } async function getData() { diff --git a/frontend/src/app/(search)/search-user/[userName]/page.tsx b/frontend/src/app/project/(search)/search-user/[userName]/page.tsx similarity index 94% rename from frontend/src/app/(search)/search-user/[userName]/page.tsx rename to frontend/src/app/project/(search)/search-user/[userName]/page.tsx index 119bf57d..92ace1cc 100644 --- a/frontend/src/app/(search)/search-user/[userName]/page.tsx +++ b/frontend/src/app/project/(search)/search-user/[userName]/page.tsx @@ -5,9 +5,9 @@ import { useRouter } from 'next/navigation' import { v4 as uuidv4 } from 'uuid' import Image from 'next/image' -import WriteIcon from '../../../../../public/images/svg/pencil-square.svg' -import ProfileIcon from '../../../../../public/images/svg/profileIcon.svg' -import Banner from '../../../../components/main/Banner' +import WriteIcon from '../../../../../../public/images/svg/arrow-right.svg' +import ProfileIcon from '../../../../../../public/images/svg/arrow-left.svg' +import Banner from '../../../../../components/project/main/Banner' type DataObject = { nickname: string diff --git a/frontend/src/app/(submit)/modification/page.tsx b/frontend/src/app/project/(submit)/modification/page.tsx similarity index 88% rename from frontend/src/app/(submit)/modification/page.tsx rename to frontend/src/app/project/(submit)/modification/page.tsx index c6fd64d7..05230cb8 100644 --- a/frontend/src/app/(submit)/modification/page.tsx +++ b/frontend/src/app/project/(submit)/modification/page.tsx @@ -7,8 +7,8 @@ import dynamic from 'next/dynamic' // TODO: NavBar 만들어야 함 // import NavBar from '../../components/general/NavBar' -import ImageUploader from '../../../components/submit/imageUploader' -import TechStackSelection from '../../../components/submit/techStackSelection' +import ImageUploader from '../../../../components/project/submit/imageUploader' +import TechStackSelection from '../../../../components/project/submit/techStackSelection' import { contentsState, projectIdState, @@ -16,10 +16,10 @@ import { thumbnailUrlState, titleState, tldrState, -} from '../../../utils/atoms' +} from '../../../../utils/atoms' const ToastUIEditor = dynamic( - () => import('../../../components/submit/toastUIEditor'), + () => import('../../../../components/project/submit/toastUIEditor'), { ssr: false }, ) @@ -65,14 +65,17 @@ export default function NewPost() { thumbNail: thumbnailUrl, } - const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/projects`, { - method: 'PUT', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${accessToken || persistToken}`, + const res = await fetch( + `${process.env.NEXT_PUBLIC_BASE_URL}/projects/${projectId}`, + { + method: 'PUT', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${accessToken || persistToken}`, + }, + body: JSON.stringify(data), }, - body: JSON.stringify(data), - }) + ) if (!res.ok) { if (!navigator.onLine) { @@ -89,12 +92,12 @@ export default function NewPost() { } setThumbnailUrl('') - router.push(`/read/${projectId}`) + router.push(`/project/post/${projectId}`) } // 취소 버튼 누를시 메인페이지 이동 function toMain() { - router.push('/') + router.push('/project') } useEffect(() => { @@ -104,7 +107,7 @@ export default function NewPost() { if (!(accessToken || persistToken)) { // eslint-disable-next-line no-alert alert('로그인시 이용하실 수 있습니다.') - router.push('/') + router.push('/project') } }, []) diff --git a/frontend/src/app/(submit)/new-post/page.tsx b/frontend/src/app/project/(submit)/new-post/page.tsx similarity index 93% rename from frontend/src/app/(submit)/new-post/page.tsx rename to frontend/src/app/project/(submit)/new-post/page.tsx index c5f1e983..7fb1b17a 100644 --- a/frontend/src/app/(submit)/new-post/page.tsx +++ b/frontend/src/app/project/(submit)/new-post/page.tsx @@ -5,10 +5,8 @@ import { useRouter } from 'next/navigation' import { useRecoilState } from 'recoil' import dynamic from 'next/dynamic' -// TODO: NavBar 만들어야 함 -// import NavBar from '../../components/general/NavBar' -import ImageUploader from '../../../components/submit/imageUploader' -import TechStackSelection from '../../../components/submit/techStackSelection' +import ImageUploader from '../../../../components/project/submit/imageUploader' +import TechStackSelection from '../../../../components/project/submit/techStackSelection' import { contentsState, projectIdState, @@ -16,10 +14,10 @@ import { thumbnailUrlState, titleState, tldrState, -} from '../../../utils/atoms' +} from '../../../../utils/atoms' const ToastUIEditor = dynamic( - () => import('../../../components/submit/toastUIEditor'), + () => import('../../../../components/project/submit/toastUIEditor'), { ssr: false }, ) @@ -92,12 +90,12 @@ export default function NewPost() { setProjectId(resData.data.projectId) setThumbnailUrl('') - router.push(`/read/${resData.data.projectId}`) + router.push(`/project/post/${resData.data.projectId}`) } // 취소 버튼 누를시 메인페이지 이동 function toMain() { - router.push('/') + router.push('/project') } useEffect(() => { @@ -107,7 +105,7 @@ export default function NewPost() { if (!(accessToken || persistToken)) { // eslint-disable-next-line no-alert alert('로그인시 이용하실 수 있습니다.') - router.push('/') + router.push('/project') } // 글쓰기 페이지 렌더링 시 변수 초기화 setTitle('') diff --git a/frontend/src/app/(user)/login/error.tsx b/frontend/src/app/project/(user)/login/error.tsx similarity index 100% rename from frontend/src/app/(user)/login/error.tsx rename to frontend/src/app/project/(user)/login/error.tsx diff --git a/frontend/src/app/(user)/login/page.tsx b/frontend/src/app/project/(user)/login/page.tsx similarity index 96% rename from frontend/src/app/(user)/login/page.tsx rename to frontend/src/app/project/(user)/login/page.tsx index c33a49fc..33309929 100644 --- a/frontend/src/app/(user)/login/page.tsx +++ b/frontend/src/app/project/(user)/login/page.tsx @@ -10,8 +10,8 @@ import { useRecoilState } from 'recoil' import * as yup from 'yup' import Image from 'next/image' -import Email from '../../../../public/images/svg/email.svg' -import { autoLoginState, usernameState } from '../../../utils/atoms' +import Email from '../../../../../public/images/svg/email.svg' +import { autoLoginState, usernameState } from '../../../../utils/atoms' type DataObject = { email: string @@ -60,11 +60,11 @@ export default function Login() { }) function toMain() { - router.push('/') + router.push('/project') } function toRegistration() { - router.push('/registration') + router.push('/project/registration') } const onSubmit: SubmitHandler = async (data: DataObject) => { @@ -112,7 +112,7 @@ export default function Login() { setUsername(myInfoData.data.nickname) - router.push('/') + router.push('/project') } useEffect(() => { diff --git a/frontend/src/app/(user)/profile/[userName]/page.tsx b/frontend/src/app/project/(user)/profile/[userName]/page.tsx similarity index 94% rename from frontend/src/app/(user)/profile/[userName]/page.tsx rename to frontend/src/app/project/(user)/profile/[userName]/page.tsx index b05d8b20..6db83f5b 100644 --- a/frontend/src/app/(user)/profile/[userName]/page.tsx +++ b/frontend/src/app/project/(user)/profile/[userName]/page.tsx @@ -4,10 +4,10 @@ import { useEffect, useState, useCallback } from 'react' import { useRouter } from 'next/navigation' import Image from 'next/image' -import WritedPost from '../../../../components/user/WritedPost' -import myProfile from '../../../../../public/images/png/myProfile.png' -import WriteIcon from '../../../../../public/images/svg/pencil-square.svg' -import FollowListModal from '../../../../components/user/FollowListModal' +import WritedPost from '../../../../../components/project/user/WritedPost' +import myProfile from '../../../../../../public/images/png/myProfile.png' +import WriteIcon from '../../../../../../public/images/svg/pencil-square.svg' +import FollowListModal from '../../../../../components/project/user/FollowListModal' type GetProjectInfoResponse = { id: number diff --git a/frontend/src/app/(user)/profile/page.tsx b/frontend/src/app/project/(user)/profile/page.tsx similarity index 95% rename from frontend/src/app/(user)/profile/page.tsx rename to frontend/src/app/project/(user)/profile/page.tsx index c4608db4..0ef9b2a0 100644 --- a/frontend/src/app/(user)/profile/page.tsx +++ b/frontend/src/app/project/(user)/profile/page.tsx @@ -50,7 +50,7 @@ export default function MyPage() { } if (resData.data !== undefined) { - router.push(`/profile/${resData.data.nickname}`) + router.push(`/project/profile/${resData.data.nickname}`) } } diff --git a/frontend/src/app/(user)/registration/error.tsx b/frontend/src/app/project/(user)/registration/error.tsx similarity index 100% rename from frontend/src/app/(user)/registration/error.tsx rename to frontend/src/app/project/(user)/registration/error.tsx diff --git a/frontend/src/app/(user)/registration/page.tsx b/frontend/src/app/project/(user)/registration/page.tsx similarity index 96% rename from frontend/src/app/(user)/registration/page.tsx rename to frontend/src/app/project/(user)/registration/page.tsx index 9fbc4718..416c25be 100644 --- a/frontend/src/app/(user)/registration/page.tsx +++ b/frontend/src/app/project/(user)/registration/page.tsx @@ -10,8 +10,8 @@ import { useRecoilState, useRecoilValue } from 'recoil' import * as yup from 'yup' import Image from 'next/image' -import Email from '../../../../public/images/svg/email.svg' -import { autoLoginState, usernameState } from '../../../utils/atoms' +import Email from '../../../../../public/images/svg/email.svg' +import { autoLoginState, usernameState } from '../../../../utils/atoms' type DataObject = { email: string @@ -65,11 +65,11 @@ export default function Registration() { }) function toMain() { - router.push('/') + router.push('/project') } function toLogin() { - router.push('/login') + router.push('/project/login') } const onSubmit: SubmitHandler = async (data: DataObject) => { @@ -142,7 +142,7 @@ export default function Registration() { setUsername(myInfoData.data.nickname) - router.push('/') + router.push('/project') } useEffect(() => { @@ -152,7 +152,7 @@ export default function Registration() { if (accessToken || persistToken) { // eslint-disable-next-line no-alert alert('이미 로그인 상태입니다.') - router.push('/') + router.push('/project') } }, []) diff --git a/frontend/src/app/project/layout.tsx b/frontend/src/app/project/layout.tsx new file mode 100644 index 00000000..f6e765db --- /dev/null +++ b/frontend/src/app/project/layout.tsx @@ -0,0 +1,9 @@ +import ProjectNavBar from '../../components/general/ProjectNavBar' + +export default function ProjectLayout({ + children, +}: { + children: React.ReactNode +}) { + return {children} +} diff --git a/frontend/src/app/page.tsx b/frontend/src/app/project/page.tsx similarity index 91% rename from frontend/src/app/page.tsx rename to frontend/src/app/project/page.tsx index 211715f6..ef0c4b94 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/project/page.tsx @@ -6,10 +6,10 @@ import { useRouter } from 'next/navigation' import { useRecoilValue } from 'recoil' import Image from 'next/image' -import WriteIcon from '../../public/images/svg/pencil-square.svg' -import Banner from '../components/main/Banner' -import ProjectCard from '../components/main/ProjectCard' -import { searchTextState } from '../utils/atoms' +import WriteIcon from '../../../public/images/svg/pencil-square.svg' +import Banner from '../../components/project/main/Banner' +import ProjectCard from '../../components/project/main/ProjectCard' +import { searchTextState } from '../../utils/atoms' type DataObject = { id: number @@ -20,13 +20,13 @@ type DataObject = { thumbNail: string } -export default function Main() { +export default function ProjectMain() { const searchText = useRecoilValue(searchTextState) const router = useRouter() function toWrite() { - router.push('/write') + router.push('/project/write') } async function getData({ pageParam = 1 }) { diff --git a/frontend/src/app/recruitment/layout.tsx b/frontend/src/app/recruitment/layout.tsx new file mode 100644 index 00000000..bda59322 --- /dev/null +++ b/frontend/src/app/recruitment/layout.tsx @@ -0,0 +1,9 @@ +import RecruitmentNavBar from '../../components/general/RecruitmentNavBar' + +export default function ProjectLayout({ + children, +}: { + children: React.ReactNode +}) { + return {children} +} diff --git a/frontend/src/app/(error)/error/page.tsx b/frontend/src/app/recruitment/page.tsx similarity index 100% rename from frontend/src/app/(error)/error/page.tsx rename to frontend/src/app/recruitment/page.tsx diff --git a/frontend/src/components/general/NavBar.tsx b/frontend/src/components/general/ProjectNavBar.tsx similarity index 92% rename from frontend/src/components/general/NavBar.tsx rename to frontend/src/components/general/ProjectNavBar.tsx index 9b60efc8..5e518af5 100644 --- a/frontend/src/components/general/NavBar.tsx +++ b/frontend/src/components/general/ProjectNavBar.tsx @@ -40,9 +40,9 @@ export default function NavBar({ children }: { children: React.ReactNode }) { router.push('/') } else if (searchText.charAt(0) === '@') { const searchUserName = searchText.substring(1) - router.push(`/search-user/${searchUserName}`) + router.push(`/project/search-user/${searchUserName}`) } else { - router.push(`/search-post/${searchText}`) + router.push(`/project/search-post/${searchText}`) } } @@ -51,7 +51,7 @@ export default function NavBar({ children }: { children: React.ReactNode }) { signOut() setBtnText('로그인') } else { - router.push('/login') + router.push('/project/login') } } @@ -63,7 +63,7 @@ export default function NavBar({ children }: { children: React.ReactNode }) { } }, [pathname]) - if (pathname === '/login' || pathname === '/registration') { + if (pathname === '/project/login' || pathname === '/project/registration') { return children } @@ -122,7 +122,7 @@ export default function NavBar({ children }: { children: React.ReactNode }) {