Skip to content

Commit a8ad2c2

Browse files
authored
Merge pull request #290 from manNomi/feat/univ-page
feat: 멘토/멘티 기능 개선 및 반응형 레이아웃 최적화
2 parents b06fc38 + 7befe65 commit a8ad2c2

File tree

48 files changed

+399
-149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+399
-149
lines changed

src/api/mentee/client/usePostApplyMentoring.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import { useRouter } from "next/navigation";
2-
31
import { axiosInstance } from "@/utils/axiosInstance";
42

53
import { QueryKeys } from "./queryKey";
64

7-
import { customConfirm } from "@/lib/zustand/useConfirmModalStore";
8-
import { IconCheck } from "@/public/svgs/mentor";
9-
import { useMutation, useQueryClient } from "@tanstack/react-query";
105
import { toast } from "@/lib/zustand/useToastStore";
6+
import { useMutation, useQueryClient } from "@tanstack/react-query";
117

128
interface UsePostApplyMentoringRequest {
139
mentorId: number;
@@ -22,27 +18,14 @@ const postApplyMentoring = async (body: UsePostApplyMentoringRequest): Promise<U
2218
};
2319

2420
const usePostApplyMentoring = () => {
25-
const router = useRouter();
2621
const queryClient = useQueryClient();
2722
return useMutation({
2823
mutationFn: postApplyMentoring,
2924
onSuccess: async () => {
3025
// 멘토링 신청 후 멘토 목록을 새로고침
3126
await queryClient.invalidateQueries({ queryKey: [QueryKeys.applyMentoringList] });
32-
const ok = await customConfirm({
33-
title: "멘토 신청",
34-
content: "멘토 신청이 완료되었습니다.",
35-
icon: IconCheck,
36-
rejectMessage: "홈으로",
37-
approveMessage: "다른 멘토 찾기",
38-
});
39-
if (ok) {
40-
router.push("/mentor");
41-
return;
42-
}
43-
router.push("/");
4427
},
45-
onError: (error) => {
28+
onError: () => {
4629
toast.error("멘토 신청에 실패했습니다. 다시 시도해주세요.");
4730
},
4831
});

src/api/mentor/client/usePatchApprovalStatus.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ import { MentoringApprovalStatus } from "@/types/mentor";
99
import { customAlert } from "@/lib/zustand/useAlertModalStore";
1010
import { customConfirm } from "@/lib/zustand/useConfirmModalStore";
1111
import { IconSmile, IconUnSmile } from "@/public/svgs/mentor";
12-
import { QueryClient, useMutation, useQueryClient } from "@tanstack/react-query";
12+
import { useMutation, useQueryClient } from "@tanstack/react-query";
1313

1414
interface UsePatchApprovalStatusRequest {
1515
status: MentoringApprovalStatus;
1616
mentoringId: number; // 멘토링 ID
1717
}
1818
interface UsePatchApprovalStatusResponse {
1919
mentoringId: number; // 멘토링 ID
20+
chatRoomId: number; // 채팅방 ID
2021
}
2122

2223
const patchApprovalStatus = async (props: UsePatchApprovalStatusRequest): Promise<UsePatchApprovalStatusResponse> => {
@@ -56,7 +57,7 @@ const usePatchApprovalStatus = () => {
5657
approveMessage: "1:1 채팅 바로가기",
5758
});
5859
if (ok) {
59-
router.push(`/mentor/chat/${data.mentoringId}`);
60+
router.push(`/mentor/chat/${data.chatRoomId}`);
6061
}
6162
}
6263
},

src/api/my/client/useGetMyInfo.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ export interface MentorInfo extends BaseUserInfo {
2020
attendedUniversity: string;
2121
}
2222

23-
export type MyInfoResponse = MenteeInfo | MentorInfo;
23+
export interface AdminInfo extends BaseUserInfo {
24+
role: UserRole.ADMIN;
25+
attendedUniversity: string;
26+
}
27+
28+
export type MyInfoResponse = MenteeInfo | MentorInfo | AdminInfo;
2429

