-
Notifications
You must be signed in to change notification settings - Fork 4
feat(DEVING-80): 상세 페이지 모달 패러렐 라우트와 인터셉트 라우트로 변경 #66
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
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| 'use client'; | ||
|
|
||
| import { redirect } from 'next/navigation'; | ||
|
|
||
| export default function NeedLoginModal({ | ||
| params, | ||
| }: { | ||
| params: { category: string; id: string; status: string }; | ||
| }) { | ||
| const category = params.category; | ||
| const meetingId = Number(params.id); | ||
|
|
||
| redirect(`/meeting/${category}/${meetingId}`); | ||
| } |
29 changes: 29 additions & 0 deletions
29
src/app/meeting/[category]/@modal/[id]/(.)APPROVED/page.tsx
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,29 @@ | ||
| 'use client'; | ||
|
|
||
| import ModalRegisterComplete from '@/app/meeting/_features/modal-content/ModalRegisterComplete'; | ||
| import ModalPortal from '@/components/ui/modal/ModalPortal'; | ||
| import { useRouter } from 'next/navigation'; | ||
|
|
||
| export default function UserListModal({ | ||
| params, | ||
| }: { | ||
| params: { category: string; id: number }; | ||
| }) { | ||
| const router = useRouter(); | ||
| const category = params.category; | ||
| const meetingId = Number(params.id); | ||
|
|
||
| return ( | ||
| <ModalPortal | ||
| isOpen={true} | ||
| onClose={() => | ||
| router.push(`/meeting/${category}/${meetingId}`, { scroll: false }) | ||
| } | ||
| confirmText="내 모임 보러가기" | ||
| cancelText="확인" | ||
| modalClassName="w-96" | ||
| > | ||
| <ModalRegisterComplete /> | ||
| </ModalPortal> | ||
| ); | ||
| } |
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,40 @@ | ||
| 'use client'; | ||
|
|
||
| import ModalCancel from '@/app/meeting/_features/modal-content/ModalCancel'; | ||
| import ModalPortal from '@/components/ui/modal/ModalPortal'; | ||
| import { useMeetingQuitMutation } from '@/hooks/mutations/useMeetingMutation'; | ||
| import { useRouter } from 'next/navigation'; | ||
|
|
||
| export default function UserListModal({ | ||
| params, | ||
| }: { | ||
| params: { category: string; id: number }; | ||
| }) { | ||
| const router = useRouter(); | ||
| const category = params.category; | ||
| const meetingId = Number(params.id); | ||
|
|
||
| const { mutate: cancelMutate } = useMeetingQuitMutation({ | ||
| meetingId: meetingId, | ||
| }); | ||
|
|
||
| const handleConfirm = () => { | ||
| cancelMutate(); | ||
| router.back(); | ||
| }; | ||
|
|
||
| return ( | ||
| <ModalPortal | ||
| isOpen={true} | ||
| onClose={() => | ||
| router.push(`/meeting/${category}/${meetingId}`, { scroll: false }) | ||
| } | ||
| onConfirm={handleConfirm} | ||
| confirmText="신청 취소" | ||
| cancelText="돌아가기" | ||
| modalClassName="w-96" | ||
| > | ||
| <ModalCancel /> | ||
| </ModalPortal> | ||
| ); | ||
| } |
30 changes: 30 additions & 0 deletions
30
src/app/meeting/[category]/@modal/[id]/(.)PENDING/page.tsx
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,30 @@ | ||
| 'use client'; | ||
|
|
||
| import ModalRegisterWait from '@/app/meeting/_features/modal-content/ModalRegisterWait'; | ||
| import ModalPortal from '@/components/ui/modal/ModalPortal'; | ||
| import { useRouter } from 'next/navigation'; | ||
|
|
||
| export default function UserListModal({ | ||
| params, | ||
| }: { | ||
| params: { category: string; id: number }; | ||
| }) { | ||
| const router = useRouter(); | ||
| const category = params.category; | ||
| const meetingId = Number(params.id); | ||
|
|
||
| return ( | ||
| <ModalPortal | ||
| isOpen={true} | ||
| onClose={() => | ||
| router.push(`/meeting/${category}/${meetingId}`, { scroll: false }) | ||
| } | ||
| onConfirm={() => router.push('/my-meeting/my?type=joined')} | ||
| confirmText="내 모임 보러가기" | ||
| cancelText="확인" | ||
| modalClassName="w-96" | ||
| > | ||
| <ModalRegisterWait /> | ||
| </ModalPortal> | ||
| ); | ||
| } |
55 changes: 55 additions & 0 deletions
55
src/app/meeting/[category]/@modal/[id]/(.)intro-input/page.tsx
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,55 @@ | ||
| 'use client'; | ||
|
|
||
| import ModalRegisterInput from '@/app/meeting/_features/modal-content/ModalRegisterInput'; | ||
| import ModalPortal from '@/components/ui/modal/ModalPortal'; | ||
| import { useMeetingMutation } from '@/hooks/mutations/useMeetingMutation'; | ||
| import { translateCategoryNameToEng } from '@/util/searchFilter'; | ||
| import { useRouter } from 'next/navigation'; | ||
| import { useState } from 'react'; | ||
|
|
||
| export default function UserListModal({ | ||
| params, | ||
| }: { | ||
| params: { category: string; id: number }; | ||
| }) { | ||
| const router = useRouter(); | ||
| const [value, setValue] = useState(''); | ||
|
|
||
| const meetingId = Number(params.id); | ||
| const category = params.category; | ||
|
|
||
| const { mutate } = useMeetingMutation({ | ||
| onSuccessCallback: (status: string) => | ||
| router.push( | ||
| `/meeting/${translateCategoryNameToEng(category)}/${meetingId}/${status}`, | ||
| { scroll: false }, | ||
| ), | ||
| onErrorCallback: () => | ||
| router.push( | ||
| `/meeting/${translateCategoryNameToEng(category)}/${meetingId}`, | ||
| { scroll: false }, | ||
| ), | ||
| meetingId: meetingId, | ||
| }); | ||
|
|
||
| const handleConfirm = () => { | ||
| mutate({ message: value }); | ||
| setValue(''); | ||
| router.push( | ||
| `/meeting/${translateCategoryNameToEng(category)}/${meetingId}/intro-input`, | ||
| { scroll: false }, | ||
| ); | ||
| }; | ||
|
|
||
| return ( | ||
| <ModalPortal | ||
| isOpen={true} | ||
| onConfirm={handleConfirm} | ||
| confirmText="보내기" | ||
| cancelText="취소" | ||
| modalClassName="w-[520px] py-[12px]" | ||
| > | ||
| <ModalRegisterInput value={value} setValue={setValue} /> | ||
| </ModalPortal> | ||
| ); | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/app/meeting/[category]/@modal/[id]/(.)need-login/page.tsx
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,22 @@ | ||
| 'use client'; | ||
|
|
||
| import ModalPortal from '@/components/ui/modal/ModalPortal'; | ||
| import { useRouter } from 'next/navigation'; | ||
|
|
||
| export default function UserListModal() { | ||
| const router = useRouter(); | ||
|
|
||
| return ( | ||
| <ModalPortal | ||
| isOpen={true} | ||
| onConfirm={() => router.push('/login')} | ||
| confirmText="로그인" | ||
| cancelText="취소" | ||
| modalClassName="w-96" | ||
| > | ||
| <div className="text-cg8 typo-head3 flex w-full justify-center"> | ||
| <p className="text-white">로그인이 필요한 서비스입니다.</p> | ||
| </div> | ||
| </ModalPortal> | ||
| ); | ||
| } |
42 changes: 42 additions & 0 deletions
42
src/app/meeting/[category]/@modal/[id]/(.)register/page.tsx
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,42 @@ | ||
| 'use client'; | ||
|
|
||
| import ModalBeforeLogin from '@/app/meeting/_features/modal-content/ModalBeforeLogin'; | ||
| import ModalPortal from '@/components/ui/modal/ModalPortal'; | ||
| import { meetingKeys } from '@/hooks/queries/useMeetingQueries'; | ||
| import { translateCategoryNameToEng } from '@/util/searchFilter'; | ||
| import { useQueryClient } from '@tanstack/react-query'; | ||
| import { useRouter } from 'next/navigation'; | ||
| import { MeetingDetail } from 'service/api/meeting'; | ||
|
|
||
| export default function UserListModal({ | ||
| params, | ||
| }: { | ||
| params: { category: string; id: number }; | ||
| }) { | ||
| const router = useRouter(); | ||
| const meetingId = Number(params.id); | ||
| const queryClient = useQueryClient(); | ||
|
|
||
| const meeting = queryClient.getQueryData<MeetingDetail>( | ||
| meetingKeys.detailInfo(meetingId), | ||
| ); | ||
|
|
||
| if (!meeting) return null; | ||
|
|
||
| return ( | ||
| <ModalPortal | ||
| isOpen={true} | ||
| onConfirm={() => | ||
| router.push( | ||
| `/meeting/${translateCategoryNameToEng(meeting.categoryTitle)}/${meeting.meetingId}/intro-input`, | ||
| { scroll: false }, | ||
| ) | ||
| } | ||
| confirmText="신청" | ||
| cancelText="취소" | ||
| modalClassName="w-96" | ||
| > | ||
| <ModalBeforeLogin meeting={meeting!} /> | ||
| </ModalPortal> | ||
| ); | ||
| } |
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,3 @@ | ||
| export default function DefaultModal() { | ||
| return null; // 기본적으로 모달 없음 | ||
| } |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setState 함수를 직접적으로 props로 전달하는 것은 자식 컴포넌트에 부모 컴포넌트 데이터 변경 주도권을 넘겨주는것과 같아서 좋지 않다고 알고 있습니당! 콜백 함수로 감싸서 전달하는 방식이 더 좋을 것 같아요
해당 내용과 관련된 블로그 링크 첨부할테니 참고하시면 좋을 것 같습니다!
https://velog.io/@thisishwarang/React-setState-%EC%9E%90%EC%B2%B4%EB%A5%BC-props%EB%A1%9C-%EC%A0%84%EB%8B%AC%ED%95%98%EC%A7%80-%EB%A7%90%EC%95%84%EC%95%BC-%ED%95%98%EB%8A%94-%EC%9D%B4%EC%9C%A0