Skip to content

Commit

Permalink
feat: add invit email copy
Browse files Browse the repository at this point in the history
  • Loading branch information
JangAyeon committed Feb 28, 2024
1 parent 1323c6d commit 9d043ce
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
34 changes: 25 additions & 9 deletions components/molecules/LandControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import BorderPointBtn from "@/components/atoms/button/BorderPointBtn"
import Text from "@/components/atoms/typo/Text"
import AuthModal from "@/components/modal/AuthModal"

import useCopy from "@/hooks/useCopy"
import useIsland from "@/hooks/useIsland"
import useStateModal from "@/hooks/useStateModal"
import useUserProfile from "@/hooks/useUser"
Expand All @@ -22,6 +23,7 @@ const LandControl = ({
isOwner: boolean
name: string
}) => {
const { isCopy, onCopy } = useCopy()
const { islandType, islandItemLoc, islandIsEdit } = useIsland()
const { userName, userEmail } = useUserProfile()
const { state, text, isOpen, setStateModal, closeModal, setIsOpen } =
Expand All @@ -45,8 +47,20 @@ const LandControl = ({
}
}

const handleEmailCopy = async () => {
if (userEmail) {
onCopy(userEmail)
setStateModal({
state: "success",
text: `복사된 초대 코드를 친구에게 전달해 섬을 자랑해봐요`,
isOpen: true,
})
}
}

useEffect(() => {
if (isOpen) {
// 초대 결과로 모달 열린게 아닌 편집에서 완료 저장 누른 경우에만 리로드
if (isOpen && !isCopy) {
router.reload()
}
}, [isOpen])
Expand Down Expand Up @@ -99,14 +113,16 @@ const LandControl = ({
alt="mode Image"
/>
</OpenerWrapper>
<ModeButton onClick={handleSaveBtn}>
<Image
src={`/assets/control/mode/invit.svg`}
width={35}
height={38}
alt="mode Image"
/>
</ModeButton>
{userEmail && (
<ModeButton onClick={handleEmailCopy}>
<Image
src={`/assets/control/mode/invit.svg`}
width={35}
height={38}
alt="mode Image"
/>
</ModeButton>
)}
</EditWrapper>
)}
</TopMenu>
Expand Down
2 changes: 1 addition & 1 deletion hooks/useCopy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const useCopy = () => {
}
}

return [isCopy, onCopy]
return { isCopy, onCopy }
}

export default useCopy

0 comments on commit 9d043ce

Please sign in to comment.