2530
// --- API 호출 함수 ---
2631
const getMyInfo = async (): Promise<MyInfoResponse> => {

src/api/news/client/usePostArticleLike.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ const usePostArticleLike = (userId: number | null) => {
6464

6565
// 4. onError: 실패 시 이전 상태로 롤백합니다.
6666
onError: (err, variables, context) => {
67-
console.log(err);
6867
if (context?.previousArticleList) {
6968
queryClient.setQueryData<Article[]>(queryKey, context.previousArticleList);
7069
}

src/api/news/client/usePutModifyArticle.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { QueryKeys } from "./queryKey";
88

99
import { Article } from "@/types/news";
1010

11-
import { useMutation, useQueryClient } from "@tanstack/react-query";
1211
import { toast } from "@/lib/zustand/useToastStore";
12+
import { useMutation, useQueryClient } from "@tanstack/react-query";
1313

1414
type UsePutModifyArticleRequest = {
1515
body: ArticleFormData & { isImageDeleted?: boolean };
@@ -68,7 +68,6 @@ const usePutModifyArticle = (userId: number | null) => {
6868
return { previousArticleList };
6969
},
7070
onError: (error, variables, context) => {
71-
console.log();
7271
const errorMessage = error.response?.data?.message || "";
7372
if (context?.previousArticleList) {
7473
queryClient.setQueryData(queryKey, context.previousArticleList);

src/app/community/[boardCode]/PostWriteButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const PostWriteButton = ({ onClick }: PostWriteButtonProps) => {
2929

3030
return (
3131
<div
32-
className={`fixed bottom-16 flex w-full max-w-[600px] flex-col items-center transition-transform duration-300 ease-in-out ${isVisible ? "translate-y-0" : "translate-y-[calc(100%+66px)]"} `}
32+
className={`max-w-app fixed bottom-16 flex w-full flex-col items-center transition-transform duration-300 ease-in-out ${isVisible ? "translate-y-0" : "translate-y-[calc(100%+66px)]"} `}
3333
>
3434
<button
3535
className="relative flex h-14 w-14 cursor-pointer items-center justify-center rounded-full bg-primary shadow-[0px_4px_30px_rgba(0,0,0,0.15)]"

src/app/community/[boardCode]/[postId]/CommentInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const CommentInput = ({ postId, curSelectedComment, setCurSelectedComment, refre
3838
};
3939

4040
return (
41-
<div className="fixed bottom-14 flex w-full min-w-[360px] max-w-[600px] items-center gap-3 border-t border-[#ececec] bg-k-0 p-2">
41+
<div className="min-w-app max-w-app fixed bottom-14 flex w-full items-center gap-3 border-t border-[#ececec] bg-k-0 p-2">
4242
<div className="w-full">
4343
{curSelectedComment && (
4444
<div className="flex h-10 w-full items-center justify-between rounded-t-lg bg-[#e2e2e2] px-2.5 pb-2.5 pt-3">

src/app/community/[boardCode]/[postId]/modify/PostModifyForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ type CustomTopDetailNavigationProps = {
151151
};
152152

153153
const CustomTopDetailNavigation = ({ routeBack, submitPost }: CustomTopDetailNavigationProps) => (
154-
<div className="fixed top-0 z-30 box-border flex h-14 w-full max-w-[600px] items-center justify-between bg-white px-5">
154+
<div className="max-w-app fixed top-0 z-30 box-border flex h-14 w-full items-center justify-between bg-white px-5">
155155
<button className="min-w-6 cursor-pointer" onClick={routeBack} type="button" aria-label="뒤로 가기">
156156
<IconArrowBackFilled />
157157
</button>

src/app/mentor/_ui/MentorClient/index.tsx

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use client";
22

3+
import { useState } from "react";
4+
35
import { tokenParse } from "@/utils/jwtUtils";
46

57
import CloudSpinnerPage from "@/components/ui/CloudSpinnerPage";
@@ -14,16 +16,46 @@ import useAuthStore from "@/lib/zustand/useAuthStore";
1416

1517
const MentorClient = () => {
1618
const { isLoading, accessToken } = useAuthStore();
17-
const isMentor = tokenParse(accessToken)?.role === UserRole.MENTOR;
19+
const parsedToken = tokenParse(accessToken);
20+
const userRole = parsedToken?.role;
21+
const isMentor = userRole === UserRole.MENTOR || userRole === UserRole.ADMIN;
22+
const isAdmin = userRole === UserRole.ADMIN;
23+
24+
// 어드민 전용: 뷰 전환 상태 (true: 멘토 뷰, false: 멘티 뷰)
25+
const [showMentorView, setShowMentorView] = useState<boolean>(true);
26+
27+
if (isLoading || !accessToken) return <CloudSpinnerPage />; // 로딩 중일 때 스피너 표시
28+
29+
// 어드민이 아닌 경우 기존 로직대로
30+
const shouldShowMentorView = isAdmin ? showMentorView : isMentor;
1831

19-
if (isLoading) return <CloudSpinnerPage />; // 로딩 중일 때 스피너 표시
2032
return (
2133
<>
22-
{isMentor ? (
34+
{/* 어드민 전용 뷰 전환 버튼 */}
35+
{isAdmin && (
36+
<div className="mb-4 flex gap-2">
37+
<button
38+
onClick={() => setShowMentorView(true)}
39+
className={`flex-1 rounded-lg px-4 py-2.5 text-sm font-semibold transition-colors ${
40+
showMentorView ? "bg-primary text-white" : "border border-k-200 bg-white text-k-600 hover:bg-k-50"
41+
}`}
42+
>
43+
멘토 페이지 보기
44+
</button>
45+
<button
46+
onClick={() => setShowMentorView(false)}
47+
className={`flex-1 rounded-lg px-4 py-2.5 text-sm font-semibold transition-colors ${
48+
!showMentorView ? "bg-primary text-white" : "border border-k-200 bg-white text-k-600 hover:bg-k-50"
49+
}`}
50+
>
51+
멘티 페이지 보기
52+
</button>
53+
</div>
54+
)}
55+
56+
{shouldShowMentorView ? (
2357
// 멘토페이지
24-
<>
25-
<MentorPage />
26-
</>
58+
<MentorPage />
2759
) : (
2860
// 멘티페이지
2961
<>

src/app/mentor/chat/[chatId]/_ui/ChatContent/_hooks/useChatListHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ const useChatListHandler = (chatId: number) => {
7777
if (content.trim() === "") return; // 빈 메시지 전송 방지
7878

7979
if (clientRef.current?.active && connectionStatus === ConnectionStatus.Connected) {
80+
// WebSocket으로 메시지 전송
8081
clientRef.current.publish({
8182
destination: `/publish/chat/${chatId}`,
8283
body: JSON.stringify({ content, senderId }),

0 commit comments

Comments
 (0)