diff --git a/src/api/userpage.api.ts b/src/api/userpage.api.ts index a7cbf887..9cc862c8 100644 --- a/src/api/userpage.api.ts +++ b/src/api/userpage.api.ts @@ -1,5 +1,5 @@ import type { ApiUserInfo } from '../models/userInfo'; -import type { ApiSelectUserProject } from '../models/userProject'; +import type { ApiUserProject } from '../models/userProject'; import { httpClient } from './http.api'; export const getUserInfo = async (id: number) => { @@ -15,8 +15,8 @@ export const getUserInfo = async (id: number) => { export const getUserJoinedProjectList = async (id: number) => { try { - const response = await httpClient.get( - `/user/${id}/project` + const response = await httpClient.get( + `/user/${id}/participated` ); return response.data; @@ -25,3 +25,16 @@ export const getUserJoinedProjectList = async (id: number) => { throw error; } }; + +export const getUserManagedProjectList = async (id: number) => { + try { + const response = await httpClient.get( + `/user/${id}/project` + ); + + return response.data; + } catch (error) { + console.error('다른 유저 기획 프로젝트 조회: ', error); + throw error; + } +}; diff --git a/src/components/user/mypage/joinedProject/MyJoinProjects.tsx b/src/components/user/mypage/joinedProject/MyJoinProjects.tsx index b0e57953..ab88846b 100644 --- a/src/components/user/mypage/joinedProject/MyJoinProjects.tsx +++ b/src/components/user/mypage/joinedProject/MyJoinProjects.tsx @@ -14,8 +14,6 @@ const MyJoinProjects = () => { return ; } - if (!myJoinedProjectListData) return; - return ( diff --git a/src/components/user/userPage/joinedProject/UserJoinProject.tsx b/src/components/user/userPage/joinedProject/UserJoinProject.tsx deleted file mode 100644 index b058c985..00000000 --- a/src/components/user/userPage/joinedProject/UserJoinProject.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import { Link, useParams } from 'react-router-dom'; -import * as S from '../../mypage/joinedProject/MyJoinProjects.styled'; -import Spinner from '../../mypage/Spinner'; -import Project from '../../mypage/joinedProject/Project'; -import { useUserJoinedProjectList } from '../../../../hooks/user/useUserInfo'; -import { ROUTES } from '../../../../constants/user/routes'; -import NoContent from '../../../common/noContent/NoContent'; - -const UserJoinProject = () => { - const { userId } = useParams(); - const { userJoinedProjectListData, isLoading } = useUserJoinedProjectList( - Number(userId) - ); - - if (isLoading) { - return ; - } - - console.log('userJoinedProjectListData', userJoinedProjectListData); - - return ( - - - - 참여한 프로젝트 리스트 - - {userJoinedProjectListData?.acceptedProjects && - userJoinedProjectListData?.acceptedProjects?.length > 0 ? ( - - {userJoinedProjectListData?.acceptedProjects?.map((project) => ( - - - - ))} - - ) : ( - - - - )} - - - - 기획한 프로젝트 리스트 - - {userJoinedProjectListData?.ownProjects && - userJoinedProjectListData?.ownProjects?.length > 0 ? ( - - {userJoinedProjectListData?.ownProjects?.map((project) => ( - - - - ))} - - ) : ( - - - - )} - - - ); -}; - -export default UserJoinProject; diff --git a/src/components/user/userPage/userProjectList/UserProjectList.tsx b/src/components/user/userPage/userProjectList/UserProjectList.tsx new file mode 100644 index 00000000..d356a3d8 --- /dev/null +++ b/src/components/user/userPage/userProjectList/UserProjectList.tsx @@ -0,0 +1,42 @@ +import { Link } from 'react-router-dom'; +import * as S from '../../mypage/joinedProject/MyJoinProjects.styled'; +import { ROUTES } from '../../../../constants/user/routes'; +import NoContent from '../../../common/noContent/NoContent'; +import ScrollWrapper from '../../mypage/ScrollWrapper'; +import Spinner from '../../mypage/Spinner'; +import Project from '../../mypage/joinedProject/Project'; +import { useGetUserProjectList } from '../../../../hooks/user/useGetUserProjectList'; + +export default function UserProjects() { + const { userProjectData, isLoading, title } = useGetUserProjectList(); + + if (isLoading) { + return ; + } + + return ( + + + {title} + + {userProjectData && userProjectData.length > 0 ? ( + + + {userProjectData?.map((project) => ( + + + + ))} + + + ) : ( + + + + )} + + ); +} diff --git a/src/constants/user/routes.ts b/src/constants/user/routes.ts index c79eb04b..a2618850 100644 --- a/src/constants/user/routes.ts +++ b/src/constants/user/routes.ts @@ -11,8 +11,8 @@ export const ROUTES = { manageProjectsPassNonPass: '/manage/pass-nonpass', mypage: '/mypage', mypageEdit: '/mypage/edit', - mypageJoinedProjects: 'joined-projects', - mypageAppliedProjects: 'apply-projects', + joinedProjects: 'joined-projects', + managedProjects: 'managed-projects', myPageNotifications: 'notifications', notificationsAppliedProjects: 'applied-projects', notificationsCheckedApplicants: 'checked-applicants', @@ -20,7 +20,6 @@ export const ROUTES = { comments: 'comments', myPageActivityLog: 'activity-log', userpage: '/user', - userJoinedProject: 'joined-projects', modifyProject: '/project-modify', notFound: '/not-found', customerService: '/customer-service', diff --git a/src/hooks/queries/user/keys.ts b/src/hooks/queries/user/keys.ts index 157a6eb3..60a3acbd 100644 --- a/src/hooks/queries/user/keys.ts +++ b/src/hooks/queries/user/keys.ts @@ -16,6 +16,7 @@ export const myInfoKey = { export const userInfoKey = { userProfile: ['userProfile'], userJoinedList: ['userJoinedProjectList'], + userManagedList: ['userManagedProjectList'], } as const; export const ProjectListKey = { diff --git a/src/hooks/user/useGetNoticeDetail.ts b/src/hooks/user/useGetNoticeDetail.ts index f355108b..5b662c2d 100644 --- a/src/hooks/user/useGetNoticeDetail.ts +++ b/src/hooks/user/useGetNoticeDetail.ts @@ -6,8 +6,6 @@ export const useGetNoticeDetail = (id: string) => { const { data: noticeDetailData, isLoading } = useQuery({ queryKey: [CustomerService.noticeDetail, id], queryFn: () => getNoticeDetail(id), - staleTime: Infinity, - gcTime: Infinity, }); return { noticeDetail: noticeDetailData, isLoading }; diff --git a/src/hooks/user/useGetUserProjectList.ts b/src/hooks/user/useGetUserProjectList.ts new file mode 100644 index 00000000..a359f6bf --- /dev/null +++ b/src/hooks/user/useGetUserProjectList.ts @@ -0,0 +1,27 @@ +import { useQuery } from '@tanstack/react-query'; +import { + getUserJoinedProjectList, + getUserManagedProjectList, +} from '../../api/userpage.api'; +import { userInfoKey } from '../queries/user/keys'; +import { useLocation, useParams } from 'react-router-dom'; +import type { ApiUserProject } from '../../models/userProject'; + +export const useGetUserProjectList = () => { + const { userId } = useParams(); + const location = useLocation(); + const isJoinedPage = location.pathname.includes('joined') ? true : false; + const title = isJoinedPage + ? '참여한 프로젝트 리스트' + : '기획한 프로젝트 리스트'; + + const { data, isLoading } = useQuery({ + queryKey: [userInfoKey.userManagedList, userId, isJoinedPage], + queryFn: () => + isJoinedPage + ? getUserJoinedProjectList(Number(userId)) + : getUserManagedProjectList(Number(userId)), + }); + + return { userProjectData: data?.data, isLoading, title }; +}; diff --git a/src/hooks/user/useUserInfo.ts b/src/hooks/user/useUserInfo.ts index f650e09e..61c5bcf8 100644 --- a/src/hooks/user/useUserInfo.ts +++ b/src/hooks/user/useUserInfo.ts @@ -2,8 +2,7 @@ import { useQuery } from '@tanstack/react-query'; import { userInfoKey } from '../queries/user/keys'; import useAuthStore from '../../store/authStore'; import { ApiUserInfo } from '../../models/userInfo'; -import { getUserInfo, getUserJoinedProjectList } from '../../api/userpage.api'; -import { ApiSelectUserProject } from '../../models/userProject'; +import { getUserInfo } from '../../api/userpage.api'; export const useUserProfileInfo = (id: number) => { const isLoggedIn = useAuthStore((state) => state.isLoggedIn); @@ -17,16 +16,3 @@ export const useUserProfileInfo = (id: number) => { return { userData: data?.data, isLoading }; }; - -export const useUserJoinedProjectList = (id: number) => { - const isLoggedIn = useAuthStore((state) => state.isLoggedIn); - - const { data, isLoading } = useQuery({ - queryKey: [userInfoKey.userJoinedList, id], - queryFn: () => getUserJoinedProjectList(id), - staleTime: 1 * 60 * 1000, - enabled: isLoggedIn, - }); - - return { userJoinedProjectListData: data?.data, isLoading }; -}; diff --git a/src/models/userProject.ts b/src/models/userProject.ts index e1aa1ab0..45cd7946 100644 --- a/src/models/userProject.ts +++ b/src/models/userProject.ts @@ -25,11 +25,6 @@ export interface ApiAppliedProject extends ApiCommonType { data: AppliedProject[] | null; } -export interface SelectUserProject { - acceptedProjects: JoinedProject[]; - ownProjects: JoinedProject[]; -} - -export interface ApiSelectUserProject extends ApiCommonType { - data: SelectUserProject; +export interface ApiUserProject extends ApiCommonType { + data: JoinedProject[]; } diff --git a/src/pages/user/customerService/faq/FAQ.styled.ts b/src/pages/user/customerService/faq/FAQ.styled.ts index cebc2b9a..5cdddc6b 100644 --- a/src/pages/user/customerService/faq/FAQ.styled.ts +++ b/src/pages/user/customerService/faq/FAQ.styled.ts @@ -23,11 +23,9 @@ export const ShowMoreFAQWrapper = styled.div``; export const ShowMoreFAQ = styled.button` width: 100%; - padding: 1.2rem 0; display: flex; justify-content: center; align-items: center; - gap: 0.5rem; font-weight: bold; font-size: 1rem; @@ -39,3 +37,26 @@ export const ShowMoreFAQ = styled.button` background: ${({ theme }) => theme.color.lightgrey}; } `; + +export const ShowMoreSpan = styled.span` + width: 100%; + padding: 1.2rem 0; + display: flex; + justify-content: center; + gap: 0.5rem; + @keyframes bounce { + 0% { + transform: translateY(0); + } + 50% { + transform: translateY(-3px); + } + 100% { + transform: translateY(0); + } + } + + &:hover { + animation: bounce 0.4s infinite; + } +`; diff --git a/src/pages/user/customerService/faq/FAQ.tsx b/src/pages/user/customerService/faq/FAQ.tsx index 42b9c8a2..d7d343dc 100644 --- a/src/pages/user/customerService/faq/FAQ.tsx +++ b/src/pages/user/customerService/faq/FAQ.tsx @@ -57,8 +57,10 @@ export default function FAQ() { type='button' onClick={() => setShowFAQ((prev) => prev + 10)} > - 더보기 - + + 더보기 + + diff --git a/src/pages/user/mypage/MyPage.tsx b/src/pages/user/mypage/MyPage.tsx index b1b6d72f..8b5f107a 100644 --- a/src/pages/user/mypage/MyPage.tsx +++ b/src/pages/user/mypage/MyPage.tsx @@ -20,7 +20,7 @@ const MyPage = () => { }, { label: '참여 프로젝트', - path: `${ROUTES.mypage}/${ROUTES.mypageJoinedProjects}`, + path: `${ROUTES.mypage}/${ROUTES.joinedProjects}`, icon: , }, { diff --git a/src/pages/user/userpage/UserPage.tsx b/src/pages/user/userpage/UserPage.tsx index 53e54e45..d070afe9 100644 --- a/src/pages/user/userpage/UserPage.tsx +++ b/src/pages/user/userpage/UserPage.tsx @@ -17,7 +17,12 @@ const UserPage = () => { }, { label: '참여 프로젝트', - path: `${ROUTES.userpage}/${userId}/${ROUTES.userJoinedProject}`, + path: `${ROUTES.userpage}/${userId}/${ROUTES.joinedProjects}`, + icon: , + }, + { + label: '기획 프로젝트', + path: `${ROUTES.userpage}/${userId}/${ROUTES.managedProjects}`, icon: , }, ]; diff --git a/src/routes/AppRoutes.tsx b/src/routes/AppRoutes.tsx index e83c68c1..2f4b65ca 100644 --- a/src/routes/AppRoutes.tsx +++ b/src/routes/AppRoutes.tsx @@ -92,8 +92,8 @@ const ActivityLogInquiries = lazy( const UserProfile = lazy( () => import('../components/user/userPage/userProfile/UserProfile') ); -const UserJoinProject = lazy( - () => import('../components/user/userPage/joinedProject/UserJoinProject') +const UserProjects = lazy( + () => import('../components/user/userPage/userProjectList/UserProjectList') ); const ModifyProject = lazy( () => import('../pages/user/modifyProject/ModifyProject') @@ -266,7 +266,7 @@ const AppRoutes = () => { ], }, { - path: ROUTES.mypageJoinedProjects, + path: ROUTES.joinedProjects, element: , }, { @@ -322,8 +322,12 @@ const AppRoutes = () => { children: [{ index: true, element: }], }, { - path: ROUTES.userJoinedProject, - element: , + path: ROUTES.joinedProjects, + element: , + }, + { + path: ROUTES.managedProjects, + element: , }, ], },