-
Notifications
You must be signed in to change notification settings - Fork 2
[FEAT] 프로필 미완료 시 Guard 설정 변경 #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a05df0b
feat: 프로필 생성 안했을 때 guard 초안 적용
9g-g9 45ff0dc
feat: profile modal 추가, profileGuard 추가
9g-g9 b06844a
feat: 중복 함수 hook 분리, alert modal onClose optional 변경
9g-g9 5346342
refactor: gate, state 훅 하나로 병합
9g-g9 e3dd7d3
fix: alertModal.stories.tsx onClose optional 적용
9g-g9 50d9ca2
Merge branch 'dev' of https://github.com/4roro-moving/moving-frontend…
9g-g9 8b10fff
fix: 로그인 확인 전 header menu, side nav menu 숨김
9g-g9 073be11
fix: role 이 없을 시 로그인 완료로 처리 x, admin role 고려한 profile menu
9g-g9 dbd79a8
docs: 각 gate, guard, store 에 JSDoc 문서 추가
9g-g9 3857491
Merge branch 'dev' of https://github.com/4roro-moving/moving-frontend…
9g-g9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| import CustomerAuthGate from "@/components/auth/CustomerAuthGate"; | ||
| import EstimateRequestForm from "@/components/estimate/request/EstimateRequestForm"; | ||
|
|
||
| export default function EstimateRequestPage() { | ||
| return ( | ||
| <main className="bg-background-subtle min-h-screen md:px-40 md:py-64"> | ||
| <EstimateRequestForm /> | ||
| </main> | ||
| <CustomerAuthGate loadingMessage="견적 요청을 준비하는 중입니다."> | ||
| <main className="bg-background-subtle min-h-screen md:px-40 md:py-64"> | ||
| <EstimateRequestForm /> | ||
| </main> | ||
| </CustomerAuthGate> | ||
|
9g-g9 marked this conversation as resolved.
|
||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| import MoverAuthGate from "@/components/auth/MoverAuthGate"; | ||
| import ReceivedRequestsPage from "@/components/estimate/ReceivedRequestsPage"; | ||
|
|
||
| export default function Page() { | ||
| return ( | ||
| <div className="bg-background-default text-text-primary min-h-screen"> | ||
| <ReceivedRequestsPage /> | ||
| </div> | ||
| <MoverAuthGate loadingMessage="받은 요청을 불러오는 중입니다."> | ||
| <div className="bg-background-default text-text-primary min-h-screen"> | ||
| <ReceivedRequestsPage /> | ||
| </div> | ||
| </MoverAuthGate> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| "use client"; | ||
|
|
||
| import { usePathname } from "next/navigation"; | ||
| import { type ReactNode } from "react"; | ||
|
|
||
| import ProfileRequiredModal from "@/components/profile/ProfileRequiredModal"; | ||
| import { useProfileCompletionState } from "@/hooks/profile/useProfileCompletionState"; | ||
| import { isProfileCreatePath } from "@/lib/auth/redirect"; | ||
| import { useAuthStore } from "@/stores/useAuthStore"; | ||
|
|
||
| interface ProfileCompletionGuardProps { | ||
| children: ReactNode; | ||
| loadingFallback?: ReactNode; | ||
| } | ||
|
|
||
| /** | ||
| * 프로필 미완료 시 생성 페이지 외 보호 라우트 접근을 막습니다. | ||
| * - allowlist: /profile, /mover/profile | ||
| * - status 로딩: loadingFallback | ||
| * - 프로필 없음(404 등): incomplete → ProfileRequiredModal (닫기 불가, CTA만) | ||
| * - 그 외 status 실패: fail-open | ||
| * - 공개 페이지에는 사용하지 않음 | ||
| * | ||
| * 적용 위치 (같은 트리에 Layout + AuthGate로 중복 적용하지 말 것): | ||
| * - `(protected)` Route Group → layout에서 RoleGuard와 함께 | ||
| * - Group 밖 보호 페이지 → CustomerAuthGate / MoverAuthGate에서 처리 | ||
|
9g-g9 marked this conversation as resolved.
|
||
| */ | ||
| const ProfileCompletionGuard = ({ | ||
| children, | ||
| loadingFallback = null, | ||
| }: ProfileCompletionGuardProps) => { | ||
| const pathname = usePathname(); | ||
| const role = useAuthStore((state) => state.user?.role); | ||
| const { shouldCheck, isStatusPending, isIncomplete, profileCreatePath, audience } = | ||
| useProfileCompletionState(role); | ||
|
|
||
| if (!shouldCheck) { | ||
| return children; | ||
| } | ||
|
|
||
| if (isStatusPending) { | ||
| return loadingFallback; | ||
| } | ||
|
|
||
| if (!isIncomplete || isProfileCreatePath(pathname, audience)) { | ||
| return children; | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| {loadingFallback} | ||
| <ProfileRequiredModal open profileCreatePath={profileCreatePath} /> | ||
| </> | ||
|
Comment on lines
+49
to
+53
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 차단 상태에서 배경으로 loadingFallback을 그대로 쓰고 있는데, AuthGate 경로에서는 이 값이 "견적 요청을 준비하는 중입니다." 같은 로딩 문구라 실제로는 차단인데 준비 중처럼 보일 수 있을 것 같습니다. 차단 시에는 중립 배경이나 모달만 두는 것도 좋을 것 같아요 :) |
||
| ); | ||
| }; | ||
|
|
||
| export default ProfileCompletionGuard; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.