diff --git a/apps/web/public/svgs/placeholders/image-placeholder.svg b/apps/web/public/svgs/placeholders/image-placeholder.svg new file mode 100644 index 00000000..97189bfe --- /dev/null +++ b/apps/web/public/svgs/placeholders/image-placeholder.svg @@ -0,0 +1,7 @@ + + + + + + Image unavailable + diff --git a/apps/web/src/apis/Auth/postAppleAuth.ts b/apps/web/src/apis/Auth/postAppleAuth.ts index 900d27d5..93249feb 100644 --- a/apps/web/src/apis/Auth/postAppleAuth.ts +++ b/apps/web/src/apis/Auth/postAppleAuth.ts @@ -11,36 +11,36 @@ import { type AppleAuthRequest, type AppleAuthResponse, authApi } from "./api"; * @description 애플 로그인을 위한 useMutation 커스텀 훅 */ const usePostAppleAuth = () => { - const router = useRouter(); - const searchParams = useSearchParams(); + const router = useRouter(); + const searchParams = useSearchParams(); - return useMutation({ - mutationFn: (data) => authApi.postAppleAuth(data), - onSuccess: (data) => { - if (data.isRegistered) { - // 기존 회원일 시 - Zustand persist가 자동으로 localStorage에 저장 - // refreshToken은 서버에서 HTTP-only 쿠키로 자동 설정됨 - useAuthStore.getState().setAccessToken(data.accessToken); + return useMutation({ + mutationFn: (data) => authApi.postAppleAuth(data), + onSuccess: (data) => { + if (data.isRegistered) { + // 기존 회원일 시 - Zustand persist가 자동으로 localStorage에 저장 + // refreshToken은 서버에서 HTTP-only 쿠키로 자동 설정됨 + useAuthStore.getState().setAccessToken(data.accessToken); - // 안전한 리다이렉트 처리 - 오픈 리다이렉트 방지 - const redirectParam = searchParams.get("redirect"); - const safeRedirect = validateSafeRedirect(redirectParam); + // 안전한 리다이렉트 처리 - 오픈 리다이렉트 방지 + const redirectParam = searchParams.get("redirect"); + const safeRedirect = validateSafeRedirect(redirectParam); - toast.success("로그인에 성공했습니다."); + toast.success("로그인에 성공했습니다."); - setTimeout(() => { - router.push(safeRedirect); - }, 100); - } else { - // 새로운 회원일 시 - 회원가입 페이지로 이동 - router.push(`/sign-up?token=${data.signUpToken}`); - } - }, - onError: () => { - toast.error("애플 로그인 중 오류가 발생했습니다. 다시 시도해주세요."); - router.push("/login"); - }, - }); + setTimeout(() => { + router.push(safeRedirect); + }, 100); + } else { + // 새로운 회원일 시 - 회원가입 페이지로 이동 + router.push(`/sign-up?token=${data.signUpToken}`); + } + }, + onError: () => { + toast.error("애플 로그인 중 오류가 발생했습니다. 다시 시도해주세요."); + router.push("/login"); + }, + }); }; export default usePostAppleAuth; diff --git a/apps/web/src/apis/Auth/postKakaoAuth.ts b/apps/web/src/apis/Auth/postKakaoAuth.ts index 40894959..8f641666 100644 --- a/apps/web/src/apis/Auth/postKakaoAuth.ts +++ b/apps/web/src/apis/Auth/postKakaoAuth.ts @@ -11,37 +11,37 @@ import { authApi, type KakaoAuthRequest, type KakaoAuthResponse } from "./api"; * @description 카카오 로그인을 위한 useMutation 커스텀 훅 */ const usePostKakaoAuth = () => { - const { setAccessToken } = useAuthStore(); - const router = useRouter(); - const searchParams = useSearchParams(); + const { setAccessToken } = useAuthStore(); + const router = useRouter(); + const searchParams = useSearchParams(); - return useMutation({ - mutationFn: (data) => authApi.postKakaoAuth(data), - onSuccess: (data) => { - if (data.isRegistered) { - // 기존 회원일 시 - Zustand persist가 자동으로 localStorage에 저장 - // refreshToken은 서버에서 HTTP-only 쿠키로 자동 설정됨 - setAccessToken(data.accessToken); + return useMutation({ + mutationFn: (data) => authApi.postKakaoAuth(data), + onSuccess: (data) => { + if (data.isRegistered) { + // 기존 회원일 시 - Zustand persist가 자동으로 localStorage에 저장 + // refreshToken은 서버에서 HTTP-only 쿠키로 자동 설정됨 + setAccessToken(data.accessToken); - // 안전한 리다이렉트 처리 - 오픈 리다이렉트 방지 - const redirectParam = searchParams.get("redirect"); - const safeRedirect = validateSafeRedirect(redirectParam); + // 안전한 리다이렉트 처리 - 오픈 리다이렉트 방지 + const redirectParam = searchParams.get("redirect"); + const safeRedirect = validateSafeRedirect(redirectParam); - toast.success("로그인에 성공했습니다."); + toast.success("로그인에 성공했습니다."); - setTimeout(() => { - router.push(safeRedirect); - }, 100); - } else { - // 새로운 회원일 시 - 회원가입 페이지로 이동 - router.push(`/sign-up?token=${data.signUpToken}`); - } - }, - onError: () => { - toast.error("카카오 로그인 중 오류가 발생했습니다. 다시 시도해주세요."); - router.push("/login"); - }, - }); + setTimeout(() => { + router.push(safeRedirect); + }, 100); + } else { + // 새로운 회원일 시 - 회원가입 페이지로 이동 + router.push(`/sign-up?token=${data.signUpToken}`); + } + }, + onError: () => { + toast.error("카카오 로그인 중 오류가 발생했습니다. 다시 시도해주세요."); + router.push("/login"); + }, + }); }; export default usePostKakaoAuth; diff --git a/apps/web/src/apis/universities/server/getRecommendedUniversity.ts b/apps/web/src/apis/universities/server/getRecommendedUniversity.ts index 3950cfe5..b3f7ae70 100644 --- a/apps/web/src/apis/universities/server/getRecommendedUniversity.ts +++ b/apps/web/src/apis/universities/server/getRecommendedUniversity.ts @@ -4,15 +4,15 @@ import serverFetch from "@/utils/serverFetchUtil"; type GetRecommendedUniversityResponse = { recommendedUniversities: ListUniversity[] }; const getRecommendedUniversity = async () => { - const endpoint = "/univ-apply-infos/recommend"; + const endpoint = "/univ-apply-infos/recommend"; - const res = await serverFetch(endpoint); + const res = await serverFetch(endpoint); - if (!res.ok) { - console.error(`Failed to fetch recommended universities:`, res.error); - } + if (!res.ok) { + console.error(`Failed to fetch recommended universities:`, res.error); + } - return res; + return res; }; export default getRecommendedUniversity; diff --git a/apps/web/src/apis/universities/server/getSearchUniversitiesByFilter.ts b/apps/web/src/apis/universities/server/getSearchUniversitiesByFilter.ts index 2b6ba386..3fdd37c4 100644 --- a/apps/web/src/apis/universities/server/getSearchUniversitiesByFilter.ts +++ b/apps/web/src/apis/universities/server/getSearchUniversitiesByFilter.ts @@ -3,60 +3,58 @@ import type { CountryCode, LanguageTestType, ListUniversity } from "@/types/univ import serverFetch from "@/utils/serverFetchUtil"; interface UniversitySearchResponse { - univApplyInfoPreviews: ListUniversity[]; + univApplyInfoPreviews: ListUniversity[]; } /** * 필터 검색에 사용될 파라미터 타입 */ export interface UniversitySearchFilterParams { - languageTestType?: LanguageTestType; - testScore?: number; - countryCode?: CountryCode[]; + languageTestType?: LanguageTestType; + testScore?: number; + countryCode?: CountryCode[]; } export const getSearchUniversitiesByFilter = async ( - filters: UniversitySearchFilterParams, + filters: UniversitySearchFilterParams, ): Promise => { - const params = new URLSearchParams(); - - if (filters.languageTestType) { - params.append("languageTestType", filters.languageTestType); - } - if (filters.testScore !== undefined) { - params.append("testScore", String(filters.testScore)); - } - // countryCode는 여러 개일 수 있으므로 각각 append 해줍니다. - if (filters.countryCode) { - filters.countryCode.forEach((code) => params.append("countryCode", code)); - } - - // 필터 값이 하나도 없으면 빈 배열을 반환합니다. - if (params.size === 0) { - return []; - } - - const endpoint = `/univ-apply-infos/search/filter?${params.toString()}`; - const response = await serverFetch(endpoint); - - if (!response.ok) { - console.error(`Failed to search universities by filter:`, response.error); - return []; - } - - return response.data.univApplyInfoPreviews; + const params = new URLSearchParams(); + + if (filters.languageTestType) { + params.append("languageTestType", filters.languageTestType); + } + if (filters.testScore !== undefined) { + params.append("testScore", String(filters.testScore)); + } + // countryCode는 여러 개일 수 있으므로 각각 append 해줍니다. + if (filters.countryCode) { + filters.countryCode.forEach((code) => params.append("countryCode", code)); + } + + // 필터 값이 하나도 없으면 빈 배열을 반환합니다. + if (params.size === 0) { + return []; + } + + const endpoint = `/univ-apply-infos/search/filter?${params.toString()}`; + const response = await serverFetch(endpoint); + + if (!response.ok) { + console.error(`Failed to search universities by filter:`, response.error); + return []; + } + + return response.data.univApplyInfoPreviews; }; -export const getSearchUniversitiesAllRegions = async (): Promise< - ListUniversity[] -> => { - const endpoint = `/univ-apply-infos/search/filter`; - const response = await serverFetch(endpoint); +export const getSearchUniversitiesAllRegions = async (): Promise => { + const endpoint = `/univ-apply-infos/search/filter`; + const response = await serverFetch(endpoint); - if (!response.ok) { - console.error(`Failed to fetch all regions universities:`, response.error); - return []; - } + if (!response.ok) { + console.error(`Failed to fetch all regions universities:`, response.error); + return []; + } - return response.data.univApplyInfoPreviews; + return response.data.univApplyInfoPreviews; }; diff --git a/apps/web/src/apis/universities/server/getSearchUniversitiesByText.ts b/apps/web/src/apis/universities/server/getSearchUniversitiesByText.ts index 92f4b362..dd20d096 100644 --- a/apps/web/src/apis/universities/server/getSearchUniversitiesByText.ts +++ b/apps/web/src/apis/universities/server/getSearchUniversitiesByText.ts @@ -3,54 +3,48 @@ import serverFetch from "@/utils/serverFetchUtil"; // --- 타입 정의 --- interface UniversitySearchResponse { - univApplyInfoPreviews: ListUniversity[]; + univApplyInfoPreviews: ListUniversity[]; } -export const getUniversitiesByText = async ( - value: string, -): Promise => { - if (value === null || value === undefined) { - return []; - } - const endpoint = `/univ-apply-infos/search/text?value=${encodeURIComponent(value)}`; - const response = await serverFetch(endpoint); - - if (!response.ok) { - console.error( - `Failed to search universities by text (value: "${value}"):`, - response.error, - ); - return []; - } - - return response.data.univApplyInfoPreviews; +export const getUniversitiesByText = async (value: string): Promise => { + if (value === null || value === undefined) { + return []; + } + const endpoint = `/univ-apply-infos/search/text?value=${encodeURIComponent(value)}`; + const response = await serverFetch(endpoint); + + if (!response.ok) { + console.error(`Failed to search universities by text (value: "${value}"):`, response.error); + return []; + } + + return response.data.univApplyInfoPreviews; }; export const getAllUniversities = async (): Promise => { - return getUniversitiesByText(""); + return getUniversitiesByText(""); }; -export const getCategorizedUniversities = - async (): Promise => { - // 1. 단 한 번의 API 호출로 모든 대학 데이터를 가져옵니다. - const allUniversities = await getAllUniversities(); - - const categorizedList: AllRegionsUniversityList = { - [RegionEnumExtend.ALL]: allUniversities, - [RegionEnumExtend.AMERICAS]: [], - [RegionEnumExtend.EUROPE]: [], - [RegionEnumExtend.ASIA]: [], - [RegionEnumExtend.CHINA]: [], - }; - if (!allUniversities) return categorizedList; - - for (const university of allUniversities) { - const region = university.region as RegionEnumExtend; // API 응답의 region 타입을 enum으로 간주 - - if (region && Object.hasOwn(categorizedList, region)) { - categorizedList[region].push(university); - } - } - - return categorizedList; - }; +export const getCategorizedUniversities = async (): Promise => { + // 1. 단 한 번의 API 호출로 모든 대학 데이터를 가져옵니다. + const allUniversities = await getAllUniversities(); + + const categorizedList: AllRegionsUniversityList = { + [RegionEnumExtend.ALL]: allUniversities, + [RegionEnumExtend.AMERICAS]: [], + [RegionEnumExtend.EUROPE]: [], + [RegionEnumExtend.ASIA]: [], + [RegionEnumExtend.CHINA]: [], + }; + if (!allUniversities) return categorizedList; + + for (const university of allUniversities) { + const region = university.region as RegionEnumExtend; // API 응답의 region 타입을 enum으로 간주 + + if (region && Object.hasOwn(categorizedList, region)) { + categorizedList[region].push(university); + } + } + + return categorizedList; +}; diff --git a/apps/web/src/app/(home)/_ui/NewsSection/index.tsx b/apps/web/src/app/(home)/_ui/NewsSection/index.tsx index 1506b959..1a5c86e9 100644 --- a/apps/web/src/app/(home)/_ui/NewsSection/index.tsx +++ b/apps/web/src/app/(home)/_ui/NewsSection/index.tsx @@ -1,7 +1,7 @@ "use client"; -import Image from "next/image"; import Link from "next/link"; +import Image from "@/components/ui/FallbackImage"; import { IconLoveLetter } from "@/public/svgs/home"; import type { News } from "@/types/news"; import useSectionHandler from "./_hooks/useSectionHadnler"; diff --git a/apps/web/src/app/(home)/_ui/PopularUniversitySection/_ui/PopularUniversityCard.tsx b/apps/web/src/app/(home)/_ui/PopularUniversitySection/_ui/PopularUniversityCard.tsx index 87f4b370..fa4b1c81 100644 --- a/apps/web/src/app/(home)/_ui/PopularUniversitySection/_ui/PopularUniversityCard.tsx +++ b/apps/web/src/app/(home)/_ui/PopularUniversitySection/_ui/PopularUniversityCard.tsx @@ -1,5 +1,5 @@ -import Image from "next/image"; import Link from "next/link"; +import Image from "@/components/ui/FallbackImage"; import type { ListUniversity } from "@/types/university"; import { convertImageUrl } from "@/utils/fileUtils"; diff --git a/apps/web/src/app/community/[boardCode]/PostCards.tsx b/apps/web/src/app/community/[boardCode]/PostCards.tsx index fc3b8f74..5b2155ff 100644 --- a/apps/web/src/app/community/[boardCode]/PostCards.tsx +++ b/apps/web/src/app/community/[boardCode]/PostCards.tsx @@ -1,9 +1,9 @@ "use client"; import { useVirtualizer } from "@tanstack/react-virtual"; -import Image from "next/image"; import Link from "next/link"; import { useRef } from "react"; +import Image from "@/components/ui/FallbackImage"; import { IconPostLikeOutline } from "@/public/svgs"; import { IconCommunication } from "@/public/svgs/community"; import { IconSolidConnentionLogo } from "@/public/svgs/mentor"; @@ -102,6 +102,7 @@ export const PostCard = ({ post }: { post: ListPost }) => ( height={82} width={82} alt="게시글 사진" + fallbackSrc="/images/article-thumb.png" /> ) : (
diff --git a/apps/web/src/app/community/[boardCode]/[postId]/CommentSection.tsx b/apps/web/src/app/community/[boardCode]/[postId]/CommentSection.tsx index a24cce9c..27c42115 100644 --- a/apps/web/src/app/community/[boardCode]/[postId]/CommentSection.tsx +++ b/apps/web/src/app/community/[boardCode]/[postId]/CommentSection.tsx @@ -1,10 +1,10 @@ "use client"; import clsx from "clsx"; -import Image from "next/image"; import { useState } from "react"; import { useDeleteComment } from "@/apis/community"; import Dropdown from "@/components/ui/Dropdown"; +import Image from "@/components/ui/FallbackImage"; import { IconMoreVertFilled, IconSubComment } from "@/public/svgs"; import type { Comment as CommentType, CommunityUser } from "@/types/community"; import { convertISODateToDateTime } from "@/utils/datetimeUtils"; diff --git a/apps/web/src/app/community/[boardCode]/[postId]/Content.tsx b/apps/web/src/app/community/[boardCode]/[postId]/Content.tsx index 68193200..92d3fd29 100644 --- a/apps/web/src/app/community/[boardCode]/[postId]/Content.tsx +++ b/apps/web/src/app/community/[boardCode]/[postId]/Content.tsx @@ -1,7 +1,7 @@ import type { Metadata } from "next"; -import Image from "next/image"; import { useEffect, useState } from "react"; import { useDeleteLike, usePostLike } from "@/apis/community"; +import Image from "@/components/ui/FallbackImage"; import LinkifyText from "@/components/ui/LinkifyText"; import { IconCloseFilled, IconPostLikeFilled, IconPostLikeOutline } from "@/public/svgs"; import { IconCommunication } from "@/public/svgs/community"; diff --git a/apps/web/src/app/mentor/[id]/_ui/MentorDetialContent/_ui/MentorArticle/index.tsx b/apps/web/src/app/mentor/[id]/_ui/MentorDetialContent/_ui/MentorArticle/index.tsx index 00a7d2c9..938c0382 100644 --- a/apps/web/src/app/mentor/[id]/_ui/MentorDetialContent/_ui/MentorArticle/index.tsx +++ b/apps/web/src/app/mentor/[id]/_ui/MentorDetialContent/_ui/MentorArticle/index.tsx @@ -1,6 +1,6 @@ "use client"; -import Image from "next/image"; +import Image from "@/components/ui/FallbackImage"; import { IconLikeFill, IconLikeNotFill } from "@/public/svgs/mentor"; import type { Article } from "@/types/news"; import { convertUploadedImageUrl } from "@/utils/fileUtils"; diff --git a/apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_ui/ChatInputBar/index.tsx b/apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_ui/ChatInputBar/index.tsx index 4f88e987..53346ffd 100644 --- a/apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_ui/ChatInputBar/index.tsx +++ b/apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_ui/ChatInputBar/index.tsx @@ -1,6 +1,6 @@ import clsx from "clsx"; -import Image from "next/image"; import { useState } from "react"; +import Image from "@/components/ui/FallbackImage"; import { IconAlbum, IconDirectMessage, IconFile, IconPlusK200, IconXWhite } from "@/public/svgs/mentor"; import { downloadLocalFile } from "@/utils/fileUtils"; import useFileHandler from "./_hooks/useFileHandler"; diff --git a/apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_ui/ChatMessageBox/index.tsx b/apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_ui/ChatMessageBox/index.tsx index fa8aa3f4..0c3815ad 100644 --- a/apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_ui/ChatMessageBox/index.tsx +++ b/apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_ui/ChatMessageBox/index.tsx @@ -1,4 +1,4 @@ -import Image from "next/image"; +import Image from "@/components/ui/FallbackImage"; import ProfileWithBadge from "@/components/ui/ProfileWithBadge"; import type { ChatMessage } from "@/types/chat"; import { formatTime } from "@/utils/datetimeUtils"; diff --git a/apps/web/src/app/my/modify/_ui/ModifyContent/_ui/ImageInputFiled/index.tsx b/apps/web/src/app/my/modify/_ui/ModifyContent/_ui/ImageInputFiled/index.tsx index 072280b4..abaaf0fb 100644 --- a/apps/web/src/app/my/modify/_ui/ModifyContent/_ui/ImageInputFiled/index.tsx +++ b/apps/web/src/app/my/modify/_ui/ModifyContent/_ui/ImageInputFiled/index.tsx @@ -1,4 +1,4 @@ -import Image from "next/image"; +import Image from "@/components/ui/FallbackImage"; import { IconAlbumWhite, IconSolidConnectionSmallLogo } from "@/public/svgs/my"; import useImageInputHandler from "./_hooks/useImageInputHandler"; diff --git a/apps/web/src/app/my/modify/_ui/ModifyContent/index.tsx b/apps/web/src/app/my/modify/_ui/ModifyContent/index.tsx index 197ca9d7..a6811124 100644 --- a/apps/web/src/app/my/modify/_ui/ModifyContent/index.tsx +++ b/apps/web/src/app/my/modify/_ui/ModifyContent/index.tsx @@ -11,85 +11,64 @@ import InputField from "./_ui/InputFiled"; import ReadOnlyField from "./_ui/ReadOnlyField"; const ModifyContent = () => { - const { methods, myInfo, onSubmit } = useModifyUserHookform(); + const { methods, myInfo, onSubmit } = useModifyUserHookform(); - const defaultUniversity: string = - (myInfo?.role === UserRole.MENTOR || myInfo?.role === UserRole.ADMIN) && - myInfo.attendedUniversity - ? myInfo.attendedUniversity - : "인하대학교"; + const defaultUniversity: string = + (myInfo?.role === UserRole.MENTOR || myInfo?.role === UserRole.ADMIN) && myInfo.attendedUniversity + ? myInfo.attendedUniversity + : "인하대학교"; - const { - handleSubmit, - formState: { isValid, isDirty }, - } = methods; + const { + handleSubmit, + formState: { isValid, isDirty }, + } = methods; - if (!myInfo) { - return ; - } - return ( - -
-
- {/* Profile Image Section */} - + if (!myInfo) { + return ; + } + return ( + +
+ + {/* Profile Image Section */} + - {/* Form Fields */} -
- {/* 닉네임 - 수정 가능 */} - + {/* Form Fields */} +
+ {/* 닉네임 - 수정 가능 */} + - {/* 출신학교 - 읽기 전용 */} - + {/* 출신학교 - 읽기 전용 */} + - {/* 수학 학교 - 읽기 전용 */} - + {/* 수학 학교 - 읽기 전용 */} + - {/* 사용자 유형 - 읽기 전용 */} - -
+ {/* 사용자 유형 - 읽기 전용 */} + +
- {/* Submit Button */} -
- -
- -
-
- ); + {/* Submit Button */} +
+ +
+ +
+
+ ); }; export default ModifyContent; diff --git a/apps/web/src/app/university/(home)/_ui/HomeUniversityCard.tsx b/apps/web/src/app/university/(home)/_ui/HomeUniversityCard.tsx index 5c37567d..4ded9fa8 100644 --- a/apps/web/src/app/university/(home)/_ui/HomeUniversityCard.tsx +++ b/apps/web/src/app/university/(home)/_ui/HomeUniversityCard.tsx @@ -1,7 +1,7 @@ "use client"; -import Image from "next/image"; import Link from "next/link"; +import Image from "@/components/ui/FallbackImage"; import type { HomeUniversityInfo } from "@/constants/university"; @@ -25,11 +25,7 @@ const HomeUniversityCard = ({ university }: HomeUniversityCardProps) => { width={48} height={48} className="h-12 w-12 object-contain" - onError={(e) => { - // 이미지 로드 실패 시 기본 텍스트 표시 - const target = e.target as HTMLImageElement; - target.style.display = "none"; - }} + fallbackSrc="/svgs/placeholders/university-logo-placeholder.svg" />
@@ -47,13 +43,7 @@ const HomeUniversityCard = ({ university }: HomeUniversityCardProps) => { xmlns="http://www.w3.org/2000/svg" className="text-k-400 group-hover:text-primary" > - + diff --git a/apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/_ui/LanguageSection.tsx b/apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/_ui/LanguageSection.tsx index 1f677b02..4297e353 100644 --- a/apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/_ui/LanguageSection.tsx +++ b/apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/_ui/LanguageSection.tsx @@ -1,6 +1,6 @@ "use client"; -import Image from "next/image"; +import Image from "@/components/ui/FallbackImage"; import LinkifyText from "@/components/ui/LinkifyText"; import type { LanguageRequirement } from "@/types/university"; import { formatLanguageTestName, getLanguageTestLogo } from "@/utils/languageUtils"; @@ -48,7 +48,7 @@ const Language = ({ name, logoUrl, score }: { name: string; logoUrl: string; sco
{name}
- 어학시험 + 어학시험
{score}
diff --git a/apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/_ui/TitleSection.tsx b/apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/_ui/TitleSection.tsx index 07f25f9e..7f3002b3 100644 --- a/apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/_ui/TitleSection.tsx +++ b/apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/_ui/TitleSection.tsx @@ -1,4 +1,4 @@ -import Image from "next/image"; +import Image from "@/components/ui/FallbackImage"; interface TitleSectionProps { logoUrl: string; @@ -10,7 +10,14 @@ const TitleSection = ({ logoUrl, title, subTitle }: TitleSectionProps) => { return (
- 대학 로고 + 대학 로고
{title} {subTitle} diff --git a/apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/index.tsx b/apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/index.tsx index 88119af9..df98753e 100644 --- a/apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/index.tsx +++ b/apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/index.tsx @@ -1,4 +1,4 @@ -import Image from "next/image"; +import Image from "@/components/ui/FallbackImage"; import LinkifyText from "@/components/ui/LinkifyText"; import type { University } from "@/types/university"; import { convertImageUrl } from "@/utils/fileUtils"; @@ -21,7 +21,13 @@ const UniversityDetail = ({ university, koreanName }: UniversityDetailProps) =>
- 대학 이미지 + 대학 이미지
- uni.koreanName.toLowerCase().includes(searchLower) || uni.country.toLowerCase().includes(searchLower), + (uni) => uni.koreanName.toLowerCase().includes(searchLower) || uni.country.toLowerCase().includes(searchLower), ); } diff --git a/apps/web/src/app/university/[homeUniversity]/search/_ui/SearchPageContent.tsx b/apps/web/src/app/university/[homeUniversity]/search/_ui/SearchPageContent.tsx index afb4e40a..80050f0a 100644 --- a/apps/web/src/app/university/[homeUniversity]/search/_ui/SearchPageContent.tsx +++ b/apps/web/src/app/university/[homeUniversity]/search/_ui/SearchPageContent.tsx @@ -6,18 +6,16 @@ import { useRouter } from "next/navigation"; import { useMemo, useState } from "react"; import { Controller, type SubmitHandler, useForm } from "react-hook-form"; import { z } from "zod"; - -import { IconSearch } from "@/public/svgs/search"; +import CustomDropdown from "@/app/university/CustomDropdown"; import { COUNTRY_CODE_MAP, LANGUAGE_TEST_TYPE_MAP, REGION_TO_COUNTRIES_MAP, REGIONS_SEARCH, } from "@/constants/university"; +import { IconSearch } from "@/public/svgs/search"; import { CountryCode, LanguageTestType } from "@/types/university"; -import CustomDropdown from "@/app/university/CustomDropdown"; - // Zod 스키마 const searchSchema = z.object({ searchText: z.string().optional(), diff --git a/apps/web/src/app/university/[homeUniversity]/search/page.tsx b/apps/web/src/app/university/[homeUniversity]/search/page.tsx index f35476c1..960bc518 100644 --- a/apps/web/src/app/university/[homeUniversity]/search/page.tsx +++ b/apps/web/src/app/university/[homeUniversity]/search/page.tsx @@ -49,7 +49,10 @@ const SearchPage = async ({ params }: PageProps) => { return ( <> - +

오직 나를 위한

diff --git a/apps/web/src/app/university/application/apply/DoneStep.tsx b/apps/web/src/app/university/application/apply/DoneStep.tsx index 271ce737..ca75cc34 100644 --- a/apps/web/src/app/university/application/apply/DoneStep.tsx +++ b/apps/web/src/app/university/application/apply/DoneStep.tsx @@ -1,7 +1,6 @@ -import Image from "next/image"; import { useRouter } from "next/navigation"; - import BlockBtn from "@/components/button/BlockBtn"; +import Image from "@/components/ui/FallbackImage"; const DoneStep = () => { const router = useRouter(); diff --git a/apps/web/src/app/university/list/[homeUniversityName]/page.tsx b/apps/web/src/app/university/list/[homeUniversityName]/page.tsx index b427c9f3..8126e5ea 100644 --- a/apps/web/src/app/university/list/[homeUniversityName]/page.tsx +++ b/apps/web/src/app/university/list/[homeUniversityName]/page.tsx @@ -41,7 +41,9 @@ export async function generateMetadata({ params }: PageProps): Promise const UniversityListPage = async ({ params }: PageProps) => { const { homeUniversityName } = await params; - const universityName = HOME_UNIVERSITY_SLUG_MAP[homeUniversityName as HomeUniversitySlug] as HomeUniversityName | undefined; + const universityName = HOME_UNIVERSITY_SLUG_MAP[homeUniversityName as HomeUniversitySlug] as + | HomeUniversityName + | undefined; if (!universityName) { notFound(); diff --git a/apps/web/src/app/university/score/example/gpa-cert/page.tsx b/apps/web/src/app/university/score/example/gpa-cert/page.tsx index bf61c317..afa10381 100644 --- a/apps/web/src/app/university/score/example/gpa-cert/page.tsx +++ b/apps/web/src/app/university/score/example/gpa-cert/page.tsx @@ -1,10 +1,9 @@ "use client"; -import Image from "next/image"; import Link from "next/link"; - import BlockBtn from "@/components/button/BlockBtn"; import TopDetailNavigation from "@/components/layout/TopDetailNavigation"; +import Image from "@/components/ui/FallbackImage"; const GpaCertExamplePage = () => { const closeWindow = () => { diff --git a/apps/web/src/app/university/score/example/lang-cert/page.tsx b/apps/web/src/app/university/score/example/lang-cert/page.tsx index cf63e0ae..0d2ab474 100644 --- a/apps/web/src/app/university/score/example/lang-cert/page.tsx +++ b/apps/web/src/app/university/score/example/lang-cert/page.tsx @@ -1,9 +1,8 @@ "use client"; -import Image from "next/image"; - import BlockBtn from "@/components/button/BlockBtn"; import TopDetailNavigation from "@/components/layout/TopDetailNavigation"; +import Image from "@/components/ui/FallbackImage"; const GpaCertExamplePage = () => { const closeWindow = () => { diff --git a/apps/web/src/components/home/NewsCards.tsx b/apps/web/src/components/home/NewsCards.tsx index 53e16944..85494c0a 100644 --- a/apps/web/src/components/home/NewsCards.tsx +++ b/apps/web/src/components/home/NewsCards.tsx @@ -1,5 +1,4 @@ -import Image from "next/image"; -import { useImageFallback } from "@/hooks/useImageFallback"; +import Image from "@/components/ui/FallbackImage"; import type { News } from "@/types/news"; @@ -8,8 +7,6 @@ type NewsCardsProps = { }; const NewsCards = ({ newsList }: NewsCardsProps) => { - const { getSrc, handleError } = useImageFallback("/svgs/placeholders/news-thumbnail-placeholder.svg"); - return (
{newsList.map((news) => ( @@ -17,11 +14,11 @@ const NewsCards = ({ newsList }: NewsCardsProps) => {
{news.title}
{news.title}
diff --git a/apps/web/src/components/login/signup/SignupSurvey.tsx b/apps/web/src/components/login/signup/SignupSurvey.tsx index fb59fab5..de393136 100644 --- a/apps/web/src/components/login/signup/SignupSurvey.tsx +++ b/apps/web/src/components/login/signup/SignupSurvey.tsx @@ -16,167 +16,157 @@ import SignupProfileScreen from "./SignupProfileScreen"; import SignupRegionScreen from "./SignupRegionScreen"; type SignupSurveyProps = { - baseNickname: string; - baseEmail: string; - baseProfileImageUrl: string; + baseNickname: string; + baseEmail: string; + baseProfileImageUrl: string; }; -const SignupSurvey = ({ - baseNickname, - baseEmail, - baseProfileImageUrl, -}: SignupSurveyProps) => { - const router = useRouter(); - const searchParams = useSearchParams(); - - const signUpToken = searchParams?.get("token"); - if (!signUpToken) { - router.push("/login"); - } - const { setAccessToken } = useAuthStore(); - const [curStage, setCurStage] = useState(1); - const [curProgress, setCurProgress] = useState(0); - - const [curPreparation, setCurPreparation] = - useState(null); - - const [region, setRegion] = useState( - null, - ); - const [countries, setCountries] = useState([]); - - const [nickname, setNickname] = useState(baseNickname); - const [profileImageFile, setProfileImageFile] = useState(null); - - const signUpMutation = usePostSignUp(); - const uploadImageMutation = useUploadProfileImagePublic(); - - useEffect(() => { - setCurProgress(((curStage - 1) / 3) * 100); - }, [curStage]); - - const createRegisterRequest = async (): Promise => { - const submitRegion: RegionKo[] = - region === "아직 잘 모르겠어요" ? [] : [region as RegionKo]; - - if (!curPreparation) { - throw new Error("준비 단계를 선택해주세요"); - } - - let imageUrl: string | null = baseProfileImageUrl; - - if (profileImageFile) { - try { - const result = await uploadImageMutation.mutateAsync(profileImageFile); - imageUrl = result.fileUrl; - } catch (err: unknown) { - const error = err as { message?: string }; - console.error("Error", error.message); - // toast.error는 hook의 onError에서 이미 처리되므로 중복 호출 제거 - } - } - - return { - signUpToken: signUpToken as string, - interestedRegions: submitRegion, - interestedCountries: countries, - preparationStatus: curPreparation, - nickname, - profileImageUrl: imageUrl, - }; - }; - - const submitRegisterRequest = async () => { - try { - const registerRequest = await createRegisterRequest(); - signUpMutation.mutate(registerRequest, { - onSuccess: (data) => { - setAccessToken(data.accessToken); - toast.success("회원가입이 완료되었습니다."); - - setTimeout(() => { - router.push("/"); - }, 100); - }, - onError: (error: unknown) => { - const axiosError = error as { - response?: { data?: { message?: string } }; - message?: string; - }; - if (axiosError.response) { - console.error("Axios response error", axiosError.response); - toast.error( - axiosError.response.data?.message || "회원가입에 실패했습니다.", - ); - } else { - console.error("Error", axiosError.message); - toast.error(axiosError.message || "회원가입에 실패했습니다."); - } - }, - }); - } catch (err: unknown) { - const error = err as { message?: string }; - console.error("Error", error.message); - toast.error(error.message || "회원가입에 실패했습니다."); - } - }; - - const renderCurrentSurvey = () => { - switch (curStage) { - case 1: - return ( - { - setCurStage(2); - }} - /> - ); - case 2: - return ( - { - setCurStage(3); - }} - /> - ); - case 3: - return ( - { - setCurStage(4); - }} - /> - ); - case 4: - return ( - - ); - default: - return
회원 가입이 완료되었습니다
; - } - }; - - return ( -
-
- -
- {renderCurrentSurvey()} -
- ); +const SignupSurvey = ({ baseNickname, baseEmail, baseProfileImageUrl }: SignupSurveyProps) => { + const router = useRouter(); + const searchParams = useSearchParams(); + + const signUpToken = searchParams?.get("token"); + if (!signUpToken) { + router.push("/login"); + } + const { setAccessToken } = useAuthStore(); + const [curStage, setCurStage] = useState(1); + const [curProgress, setCurProgress] = useState(0); + + const [curPreparation, setCurPreparation] = useState(null); + + const [region, setRegion] = useState(null); + const [countries, setCountries] = useState([]); + + const [nickname, setNickname] = useState(baseNickname); + const [profileImageFile, setProfileImageFile] = useState(null); + + const signUpMutation = usePostSignUp(); + const uploadImageMutation = useUploadProfileImagePublic(); + + useEffect(() => { + setCurProgress(((curStage - 1) / 3) * 100); + }, [curStage]); + + const createRegisterRequest = async (): Promise => { + const submitRegion: RegionKo[] = region === "아직 잘 모르겠어요" ? [] : [region as RegionKo]; + + if (!curPreparation) { + throw new Error("준비 단계를 선택해주세요"); + } + + let imageUrl: string | null = baseProfileImageUrl; + + if (profileImageFile) { + try { + const result = await uploadImageMutation.mutateAsync(profileImageFile); + imageUrl = result.fileUrl; + } catch (err: unknown) { + const error = err as { message?: string }; + console.error("Error", error.message); + // toast.error는 hook의 onError에서 이미 처리되므로 중복 호출 제거 + } + } + + return { + signUpToken: signUpToken as string, + interestedRegions: submitRegion, + interestedCountries: countries, + preparationStatus: curPreparation, + nickname, + profileImageUrl: imageUrl, + }; + }; + + const submitRegisterRequest = async () => { + try { + const registerRequest = await createRegisterRequest(); + signUpMutation.mutate(registerRequest, { + onSuccess: (data) => { + setAccessToken(data.accessToken); + toast.success("회원가입이 완료되었습니다."); + + setTimeout(() => { + router.push("/"); + }, 100); + }, + onError: (error: unknown) => { + const axiosError = error as { + response?: { data?: { message?: string } }; + message?: string; + }; + if (axiosError.response) { + console.error("Axios response error", axiosError.response); + toast.error(axiosError.response.data?.message || "회원가입에 실패했습니다."); + } else { + console.error("Error", axiosError.message); + toast.error(axiosError.message || "회원가입에 실패했습니다."); + } + }, + }); + } catch (err: unknown) { + const error = err as { message?: string }; + console.error("Error", error.message); + toast.error(error.message || "회원가입에 실패했습니다."); + } + }; + + const renderCurrentSurvey = () => { + switch (curStage) { + case 1: + return ( + { + setCurStage(2); + }} + /> + ); + case 2: + return ( + { + setCurStage(3); + }} + /> + ); + case 3: + return ( + { + setCurStage(4); + }} + /> + ); + case 4: + return ( + + ); + default: + return
회원 가입이 완료되었습니다
; + } + }; + + return ( +
+
+ +
+ {renderCurrentSurvey()} +
+ ); }; export default SignupSurvey; diff --git a/apps/web/src/components/mentor/ArticleBottomSheetModal/index.tsx b/apps/web/src/components/mentor/ArticleBottomSheetModal/index.tsx index 58797de4..e819c121 100644 --- a/apps/web/src/components/mentor/ArticleBottomSheetModal/index.tsx +++ b/apps/web/src/components/mentor/ArticleBottomSheetModal/index.tsx @@ -1,6 +1,5 @@ -import Image from "next/image"; - import BottomSheet from "@/components/ui/BottomSheet"; +import Image from "@/components/ui/FallbackImage"; import { IconCamera } from "@/public/svgs/mentor"; import useArticleSchema from "./hooks/useArticleSchema"; diff --git a/apps/web/src/components/mentor/MentorApplyCountContent/index.tsx b/apps/web/src/components/mentor/MentorApplyCountContent/index.tsx index 00e16474..0d996957 100644 --- a/apps/web/src/components/mentor/MentorApplyCountContent/index.tsx +++ b/apps/web/src/components/mentor/MentorApplyCountContent/index.tsx @@ -8,58 +8,54 @@ import { UserRole } from "@/types/mentor"; import { tokenParse } from "@/utils/jwtUtils"; const MentorApplyCountContent = () => { - // 로그인 된경우에만 신규 신청 카운트 모달 표시 - const { accessToken, isInitialized } = useAuthStore(); - const isMentor = - tokenParse(accessToken)?.role === UserRole.MENTOR || - tokenParse(accessToken)?.role === UserRole.ADMIN; - - const { data: count, isSuccess } = useGetUnconfirmedMentoringCount( - isInitialized && !!accessToken && isMentor, - ); - - const [isModalOpen, setIsModalOpen] = useState(true); - - // 신규 신청 없으면 표시 - if (!isInitialized || !isMentor || !isSuccess || !isModalOpen || count === 0) - return null; - - return ( -
- {/* close button */} - - setIsModalOpen(false)}> -
- {/* left: message */} -
-

알림

-

새로운 요청이 들어왔어요!

-

어서 요청을 수락해주세요.

-
- - {/* divider */} -
- - {/* right: count */} -
- 신규 신청 -
{count}명
-
-
- -
- ); + // 로그인 된경우에만 신규 신청 카운트 모달 표시 + const { accessToken, isInitialized } = useAuthStore(); + const isMentor = + tokenParse(accessToken)?.role === UserRole.MENTOR || tokenParse(accessToken)?.role === UserRole.ADMIN; + + const { data: count, isSuccess } = useGetUnconfirmedMentoringCount(isInitialized && !!accessToken && isMentor); + + const [isModalOpen, setIsModalOpen] = useState(true); + + // 신규 신청 없으면 표시 + if (!isInitialized || !isMentor || !isSuccess || !isModalOpen || count === 0) return null; + + return ( +
+ {/* close button */} + + setIsModalOpen(false)}> +
+ {/* left: message */} +
+

알림

+

새로운 요청이 들어왔어요!

+

어서 요청을 수락해주세요.

+
+ + {/* divider */} +
+ + {/* right: count */} +
+ 신규 신청 +
{count}명
+
+
+ +
+ ); }; export default MentorApplyCountContent; diff --git a/apps/web/src/components/ui/FallbackImage.tsx b/apps/web/src/components/ui/FallbackImage.tsx new file mode 100644 index 00000000..b2f4c981 --- /dev/null +++ b/apps/web/src/components/ui/FallbackImage.tsx @@ -0,0 +1,34 @@ +"use client"; + +import NextImage from "next/image"; +import { useState } from "react"; + +const DEFAULT_FALLBACK_SRC = "/svgs/placeholders/image-placeholder.svg"; + +type FallbackImageProps = React.ComponentProps & { + fallbackSrc?: string; +}; + +const FallbackImage = ({ src, fallbackSrc = DEFAULT_FALLBACK_SRC, onError, ...props }: FallbackImageProps) => { + const [failedSource, setFailedSource] = useState(null); + + const normalizedSrc = typeof src === "string" ? src.trim() || fallbackSrc : src; + const sourceKey = typeof normalizedSrc === "string" ? normalizedSrc : JSON.stringify(normalizedSrc); + const hasError = failedSource === sourceKey; + const resolvedSrc = hasError ? fallbackSrc : normalizedSrc; + + return ( + { + if (!hasError && resolvedSrc !== fallbackSrc) { + setFailedSource(sourceKey); + } + onError?.(event); + }} + /> + ); +}; + +export default FallbackImage; diff --git a/apps/web/src/components/ui/OptimisticImg/index.tsx b/apps/web/src/components/ui/OptimisticImg/index.tsx index 5b6e5345..865dd11b 100644 --- a/apps/web/src/components/ui/OptimisticImg/index.tsx +++ b/apps/web/src/components/ui/OptimisticImg/index.tsx @@ -1,5 +1,5 @@ -import Image from "next/image"; import { useEffect, useState } from "react"; +import Image from "@/components/ui/FallbackImage"; const OptimisticImg = ({ src, alt }: { src: string; alt: string }) => { // 실제 서버 URL인지, 아니면 로컬 blob URL인지 판단 diff --git a/apps/web/src/components/ui/ProfileWithBadge.tsx b/apps/web/src/components/ui/ProfileWithBadge.tsx index 48c07061..c17bf3b5 100644 --- a/apps/web/src/components/ui/ProfileWithBadge.tsx +++ b/apps/web/src/components/ui/ProfileWithBadge.tsx @@ -1,4 +1,4 @@ -import Image from "next/image"; +import Image from "@/components/ui/FallbackImage"; import { IconDefaultProfile, IconGraduation } from "@/public/svgs/mentor"; import { convertUploadedImageUrl } from "@/utils/fileUtils"; @@ -37,6 +37,7 @@ const ProfileWithBadge = ({ width={width} height={height} className="h-full w-full object-cover" + fallbackSrc="/images/placeholder/profile112.png" /> ) : ( diff --git a/apps/web/src/components/ui/UniverSityCard/index.tsx b/apps/web/src/components/ui/UniverSityCard/index.tsx index 475be51b..7b6d0700 100644 --- a/apps/web/src/components/ui/UniverSityCard/index.tsx +++ b/apps/web/src/components/ui/UniverSityCard/index.tsx @@ -1,7 +1,6 @@ -import Image from "next/image"; import Link from "next/link"; +import Image from "@/components/ui/FallbackImage"; import CheveronRightFilled from "@/components/ui/icon/ChevronRightFilled"; -import { useImageFallback } from "@/hooks/useImageFallback"; import type { ListUniversity } from "@/types/university"; import { convertImageUrl } from "@/utils/fileUtils"; import shortenLanguageTestName from "@/utils/universityUtils"; @@ -13,7 +12,6 @@ type UniversityCardProps = { }; const UniversityCard = ({ university, showCapacity = true, linkPrefix = "/university" }: UniversityCardProps) => { - const { getSrc, handleError } = useImageFallback("/svgs/placeholders/university-logo-placeholder.svg"); const convertedKoreanName = university.term !== process.env.NEXT_PUBLIC_CURRENT_TERM ? `${university.koreanName}(${university.term})` @@ -31,11 +29,11 @@ const UniversityCard = ({ university, showCapacity = true, linkPrefix = "/univer
대학 이미지
diff --git a/apps/web/src/hooks/useImageFallback.ts b/apps/web/src/hooks/useImageFallback.ts deleted file mode 100644 index 95921ecf..00000000 --- a/apps/web/src/hooks/useImageFallback.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { useState } from "react"; - -/** - * 이미지 로드 실패 시 폴백 이미지를 표시하는 커스텀 훅 - * @param fallbackSrc - 폴백 이미지 경로 - * @returns [현재 이미지 src, 에러 핸들러] - */ -export const useImageFallback = (fallbackSrc: string) => { - const [hasError, setHasError] = useState(false); - - const handleError = () => { - setHasError(true); - }; - - const getSrc = (originalSrc: string) => { - return hasError ? fallbackSrc : originalSrc; - }; - - return { getSrc, handleError, hasError }; -}; diff --git a/turbo.json b/turbo.json index 693afe3d..f2f03b7e 100644 --- a/turbo.json +++ b/turbo.json @@ -4,7 +4,12 @@ "tasks": { "build": { "dependsOn": ["^build"], - "outputs": [".next/**", "!.next/cache/**", "dist/**", ".output/**"], + "outputs": ["dist/**", ".output/**"], + "env": ["NODE_ENV", "NEXT_PUBLIC_*"] + }, + "@solid-connect/web#build": { + "dependsOn": ["^build"], + "outputs": [".next/**", "!.next/cache/**"], "env": ["NODE_ENV", "NEXT_PUBLIC_*"] }, "sync:bruno": { diff --git a/vercel.json b/vercel.json index a5a37ee6..4eb776c8 100644 --- a/vercel.json +++ b/vercel.json @@ -2,7 +2,7 @@ "git": { "deploymentEnabled": true }, - "buildCommand": "pnpm turbo build --filter=@solid-connect/web", + "buildCommand": "pnpm --filter @solid-connect/web run build", "outputDirectory": "apps/web/.next", "installCommand": "pnpm install", "framework": "nextjs"