-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 기존에 section 컴포넌트가 상위의 page 컴포넌트로부터 필요한 데이터를 받아오는 부분을 sectio…
…n 내부에서 처리도록 수정 기존에 UserAttendModalSection에서 필요한 programId 값을 page에서 받아오던 부분을 내부에서 받아오도록 수정 #159
- Loading branch information
Showing
4 changed files
with
64 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 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
57 changes: 57 additions & 0 deletions
57
FE/src/components/feature/detail/userAttendModal/UserAttendModalSection.tsx
This file contains 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 @@ | ||
//TODO: 리팩토링 필요 : isLoggedIn을 props로 받아서 조건부 렌더링을 하고 있음 | ||
|
||
"use client"; | ||
|
||
import classNames from "classnames"; | ||
import { ErrorBoundary } from "react-error-boundary"; | ||
import LoginModal from "./LoginModal"; | ||
import UserAttendModal from "./UserAttendModal"; | ||
import ErrorFallbackNoIcon from "@/components/common/error/ErrorFallbackNoIcon"; | ||
import useModal from "@/hooks/useModal"; | ||
import useOutsideRef from "@/hooks/useOutsideRef"; | ||
import { useGetProgramId } from "@/hooks/usePrograms"; | ||
import { Line } from "@/components/icons"; | ||
|
||
interface UserAttendModalProps { | ||
isLoggedIn: boolean; | ||
} | ||
|
||
const UserAttendModalSection = ({ isLoggedIn }: UserAttendModalProps) => { | ||
const programId = useGetProgramId(); | ||
const { isOpen, openModal, closeModal } = useModal(); | ||
const modalRef = useOutsideRef(closeModal); | ||
|
||
const modalStyle = classNames( | ||
"fixed left-0 z-10 flex h-60 w-full flex-col items-center gap-5 rounded-t-3xl border-t-2 bg-background shadow-2xl transition-all duration-500", | ||
{ | ||
"bottom-0": isOpen, | ||
"-bottom-[8rem]": !isOpen, | ||
}, | ||
); | ||
|
||
const handleOpenModal = (e: React.MouseEvent) => { | ||
e.stopPropagation(); | ||
isOpen ? closeModal() : openModal(); | ||
}; | ||
|
||
return ( | ||
<button | ||
ref={modalRef} | ||
className={modalStyle} | ||
onClick={openModal} | ||
type="button" | ||
> | ||
<div onClick={handleOpenModal} className="pb-1 pt-3"> | ||
<Line /> | ||
</div> | ||
{isLoggedIn ? ( | ||
<ErrorBoundary FallbackComponent={ErrorFallbackNoIcon}> | ||
<UserAttendModal programId={programId} /> | ||
</ErrorBoundary> | ||
) : ( | ||
<LoginModal /> | ||
)} | ||
</button> | ||
); | ||
}; | ||
export default UserAttendModalSection; |