From 96df6322e2592dfb889c7f5d18803d3e6444b31b Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Wed, 25 Feb 2026 01:44:39 +0900 Subject: [PATCH 01/11] =?UTF-8?q?refactor:=20USER=5FQUERY=5FOPTIONS=20?= =?UTF-8?q?=ED=86=B5=ED=95=A9=20=EB=B0=8F=20=EC=BF=BC=EB=A6=AC=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/client/src/pages/home/home-page.tsx | 8 +- apps/client/src/pages/my/my-page.tsx | 2 +- .../src/pages/onboarding/onboarding-page.tsx | 13 ++- apps/client/src/pages/report/report-page.tsx | 6 +- .../src/shared/api/domain/home/queries.ts | 18 +--- .../src/shared/api/domain/mypage/queries.ts | 96 +------------------ .../shared/api/domain/onboarding/queries.ts | 16 +--- apps/client/src/shared/api/domain/queries.ts | 96 ++++++++++++++++++- .../src/shared/api/domain/report/queries.ts | 22 +---- .../components/feed-content/feed-content.tsx | 2 +- .../widgets/mypage/components/body/body.tsx | 2 +- .../mypage/components/preview/preview.tsx | 7 +- .../step/etcetera-info/etcetera-info.tsx | 6 +- 13 files changed, 126 insertions(+), 168 deletions(-) diff --git a/apps/client/src/pages/home/home-page.tsx b/apps/client/src/pages/home/home-page.tsx index 830c17b3d..19aef5dff 100644 --- a/apps/client/src/pages/home/home-page.tsx +++ b/apps/client/src/pages/home/home-page.tsx @@ -8,7 +8,7 @@ import { FeaturesSection } from '@widgets/home/components/features-section/featu import { InfoSection } from '@widgets/home/components/info-section/info-section.tsx'; import { RecommendedInfoSection } from '@widgets/home/components/info-section/recommended-info-section.tsx'; -import { HOME_QUERY_OPTIONS } from '@shared/api/domain/home/queries.ts'; +import { USER_QUERY_OPTIONS } from '@shared/api/domain/queries.ts'; import { routePath } from '@shared/router/path.ts'; import * as styles from './home-page.css.ts'; @@ -20,7 +20,7 @@ const HomePage = () => { navigate(path); }; - const { data: userData } = useSuspenseQuery(HOME_QUERY_OPTIONS.USER_INFO()); + const { data: userData } = useSuspenseQuery(USER_QUERY_OPTIONS.PROFILE()); return (
@@ -41,9 +41,9 @@ const HomePage = () => { /> } /> - {userData?.isRecommendInsurance ? ( + {userData?.data?.isRecommendInsurance ? ( <> - + ) : ( diff --git a/apps/client/src/pages/my/my-page.tsx b/apps/client/src/pages/my/my-page.tsx index fc981093e..46674542b 100644 --- a/apps/client/src/pages/my/my-page.tsx +++ b/apps/client/src/pages/my/my-page.tsx @@ -6,7 +6,7 @@ import { Icon } from '@bds/ui/icons'; import Body from '@widgets/mypage/components/body/body'; -import { USER_QUERY_OPTIONS } from '@shared/api/domain/mypage/queries'; +import { USER_QUERY_OPTIONS } from '@shared/api/domain/queries'; import { useNavigateTo } from '@shared/hooks/use-navigate-to'; import { routePath } from '@shared/router/path'; diff --git a/apps/client/src/pages/onboarding/onboarding-page.tsx b/apps/client/src/pages/onboarding/onboarding-page.tsx index 98da3f3fa..63c55ab2c 100644 --- a/apps/client/src/pages/onboarding/onboarding-page.tsx +++ b/apps/client/src/pages/onboarding/onboarding-page.tsx @@ -23,10 +23,9 @@ import { } from '@widgets/onboarding/schemas/onboarding-form-schema'; import { buildSubmitPayload } from '@widgets/onboarding/utils/build-submit-payload'; -import { - usePostUserInfo, - USER_QUERY_OPTIONS, -} from '@shared/api/domain/onboarding/queries'; +import { usePostUserInfo } from '@shared/api/domain/onboarding/queries'; +import { INSURANCE_QUERY_OPTIONS } from '@shared/api/domain/onboarding/queries'; +import { USER_QUERY_OPTIONS } from '@shared/api/domain/queries'; import { SwitchCase } from '@shared/components/switch-case'; import { useFunnel } from '@shared/hooks/use-funnel'; import { routePath } from '@shared/router/path'; @@ -69,12 +68,12 @@ const OnboardingPage = () => { const progressTotal = stepSlugs.filter((s) => !excluded.includes(s)).length; const { data: userData } = useSuspenseQuery(USER_QUERY_OPTIONS.PROFILE()); - const { data: userJobs } = useSuspenseQuery(USER_QUERY_OPTIONS.JOBS()); + const { data: userJobs } = useSuspenseQuery(INSURANCE_QUERY_OPTIONS.JOBS()); const { data: userDiseases } = useSuspenseQuery( - USER_QUERY_OPTIONS.DISEASES(), + INSURANCE_QUERY_OPTIONS.DISEASES(), ); const { data: userCoverages } = useSuspenseQuery( - USER_QUERY_OPTIONS.COVERAGES(), + INSURANCE_QUERY_OPTIONS.COVERAGES(), ); const { mutate } = usePostUserInfo(() => { diff --git a/apps/client/src/pages/report/report-page.tsx b/apps/client/src/pages/report/report-page.tsx index 10d76b126..c4c1369c1 100644 --- a/apps/client/src/pages/report/report-page.tsx +++ b/apps/client/src/pages/report/report-page.tsx @@ -7,10 +7,8 @@ import { Icon } from '@bds/ui/icons'; import ReportDetail from '@widgets/report/components/report-detail/report-detail'; import Summarize from '@widgets/report/components/summarize/summarize'; -import { - INSURANCE_QUERY_OPTIONS, - USER_QUERY_OPTIONS, -} from '@shared/api/domain/report/queries'; +import { USER_QUERY_OPTIONS } from '@shared/api/domain/queries'; +import { INSURANCE_QUERY_OPTIONS } from '@shared/api/domain/report/queries'; import { routePath } from '@shared/router/path'; import * as styles from './report-page.css'; diff --git a/apps/client/src/shared/api/domain/home/queries.ts b/apps/client/src/shared/api/domain/home/queries.ts index 003b78c54..cb89dedab 100644 --- a/apps/client/src/shared/api/domain/home/queries.ts +++ b/apps/client/src/shared/api/domain/home/queries.ts @@ -2,8 +2,8 @@ import { queryOptions } from '@tanstack/react-query'; import { END_POINT } from '@shared/api/config/end-point.ts'; import { api } from '@shared/api/config/instance'; -import { HOME_QUERY_KEY, USER_QUERY_KEY } from '@shared/api/keys/query-key.ts'; -import { ReportSummaryRes, UserProfile } from '@shared/api/types/types'; +import { HOME_QUERY_KEY } from '@shared/api/keys/query-key.ts'; +import { ReportSummaryRes } from '@shared/api/types/types'; export const HOME_QUERY_OPTIONS = { REPORT_SUMMARY: () => { @@ -13,13 +13,6 @@ export const HOME_QUERY_OPTIONS = { select: (data: ReportSummaryRes | null) => data?.data, }); }, - USER_INFO: () => { - return queryOptions({ - queryKey: USER_QUERY_KEY.PROFILE(), - queryFn: getUserProfile, - select: (data: UserProfile | null) => data?.data, - }); - }, }; export const getReportSummary = async (): Promise => { @@ -28,10 +21,3 @@ export const getReportSummary = async (): Promise => { .json(); return response; }; - -export const getUserProfile = async (): Promise => { - const response = await api - .get(END_POINT.USER.GET_USER_INFO) - .json(); - return response; -}; diff --git a/apps/client/src/shared/api/domain/mypage/queries.ts b/apps/client/src/shared/api/domain/mypage/queries.ts index 75b4028e6..f79f59fa0 100644 --- a/apps/client/src/shared/api/domain/mypage/queries.ts +++ b/apps/client/src/shared/api/domain/mypage/queries.ts @@ -1,110 +1,31 @@ -import { - infiniteQueryOptions, - mutationOptions, - queryOptions, -} from '@tanstack/react-query'; +import { mutationOptions } from '@tanstack/react-query'; import { END_POINT } from '@shared/api/config/end-point.ts'; import { api } from '@shared/api/config/instance'; -import { - USER_MUTATION_KEY, - USER_QUERY_KEY, -} from '@shared/api/keys/query-key.ts'; +import { AUTH_MUTATION_KEY } from '@shared/api/keys/query-key.ts'; import { KakaoLogoutResponse, KakaoWithdrawResponse, - MePostResponse, - UserProfile, - UserProfileEditRequestBody, - UserProfileEditResponse, } from '@shared/api/types/types'; -// ============================================================================= -// QUERY OPTIONS -// ============================================================================= - -export const USER_QUERY_OPTIONS = { - PROFILE: () => - queryOptions({ - queryKey: USER_QUERY_KEY.PROFILE(), - queryFn: getUserProfile, - }), - - ME_POSTS: () => - infiniteQueryOptions({ - queryKey: USER_QUERY_KEY.ME_POSTS(), - queryFn: ({ pageParam = 0 }) => getMePosts({ pageParam }), - getNextPageParam: (lastPage) => - lastPage.isLast ? undefined : lastPage.nextCursor, - initialPageParam: 0, - }), - - ME_COMMENTS: () => - infiniteQueryOptions({ - queryKey: USER_QUERY_KEY.ME_COMMENTS(), - queryFn: ({ pageParam = 0 }) => getMeComments({ pageParam }), - getNextPageParam: (lastPage) => - lastPage.isLast ? undefined : lastPage.nextCursor, - initialPageParam: 0, - }), -}; - -// ============================================================================= -// QUERY FUNCTIONS -// ============================================================================= - -export const getUserProfile = async (): Promise => { - const response = await api - .get(END_POINT.USER.GET_USER_INFO) - .json(); - return response; -}; - -export const getMePosts = async ({ pageParam }: { pageParam: number }) => { - const url = - pageParam === 0 - ? `${END_POINT.USER.GET_ME_POSTS}?size=10` - : `${END_POINT.USER.GET_ME_POSTS}?cursorId=${pageParam}&size=10`; - - const response = await api.get(url).json(); - return response.data; -}; - -export const getMeComments = async ({ pageParam }: { pageParam: number }) => { - const url = - pageParam === 0 - ? `${END_POINT.USER.GET_ME_COMMENTS}?size=10` - : `${END_POINT.USER.GET_ME_COMMENTS}?cursorId=${pageParam}&size=10`; - - const response = await api.get(url).json(); - return response.data; -}; - // ============================================================================= // MUTATION OPTIONS // ============================================================================= -export const USER_MUTATION_OPTIONS = { +export const AUTH_MUTATION_OPTIONS = { KAKAO_LOGOUT: () => { return mutationOptions({ - mutationKey: USER_QUERY_KEY.KAKAO_LOGOUT(), + mutationKey: AUTH_MUTATION_KEY.KAKAO_LOGOUT(), mutationFn: kakaoLogout, }); }, KAKAO_WITHDRAW: () => { return mutationOptions({ - mutationKey: USER_QUERY_KEY.KAKAO_WITHDRAW(), + mutationKey: AUTH_MUTATION_KEY.KAKAO_WITHDRAW(), mutationFn: kakaoWithdraw, }); }, - PATCH_USER_PROFILE: () => { - return mutationOptions({ - mutationKey: USER_MUTATION_KEY.USER_PROFILE(), - mutationFn: ({ body }: { body: UserProfileEditRequestBody }) => - patchUserProfile(body), - }); - }, }; // ============================================================================= @@ -124,10 +45,3 @@ export const kakaoWithdraw = async () => { .json(); return response; }; - -export const patchUserProfile = async (data: UserProfileEditRequestBody) => { - const response = await api - .patch(END_POINT.USER.PATCH_USER_INFO, { json: data }) - .json(); - return response; -}; diff --git a/apps/client/src/shared/api/domain/onboarding/queries.ts b/apps/client/src/shared/api/domain/onboarding/queries.ts index 5a5309b2d..0df9767ec 100644 --- a/apps/client/src/shared/api/domain/onboarding/queries.ts +++ b/apps/client/src/shared/api/domain/onboarding/queries.ts @@ -10,16 +10,9 @@ import { UserInfoOptions, UserInfoSubmitRequest, UserInfoSubmitResponse, - UserProfile, } from '@shared/api/types/types'; -export const USER_QUERY_OPTIONS = { - PROFILE: () => { - return queryOptions({ - queryKey: USER_QUERY_KEY.PROFILE(), - queryFn: getUserProfile, - }); - }, +export const INSURANCE_QUERY_OPTIONS = { JOBS: () => { return queryOptions({ queryKey: USER_QUERY_KEY.JOBS(), @@ -57,13 +50,6 @@ export const usePostUserInfo = (onSuccessCallback?: () => void) => { }); }; -export const getUserProfile = async (): Promise => { - const response = await api - .get(END_POINT.USER.GET_USER_INFO) - .json(); - return response; -}; - export const getUserInfoJobs = async (): Promise => { const response = await api .get(END_POINT.USER.GET_USER_INFO_JOBS) diff --git a/apps/client/src/shared/api/domain/queries.ts b/apps/client/src/shared/api/domain/queries.ts index 26829e465..b22ebd673 100644 --- a/apps/client/src/shared/api/domain/queries.ts +++ b/apps/client/src/shared/api/domain/queries.ts @@ -1,13 +1,107 @@ +import { + infiniteQueryOptions, + mutationOptions, + queryOptions, +} from '@tanstack/react-query'; import ky from '@toss/ky'; +import { USER_MUTATION_KEY, USER_QUERY_KEY } from '@shared/api/keys/query-key'; + import { END_POINT } from '../config/end-point'; import { api } from '../config/instance'; -import { ImageUploadResponse } from '../types/types'; +import { + ImageUploadResponse, + MePostResponse, + UserProfile, + UserProfileEditRequestBody, + UserProfileEditResponse, +} from '../types/types'; + +// ============================================================================= +// QUERY OPTIONS +// ============================================================================= + +export const USER_QUERY_OPTIONS = { + PROFILE: () => + queryOptions({ + queryKey: USER_QUERY_KEY.PROFILE(), + queryFn: getUserProfile, + }), + + ME_POSTS: () => + infiniteQueryOptions({ + queryKey: USER_QUERY_KEY.ME_POSTS(), + queryFn: ({ pageParam = 0 }) => getMePosts({ pageParam }), + getNextPageParam: (lastPage) => + lastPage.isLast ? undefined : lastPage.nextCursor, + initialPageParam: 0, + }), + + ME_COMMENTS: () => + infiniteQueryOptions({ + queryKey: USER_QUERY_KEY.ME_COMMENTS(), + queryFn: ({ pageParam = 0 }) => getMeComments({ pageParam }), + getNextPageParam: (lastPage) => + lastPage.isLast ? undefined : lastPage.nextCursor, + initialPageParam: 0, + }), +}; + +// ============================================================================= +// QUERY FUNCTIONS +// ============================================================================= + +export const getUserProfile = async (): Promise => { + const response = await api + .get(END_POINT.USER.GET_USER_INFO) + .json(); + return response; +}; + +export const getMePosts = async ({ pageParam }: { pageParam: number }) => { + const url = + pageParam === 0 + ? `${END_POINT.USER.GET_ME_POSTS}?size=10` + : `${END_POINT.USER.GET_ME_POSTS}?cursorId=${pageParam}&size=10`; + + const response = await api.get(url).json(); + return response.data; +}; + +export const getMeComments = async ({ pageParam }: { pageParam: number }) => { + const url = + pageParam === 0 + ? `${END_POINT.USER.GET_ME_COMMENTS}?size=10` + : `${END_POINT.USER.GET_ME_COMMENTS}?cursorId=${pageParam}&size=10`; + + const response = await api.get(url).json(); + return response.data; +}; + +// ============================================================================= +// MUTATION OPTIONS +// ============================================================================= +export const USER_MUTATION_OPTIONS = { + PATCH_USER_PROFILE: () => { + return mutationOptions({ + mutationKey: USER_MUTATION_KEY.USER_PROFILE(), + mutationFn: ({ body }: { body: UserProfileEditRequestBody }) => + patchUserProfile(body), + }); + }, +}; // ============================================================================= // MUTATION FUNCTIONS // ============================================================================= +export const patchUserProfile = async (data: UserProfileEditRequestBody) => { + const response = await api + .patch(END_POINT.USER.PATCH_USER_INFO, { json: data }) + .json(); + return response; +}; + export const postImage = async (mediaType: string[]) => { const response = await api .post(END_POINT.SHARED.IMAGE_UPLOAD, { json: { mediaType } }) diff --git a/apps/client/src/shared/api/domain/report/queries.ts b/apps/client/src/shared/api/domain/report/queries.ts index 905c6fa23..bb8c0d558 100644 --- a/apps/client/src/shared/api/domain/report/queries.ts +++ b/apps/client/src/shared/api/domain/report/queries.ts @@ -2,10 +2,7 @@ import { queryOptions } from '@tanstack/react-query'; import { END_POINT } from '@shared/api/config/end-point'; import { api } from '@shared/api/config/instance'; -import { - INSURANCE_QUERY_KEY, - USER_QUERY_KEY, -} from '@shared/api/keys/query-key'; +import { INSURANCE_QUERY_KEY } from '@shared/api/keys/query-key'; import { InsuranceIpwonReport, InsuranceJanghaeReport, @@ -14,7 +11,6 @@ import { InsuranceSamangReport, InsuranceSummary, InsuranceSusulReport, - UserProfile, } from '@shared/api/types/types'; export const INSURANCE_QUERY_OPTIONS = { @@ -63,15 +59,6 @@ export const INSURANCE_QUERY_OPTIONS = { }, }; -export const USER_QUERY_OPTIONS = { - PROFILE: () => { - return queryOptions({ - queryKey: USER_QUERY_KEY.PROFILE(), - queryFn: getUserProfile, - }); - }, -}; - export const getInsuranceReport = async ( reportId: string, ): Promise => { @@ -148,10 +135,3 @@ export const getInsuranceSamangReport = async ( .json(); return response; }; - -export const getUserProfile = async (): Promise => { - const response = await api - .get(END_POINT.USER.GET_USER_INFO) - .json(); - return response; -}; diff --git a/apps/client/src/widgets/community/components/feed-content/feed-content.tsx b/apps/client/src/widgets/community/components/feed-content/feed-content.tsx index ba7bb086c..066387663 100644 --- a/apps/client/src/widgets/community/components/feed-content/feed-content.tsx +++ b/apps/client/src/widgets/community/components/feed-content/feed-content.tsx @@ -12,7 +12,7 @@ import { COMMUNITY_MUTATION_OPTIONS, COMMUNITY_QUERY_OPTIONS, } from '@shared/api/domain/community/queries'; -import { USER_QUERY_OPTIONS } from '@shared/api/domain/onboarding/queries'; +import { USER_QUERY_OPTIONS } from '@shared/api/domain/queries'; import { COMMUNITY_QUERY_KEY } from '@shared/api/keys/query-key'; import { routePath } from '@shared/router/path'; import { queryClient } from '@shared/utils/query-client'; diff --git a/apps/client/src/widgets/mypage/components/body/body.tsx b/apps/client/src/widgets/mypage/components/body/body.tsx index 2a14e5fb8..fec8199d2 100644 --- a/apps/client/src/widgets/mypage/components/body/body.tsx +++ b/apps/client/src/widgets/mypage/components/body/body.tsx @@ -7,7 +7,7 @@ import { Icon } from '@bds/ui/icons'; import AccountMenuBar from '@widgets/mypage/components/account-menu-bar/account-menu-bar'; import Preview from '@widgets/mypage/components/preview/preview'; -import { USER_MUTATION_OPTIONS } from '@shared/api/domain/mypage/queries'; +import { USER_MUTATION_OPTIONS } from '@shared/api/domain/queries'; import { USER_MUTATION_KEY } from '@shared/api/keys/query-key'; import { useImageUpload } from '@shared/hooks/use-image-upload'; import { useInputState } from '@shared/hooks/use-input-state'; diff --git a/apps/client/src/widgets/mypage/components/preview/preview.tsx b/apps/client/src/widgets/mypage/components/preview/preview.tsx index 0c235f99c..2dd2495d0 100644 --- a/apps/client/src/widgets/mypage/components/preview/preview.tsx +++ b/apps/client/src/widgets/mypage/components/preview/preview.tsx @@ -5,14 +5,13 @@ import { useNavigate } from 'react-router'; import { Tab } from '@bds/ui'; import EmptyPlaceholder from '@widgets/community/components/empty-placeholder/empty-placeholder'; +import CommentPreview from '@widgets/mypage/components/comment-preview/comment-preview'; +import PostPreview from '@widgets/mypage/components/post-preview/post-preview'; -import { USER_QUERY_OPTIONS } from '@shared/api/domain/mypage/queries'; +import { USER_QUERY_OPTIONS } from '@shared/api/domain/queries'; import { useIntersectionObserver } from '@shared/hooks/use-intersection-observer'; import { routePath } from '@shared/router/path'; -import CommentPreview from '../comment-preview/comment-preview'; -import PostPreview from '../post-preview/post-preview'; - import * as styles from './preview.css'; const PREVIEW_TABS = { diff --git a/apps/client/src/widgets/onboarding/components/step/etcetera-info/etcetera-info.tsx b/apps/client/src/widgets/onboarding/components/step/etcetera-info/etcetera-info.tsx index 1f97fa702..837fc2931 100644 --- a/apps/client/src/widgets/onboarding/components/step/etcetera-info/etcetera-info.tsx +++ b/apps/client/src/widgets/onboarding/components/step/etcetera-info/etcetera-info.tsx @@ -9,7 +9,7 @@ import { Button, InfoBox, Title } from '@bds/ui'; import OnboardingTitle from '@widgets/onboarding/components/onboarding-title/onboarding-title'; -import { USER_QUERY_OPTIONS } from '@shared/api/domain/onboarding/queries'; +import { INSURANCE_QUERY_OPTIONS } from '@shared/api/domain/onboarding/queries'; import * as styles from './etcetera-info.css'; @@ -48,7 +48,9 @@ const INFO_DESCRIPTION = { const EtceteraInfo = () => { const { control, setValue } = useFormContext(); - const { data: etcUserData } = useSuspenseQuery(USER_QUERY_OPTIONS.OPTIONS()); + const { data: etcUserData } = useSuspenseQuery( + INSURANCE_QUERY_OPTIONS.OPTIONS(), + ); const handleFieldChange = ( field: ControllerRenderProps, From 56d21dd04ae0bb64265199358736a72611a124c3 Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Wed, 25 Feb 2026 01:45:03 +0900 Subject: [PATCH 02/11] =?UTF-8?q?fix:=20USER=5FMUTATION=5FOPTIONS=EB=A5=BC?= =?UTF-8?q?=20AUTH=5FMUTATION=5FOPTIONS=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/client/src/shared/api/keys/query-key.ts | 2 -- .../mypage/components/account-menu-bar/account-menu-bar.tsx | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/client/src/shared/api/keys/query-key.ts b/apps/client/src/shared/api/keys/query-key.ts index 4ba87c943..ac94cc47e 100644 --- a/apps/client/src/shared/api/keys/query-key.ts +++ b/apps/client/src/shared/api/keys/query-key.ts @@ -19,8 +19,6 @@ export const USER_QUERY_KEY = { DISEASES: () => [...USER_QUERY_KEY.ALL, 'diseases'], COVERAGES: () => [...USER_QUERY_KEY.ALL, 'coverages'], OPTIONS: () => [...USER_QUERY_KEY.ALL, 'options'], - KAKAO_LOGOUT: () => [...USER_QUERY_KEY.ALL, 'kakao-logout'], - KAKAO_WITHDRAW: () => [...USER_QUERY_KEY.ALL, 'kakao-withdraw'], } as const; export const USER_MUTATION_KEY = { diff --git a/apps/client/src/widgets/mypage/components/account-menu-bar/account-menu-bar.tsx b/apps/client/src/widgets/mypage/components/account-menu-bar/account-menu-bar.tsx index 95bd00cfc..359d1234f 100644 --- a/apps/client/src/widgets/mypage/components/account-menu-bar/account-menu-bar.tsx +++ b/apps/client/src/widgets/mypage/components/account-menu-bar/account-menu-bar.tsx @@ -5,7 +5,7 @@ import { TextButton, useModal } from '@bds/ui'; import LogoutModal from '@widgets/mypage/components/modal/logout-modal'; import WithdrawModal from '@widgets/mypage/components/modal/withdraw-modal'; -import { USER_MUTATION_OPTIONS } from '@shared/api/domain/mypage/queries'; +import { AUTH_MUTATION_OPTIONS } from '@shared/api/domain/mypage/queries'; import { USER_QUERY_KEY } from '@shared/api/keys/query-key'; import { authService } from '@shared/auth/services/auth-service'; import { routePath } from '@shared/router/path'; @@ -17,7 +17,7 @@ const AccountMenuBar = () => { const queryClient = useQueryClient(); const { mutate: kakaoLogout } = useMutation({ - ...USER_MUTATION_OPTIONS.KAKAO_LOGOUT(), + ...AUTH_MUTATION_OPTIONS.KAKAO_LOGOUT(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY.ALL, @@ -28,7 +28,7 @@ const AccountMenuBar = () => { }); const { mutate: kakaoWithdraw } = useMutation({ - ...USER_MUTATION_OPTIONS.KAKAO_WITHDRAW(), + ...AUTH_MUTATION_OPTIONS.KAKAO_WITHDRAW(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: USER_QUERY_KEY.ALL, From b603c3980e39bbd796ac8a1515c244fe5bc1bcc2 Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Wed, 25 Feb 2026 02:19:52 +0900 Subject: [PATCH 03/11] =?UTF-8?q?fix:=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EB=8D=B0=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=EC=97=90=20=EB=94=B0=EB=9D=BC=20=EC=9E=91=EC=84=B1=EC=9E=90=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/community-edit/community-edit.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/client/src/pages/community/community-edit/community-edit.tsx b/apps/client/src/pages/community/community-edit/community-edit.tsx index d674a7f54..49d605ae3 100644 --- a/apps/client/src/pages/community/community-edit/community-edit.tsx +++ b/apps/client/src/pages/community/community-edit/community-edit.tsx @@ -4,7 +4,7 @@ import { useQueryClient, useSuspenseQuery, } from '@tanstack/react-query'; -import { useNavigate, useParams } from 'react-router-dom'; +import { Navigate, useNavigate, useParams } from 'react-router-dom'; import { Input, Navigation, TextButton, Title } from '@bds/ui'; import { Icon } from '@bds/ui/icons'; @@ -21,6 +21,7 @@ import { COMMUNITY_MUTATION_OPTIONS, COMMUNITY_QUERY_OPTIONS, } from '@shared/api/domain/community/queries'; +import { USER_QUERY_OPTIONS } from '@shared/api/domain/queries'; import { COMMUNITY_QUERY_KEY } from '@shared/api/keys/query-key'; import { LIMIT_LONG_TEXT, @@ -46,6 +47,19 @@ const CommunityEdit = () => { COMMUNITY_QUERY_OPTIONS.FEED_DETAIL(postId), ); + const { data: userData } = useSuspenseQuery({ + ...USER_QUERY_OPTIONS.PROFILE(), + }); + + if (feedDetailData?.writerId !== userData?.data?.userId) { + return ( + + ); + } + const { mutate, isPending } = useMutation({ ...COMMUNITY_MUTATION_OPTIONS.PUT_FEED(postId), onSuccess: () => { From 580ff433f2a24a7705b2e02bd6804dfe96d83857 Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Wed, 25 Feb 2026 02:39:13 +0900 Subject: [PATCH 04/11] =?UTF-8?q?refactor:=20PROFILE=EB=A7=8C=20=EA=B3=B5?= =?UTF-8?q?=ED=86=B5=ED=99=94=ED=95=98=EA=B3=A0=20ME=5FPOSTS/ME=5FCOMMENTS?= =?UTF-8?q?/PATCH=5FUSER=5FPROFILE=EB=8A=94=20mypage=EB=A1=9C=20=EB=A1=A4?= =?UTF-8?q?=EB=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/shared/api/domain/mypage/queries.ts | 76 ++++++++++++++++++- apps/client/src/shared/api/domain/queries.ts | 76 +------------------ .../widgets/mypage/components/body/body.tsx | 2 +- .../mypage/components/preview/preview.tsx | 2 +- 4 files changed, 80 insertions(+), 76 deletions(-) diff --git a/apps/client/src/shared/api/domain/mypage/queries.ts b/apps/client/src/shared/api/domain/mypage/queries.ts index f79f59fa0..d18ac6e46 100644 --- a/apps/client/src/shared/api/domain/mypage/queries.ts +++ b/apps/client/src/shared/api/domain/mypage/queries.ts @@ -1,17 +1,82 @@ -import { mutationOptions } from '@tanstack/react-query'; +import { infiniteQueryOptions, mutationOptions } from '@tanstack/react-query'; import { END_POINT } from '@shared/api/config/end-point.ts'; import { api } from '@shared/api/config/instance'; -import { AUTH_MUTATION_KEY } from '@shared/api/keys/query-key.ts'; +import { + AUTH_MUTATION_KEY, + USER_MUTATION_KEY, + USER_QUERY_KEY, +} from '@shared/api/keys/query-key.ts'; import { KakaoLogoutResponse, KakaoWithdrawResponse, + MePostResponse, + UserProfileEditRequestBody, + UserProfileEditResponse, } from '@shared/api/types/types'; +// ============================================================================= +// QUERY OPTIONS +// ============================================================================= + +export const USER_QUERY_OPTIONS = { + ME_POSTS: () => + infiniteQueryOptions({ + queryKey: USER_QUERY_KEY.ME_POSTS(), + queryFn: ({ pageParam = 0 }) => getMePosts({ pageParam }), + getNextPageParam: (lastPage) => + lastPage.isLast ? undefined : lastPage.nextCursor, + initialPageParam: 0, + }), + + ME_COMMENTS: () => + infiniteQueryOptions({ + queryKey: USER_QUERY_KEY.ME_COMMENTS(), + queryFn: ({ pageParam = 0 }) => getMeComments({ pageParam }), + getNextPageParam: (lastPage) => + lastPage.isLast ? undefined : lastPage.nextCursor, + initialPageParam: 0, + }), +}; + +// ============================================================================= +// QUERY FUNCTIONS +// ============================================================================= + +export const getMePosts = async ({ pageParam }: { pageParam: number }) => { + const url = + pageParam === 0 + ? `${END_POINT.USER.GET_ME_POSTS}?size=10` + : `${END_POINT.USER.GET_ME_POSTS}?cursorId=${pageParam}&size=10`; + + const response = await api.get(url).json(); + return response.data; +}; + +export const getMeComments = async ({ pageParam }: { pageParam: number }) => { + const url = + pageParam === 0 + ? `${END_POINT.USER.GET_ME_COMMENTS}?size=10` + : `${END_POINT.USER.GET_ME_COMMENTS}?cursorId=${pageParam}&size=10`; + + const response = await api.get(url).json(); + return response.data; +}; + // ============================================================================= // MUTATION OPTIONS // ============================================================================= +export const USER_MUTATION_OPTIONS = { + PATCH_USER_PROFILE: () => { + return mutationOptions({ + mutationKey: USER_MUTATION_KEY.USER_PROFILE(), + mutationFn: ({ body }: { body: UserProfileEditRequestBody }) => + patchUserProfile(body), + }); + }, +}; + export const AUTH_MUTATION_OPTIONS = { KAKAO_LOGOUT: () => { return mutationOptions({ @@ -32,6 +97,13 @@ export const AUTH_MUTATION_OPTIONS = { // MUTATION FUNCTIONS // ============================================================================= +export const patchUserProfile = async (data: UserProfileEditRequestBody) => { + const response = await api + .patch(END_POINT.USER.PATCH_USER_INFO, { json: data }) + .json(); + return response; +}; + export const kakaoLogout = async (redirectUrl: string) => { const response = await api .post(`${END_POINT.AUTH.KAKAO_LOGOUT}?redirect-url=${redirectUrl}`) diff --git a/apps/client/src/shared/api/domain/queries.ts b/apps/client/src/shared/api/domain/queries.ts index b22ebd673..e69344a55 100644 --- a/apps/client/src/shared/api/domain/queries.ts +++ b/apps/client/src/shared/api/domain/queries.ts @@ -1,21 +1,11 @@ -import { - infiniteQueryOptions, - mutationOptions, - queryOptions, -} from '@tanstack/react-query'; +import { queryOptions } from '@tanstack/react-query'; import ky from '@toss/ky'; -import { USER_MUTATION_KEY, USER_QUERY_KEY } from '@shared/api/keys/query-key'; +import { USER_QUERY_KEY } from '@shared/api/keys/query-key'; import { END_POINT } from '../config/end-point'; import { api } from '../config/instance'; -import { - ImageUploadResponse, - MePostResponse, - UserProfile, - UserProfileEditRequestBody, - UserProfileEditResponse, -} from '../types/types'; +import { ImageUploadResponse, UserProfile } from '../types/types'; // ============================================================================= // QUERY OPTIONS @@ -27,24 +17,6 @@ export const USER_QUERY_OPTIONS = { queryKey: USER_QUERY_KEY.PROFILE(), queryFn: getUserProfile, }), - - ME_POSTS: () => - infiniteQueryOptions({ - queryKey: USER_QUERY_KEY.ME_POSTS(), - queryFn: ({ pageParam = 0 }) => getMePosts({ pageParam }), - getNextPageParam: (lastPage) => - lastPage.isLast ? undefined : lastPage.nextCursor, - initialPageParam: 0, - }), - - ME_COMMENTS: () => - infiniteQueryOptions({ - queryKey: USER_QUERY_KEY.ME_COMMENTS(), - queryFn: ({ pageParam = 0 }) => getMeComments({ pageParam }), - getNextPageParam: (lastPage) => - lastPage.isLast ? undefined : lastPage.nextCursor, - initialPageParam: 0, - }), }; // ============================================================================= @@ -58,50 +30,10 @@ export const getUserProfile = async (): Promise => { return response; }; -export const getMePosts = async ({ pageParam }: { pageParam: number }) => { - const url = - pageParam === 0 - ? `${END_POINT.USER.GET_ME_POSTS}?size=10` - : `${END_POINT.USER.GET_ME_POSTS}?cursorId=${pageParam}&size=10`; - - const response = await api.get(url).json(); - return response.data; -}; - -export const getMeComments = async ({ pageParam }: { pageParam: number }) => { - const url = - pageParam === 0 - ? `${END_POINT.USER.GET_ME_COMMENTS}?size=10` - : `${END_POINT.USER.GET_ME_COMMENTS}?cursorId=${pageParam}&size=10`; - - const response = await api.get(url).json(); - return response.data; -}; - -// ============================================================================= -// MUTATION OPTIONS -// ============================================================================= -export const USER_MUTATION_OPTIONS = { - PATCH_USER_PROFILE: () => { - return mutationOptions({ - mutationKey: USER_MUTATION_KEY.USER_PROFILE(), - mutationFn: ({ body }: { body: UserProfileEditRequestBody }) => - patchUserProfile(body), - }); - }, -}; - // ============================================================================= -// MUTATION FUNCTIONS +// IMAGE FUNCTIONS // ============================================================================= -export const patchUserProfile = async (data: UserProfileEditRequestBody) => { - const response = await api - .patch(END_POINT.USER.PATCH_USER_INFO, { json: data }) - .json(); - return response; -}; - export const postImage = async (mediaType: string[]) => { const response = await api .post(END_POINT.SHARED.IMAGE_UPLOAD, { json: { mediaType } }) diff --git a/apps/client/src/widgets/mypage/components/body/body.tsx b/apps/client/src/widgets/mypage/components/body/body.tsx index fec8199d2..2a14e5fb8 100644 --- a/apps/client/src/widgets/mypage/components/body/body.tsx +++ b/apps/client/src/widgets/mypage/components/body/body.tsx @@ -7,7 +7,7 @@ import { Icon } from '@bds/ui/icons'; import AccountMenuBar from '@widgets/mypage/components/account-menu-bar/account-menu-bar'; import Preview from '@widgets/mypage/components/preview/preview'; -import { USER_MUTATION_OPTIONS } from '@shared/api/domain/queries'; +import { USER_MUTATION_OPTIONS } from '@shared/api/domain/mypage/queries'; import { USER_MUTATION_KEY } from '@shared/api/keys/query-key'; import { useImageUpload } from '@shared/hooks/use-image-upload'; import { useInputState } from '@shared/hooks/use-input-state'; diff --git a/apps/client/src/widgets/mypage/components/preview/preview.tsx b/apps/client/src/widgets/mypage/components/preview/preview.tsx index 2dd2495d0..635a4a76b 100644 --- a/apps/client/src/widgets/mypage/components/preview/preview.tsx +++ b/apps/client/src/widgets/mypage/components/preview/preview.tsx @@ -8,7 +8,7 @@ import EmptyPlaceholder from '@widgets/community/components/empty-placeholder/em import CommentPreview from '@widgets/mypage/components/comment-preview/comment-preview'; import PostPreview from '@widgets/mypage/components/post-preview/post-preview'; -import { USER_QUERY_OPTIONS } from '@shared/api/domain/queries'; +import { USER_QUERY_OPTIONS } from '@shared/api/domain/mypage/queries'; import { useIntersectionObserver } from '@shared/hooks/use-intersection-observer'; import { routePath } from '@shared/router/path'; From 8fc054dce238d35298dc4425659e748c56c4fb9a Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Wed, 25 Feb 2026 02:56:54 +0900 Subject: [PATCH 05/11] =?UTF-8?q?fix:=20IMAGE=20FUNCTIONS=20=EC=A3=BC?= =?UTF-8?q?=EC=84=9D=EC=9D=84=20MUTATION=20FUNCTIONS=EB=A1=9C=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 --- apps/client/src/shared/api/domain/queries.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/client/src/shared/api/domain/queries.ts b/apps/client/src/shared/api/domain/queries.ts index e69344a55..de77addd3 100644 --- a/apps/client/src/shared/api/domain/queries.ts +++ b/apps/client/src/shared/api/domain/queries.ts @@ -31,7 +31,7 @@ export const getUserProfile = async (): Promise => { }; // ============================================================================= -// IMAGE FUNCTIONS +// MUTATION FUNCTIONS // ============================================================================= export const postImage = async (mediaType: string[]) => { From 500ebba075947b5ae51e9e811aa24ee95e20993e Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Wed, 25 Feb 2026 11:49:20 +0900 Subject: [PATCH 06/11] =?UTF-8?q?refactor:=20isPostAuthor=20=EA=B3=B5?= =?UTF-8?q?=ED=86=B5=20=EB=A1=9C=EC=A7=81=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/components/feed-content/feed-content.tsx | 4 ++-- .../components/feed-detail-info/feed-detail-info.tsx | 6 +++--- .../components/user-detail-meta/user-detail-meta.tsx | 6 +++--- .../src/widgets/community/utils/is-post-author.ts | 10 ++++++++++ 4 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 apps/client/src/widgets/community/utils/is-post-author.ts diff --git a/apps/client/src/widgets/community/components/feed-content/feed-content.tsx b/apps/client/src/widgets/community/components/feed-content/feed-content.tsx index 066387663..1e907ce30 100644 --- a/apps/client/src/widgets/community/components/feed-content/feed-content.tsx +++ b/apps/client/src/widgets/community/components/feed-content/feed-content.tsx @@ -7,6 +7,7 @@ import CommunityModal from '@widgets/community/components/community-modal/commun import FeedDetailInfo from '@widgets/community/components/feed-detail-info/feed-detail-info'; import UserCommentList from '@widgets/community/components/user-comment-list/user-comment-list'; import { ModalType } from '@widgets/community/types/community-modal.type'; +import { isPostAuthor } from '@widgets/community/utils/is-post-author'; import { COMMUNITY_MUTATION_OPTIONS, @@ -35,7 +36,6 @@ const FeedContent = ({ postId }: FeedContentProps) => { const { data: profileData } = useSuspenseQuery(USER_QUERY_OPTIONS.PROFILE()); const userData = profileData?.data; - const isPostOwner = feedDetailData?.writerId === userData?.userId; const { mutate: deleteFeedMutate } = useMutation({ ...COMMUNITY_MUTATION_OPTIONS.DELETE_FEED(postId), @@ -124,7 +124,7 @@ const FeedContent = ({ postId }: FeedContentProps) => { nickname={feedDetailData?.writerNickname ?? ''} createdAt={getTimeAgo(feedDetailData?.createdAt ?? '')} profileImage={feedDetailData?.profileImage ?? ''} - isOwner={isPostOwner} + isOwner={isPostAuthor(feedDetailData?.writerId, userData?.userId)} imageUrl={feedDetailData?.imageUrl ?? []} title={feedDetailData?.title ?? ''} content={feedDetailData?.content ?? ''} diff --git a/apps/client/src/widgets/community/components/feed-detail-info/feed-detail-info.tsx b/apps/client/src/widgets/community/components/feed-detail-info/feed-detail-info.tsx index ab3d68a8d..2425354c5 100644 --- a/apps/client/src/widgets/community/components/feed-detail-info/feed-detail-info.tsx +++ b/apps/client/src/widgets/community/components/feed-detail-info/feed-detail-info.tsx @@ -11,9 +11,9 @@ interface FeedDetailInfoProps { content: string; nickname: string; imageUrl: Image[]; + isAuthor: boolean; createdAt: string; profileImage: string; - isOwner: boolean; onEditClick: () => void; onDeleteClick: () => void; } @@ -23,9 +23,9 @@ export const FeedDetailInfo = ({ content, nickname, imageUrl, + isAuthor, createdAt, profileImage, - isOwner, onEditClick, onDeleteClick, }: FeedDetailInfoProps) => { @@ -35,7 +35,7 @@ export const FeedDetailInfo = ({ nickName={nickname} createdAt={createdAt} profileImage={profileImage} - isOwner={isOwner} + isAuthor={isAuthor} onEditClick={onEditClick} onDeleteClick={onDeleteClick} /> diff --git a/apps/client/src/widgets/community/components/user-detail-meta/user-detail-meta.tsx b/apps/client/src/widgets/community/components/user-detail-meta/user-detail-meta.tsx index 9f4cb7bbe..b1013af9c 100644 --- a/apps/client/src/widgets/community/components/user-detail-meta/user-detail-meta.tsx +++ b/apps/client/src/widgets/community/components/user-detail-meta/user-detail-meta.tsx @@ -3,19 +3,19 @@ import { Avatar, TextButton } from '@bds/ui'; import * as styles from './user-detail-meta.css'; interface UserDetailMetaProps { + isAuthor: boolean; nickName: string; createdAt: string; profileImage: string; - isOwner: boolean; onEditClick: () => void; onDeleteClick: () => void; } const UserDetailMeta = ({ + isAuthor, nickName, createdAt, profileImage, - isOwner, onEditClick, onDeleteClick, }: UserDetailMetaProps) => { @@ -28,7 +28,7 @@ const UserDetailMeta = ({

{createdAt}

- {isOwner ? ( + {isAuthor ? (
{ + if (writerId == null || userId == null) { + return false; + } + + return writerId === userId; +}; From 4d576bf7b16afe2677c3589d99393f972ab19677 Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Wed, 25 Feb 2026 11:49:52 +0900 Subject: [PATCH 07/11] =?UTF-8?q?feat:=20=EC=BB=A4=EB=AE=A4=EB=8B=88?= =?UTF-8?q?=ED=8B=B0=20=EC=88=98=EC=A0=95=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EC=97=90=20=EB=A1=9C=EB=8D=94=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community-edit/community-edit.tsx | 16 +--------- .../pages/community/community-edit/loader.ts | 30 +++++++++++++++++++ .../shared/router/routes/global-routes.tsx | 2 ++ 3 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 apps/client/src/pages/community/community-edit/loader.ts diff --git a/apps/client/src/pages/community/community-edit/community-edit.tsx b/apps/client/src/pages/community/community-edit/community-edit.tsx index 49d605ae3..d674a7f54 100644 --- a/apps/client/src/pages/community/community-edit/community-edit.tsx +++ b/apps/client/src/pages/community/community-edit/community-edit.tsx @@ -4,7 +4,7 @@ import { useQueryClient, useSuspenseQuery, } from '@tanstack/react-query'; -import { Navigate, useNavigate, useParams } from 'react-router-dom'; +import { useNavigate, useParams } from 'react-router-dom'; import { Input, Navigation, TextButton, Title } from '@bds/ui'; import { Icon } from '@bds/ui/icons'; @@ -21,7 +21,6 @@ import { COMMUNITY_MUTATION_OPTIONS, COMMUNITY_QUERY_OPTIONS, } from '@shared/api/domain/community/queries'; -import { USER_QUERY_OPTIONS } from '@shared/api/domain/queries'; import { COMMUNITY_QUERY_KEY } from '@shared/api/keys/query-key'; import { LIMIT_LONG_TEXT, @@ -47,19 +46,6 @@ const CommunityEdit = () => { COMMUNITY_QUERY_OPTIONS.FEED_DETAIL(postId), ); - const { data: userData } = useSuspenseQuery({ - ...USER_QUERY_OPTIONS.PROFILE(), - }); - - if (feedDetailData?.writerId !== userData?.data?.userId) { - return ( - - ); - } - const { mutate, isPending } = useMutation({ ...COMMUNITY_MUTATION_OPTIONS.PUT_FEED(postId), onSuccess: () => { diff --git a/apps/client/src/pages/community/community-edit/loader.ts b/apps/client/src/pages/community/community-edit/loader.ts new file mode 100644 index 000000000..3094895a7 --- /dev/null +++ b/apps/client/src/pages/community/community-edit/loader.ts @@ -0,0 +1,30 @@ +import { LoaderFunctionArgs, redirect } from 'react-router'; + +import { isPostAuthor } from '@widgets/community/utils/is-post-author'; + +import { COMMUNITY_QUERY_OPTIONS } from '@shared/api/domain/community/queries'; +import { USER_QUERY_OPTIONS } from '@shared/api/domain/queries'; +import { routePath } from '@shared/router/path'; +import { queryClient } from '@shared/utils/query-client'; + +export const communityEditLoader = async ({ params }: LoaderFunctionArgs) => { + const postId = params.postId; + + if (!postId) { + throw new Error('글 수정 페이지에서 postId를 찾을 수 없습니다.'); + } + + const [feedDetailData, userData] = await Promise.all([ + queryClient.ensureQueryData(COMMUNITY_QUERY_OPTIONS.FEED_DETAIL(postId)), + queryClient.ensureQueryData(USER_QUERY_OPTIONS.PROFILE()), + ]); + + const writerId = feedDetailData?.writerId; + const userId = userData?.data?.userId; + + if (!isPostAuthor(writerId, userId)) { + return redirect(routePath.COMMUNITY_DETAIL.replace(':postId', postId)); + } + + return null; +}; diff --git a/apps/client/src/shared/router/routes/global-routes.tsx b/apps/client/src/shared/router/routes/global-routes.tsx index 6ebb6f933..b5781a1f2 100644 --- a/apps/client/src/shared/router/routes/global-routes.tsx +++ b/apps/client/src/shared/router/routes/global-routes.tsx @@ -1,4 +1,5 @@ import CommunityEdit from '@pages/community/community-edit/community-edit'; +import { communityEditLoader } from '@pages/community/community-edit/loader'; import CommunitySearch from '@pages/community/community-search/community-search'; import SplashPage from '@pages/splash/splash-page.tsx'; @@ -47,6 +48,7 @@ export const protectedRoutes = [ { path: routePath.COMMUNITY_EDIT, Component: CommunityEdit, + loader: communityEditLoader, }, { path: routePath.COMMUNITY_SEARCH, From 38fca40b6597728987d1bcf0dac1ee406b31336e Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Wed, 25 Feb 2026 11:51:39 +0900 Subject: [PATCH 08/11] =?UTF-8?q?fix:=20'isOwner'=EB=A5=BC=20'isAuthor'?= =?UTF-8?q?=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widgets/community/components/feed-content/feed-content.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/client/src/widgets/community/components/feed-content/feed-content.tsx b/apps/client/src/widgets/community/components/feed-content/feed-content.tsx index 1e907ce30..ff587737c 100644 --- a/apps/client/src/widgets/community/components/feed-content/feed-content.tsx +++ b/apps/client/src/widgets/community/components/feed-content/feed-content.tsx @@ -124,7 +124,7 @@ const FeedContent = ({ postId }: FeedContentProps) => { nickname={feedDetailData?.writerNickname ?? ''} createdAt={getTimeAgo(feedDetailData?.createdAt ?? '')} profileImage={feedDetailData?.profileImage ?? ''} - isOwner={isPostAuthor(feedDetailData?.writerId, userData?.userId)} + isAuthor={isPostAuthor(feedDetailData?.writerId, userData?.userId)} imageUrl={feedDetailData?.imageUrl ?? []} title={feedDetailData?.title ?? ''} content={feedDetailData?.content ?? ''} From cf6a4b82c8374ac7b5f54fca999b386053b82ae1 Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Wed, 25 Feb 2026 17:26:32 +0900 Subject: [PATCH 09/11] =?UTF-8?q?fix:=20isPostAuthor=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=EC=9D=98=20=EB=B0=98=ED=99=98=20=ED=83=80=EC=9E=85=EC=9D=84=20?= =?UTF-8?q?boolean=EC=9C=BC=EB=A1=9C=20=EB=AA=85=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/client/src/widgets/community/utils/is-post-author.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/client/src/widgets/community/utils/is-post-author.ts b/apps/client/src/widgets/community/utils/is-post-author.ts index 3e0c2e488..dd1158523 100644 --- a/apps/client/src/widgets/community/utils/is-post-author.ts +++ b/apps/client/src/widgets/community/utils/is-post-author.ts @@ -1,7 +1,7 @@ export const isPostAuthor = ( writerId?: number | null, userId?: number | null, -) => { +): boolean => { if (writerId == null || userId == null) { return false; } From 12abd7727cc8ed6909c6f064031161283ccfc547 Mon Sep 17 00:00:00 2001 From: JeongHoon <113702672+jeonghoon11@users.noreply.github.com> Date: Wed, 25 Feb 2026 23:58:39 +0900 Subject: [PATCH 10/11] =?UTF-8?q?refactor:=20data=EA=B0=80=EA=B3=B5=201dep?= =?UTF-8?q?th=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 곽지욱(クァク·ジウク) <99489686+gwagjiug@users.noreply.github.com> --- apps/client/src/pages/community/community-edit/loader.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/client/src/pages/community/community-edit/loader.ts b/apps/client/src/pages/community/community-edit/loader.ts index 3094895a7..2c770a282 100644 --- a/apps/client/src/pages/community/community-edit/loader.ts +++ b/apps/client/src/pages/community/community-edit/loader.ts @@ -19,10 +19,7 @@ export const communityEditLoader = async ({ params }: LoaderFunctionArgs) => { queryClient.ensureQueryData(USER_QUERY_OPTIONS.PROFILE()), ]); - const writerId = feedDetailData?.writerId; - const userId = userData?.data?.userId; - - if (!isPostAuthor(writerId, userId)) { + if (!isPostAuthor(feedDetailData?.writerId, userData?.data?.userId)) { return redirect(routePath.COMMUNITY_DETAIL.replace(':postId', postId)); } From e9a7c8dfead551987b031360bf6d6f8313aa1210 Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Thu, 26 Feb 2026 00:31:39 +0900 Subject: [PATCH 11/11] =?UTF-8?q?fix:=20import=20=EB=B3=91=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/client/src/pages/onboarding/onboarding-page.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/client/src/pages/onboarding/onboarding-page.tsx b/apps/client/src/pages/onboarding/onboarding-page.tsx index 63c55ab2c..8dae9ebb9 100644 --- a/apps/client/src/pages/onboarding/onboarding-page.tsx +++ b/apps/client/src/pages/onboarding/onboarding-page.tsx @@ -23,8 +23,10 @@ import { } from '@widgets/onboarding/schemas/onboarding-form-schema'; import { buildSubmitPayload } from '@widgets/onboarding/utils/build-submit-payload'; -import { usePostUserInfo } from '@shared/api/domain/onboarding/queries'; -import { INSURANCE_QUERY_OPTIONS } from '@shared/api/domain/onboarding/queries'; +import { + INSURANCE_QUERY_OPTIONS, + usePostUserInfo, +} from '@shared/api/domain/onboarding/queries'; import { USER_QUERY_OPTIONS } from '@shared/api/domain/queries'; import { SwitchCase } from '@shared/components/switch-case'; import { useFunnel } from '@shared/hooks/use-funnel';