-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,61 @@ | ||
'use client'; | ||
|
||
import useModal from '@/hooks/useModal'; | ||
import { Notice } from '@/lib/definitions'; | ||
import { Modal } from 'antd'; | ||
import { useEffect } from 'react'; | ||
import Button from '../common/button/button'; | ||
|
||
export default function NoticeModal({ noticeData }: { noticeData: Notice }) { | ||
const { noticeModal } = useModal(); | ||
const { title, content, id } = noticeData; | ||
|
||
useEffect(() => { | ||
noticeModal({ | ||
title: noticeData.title, | ||
content: noticeData.content, | ||
onClick: () => { | ||
// TODO: 확인버튼, 다시보지 않기 버튼 클릭 2가지 경우 고려해서 함수 구현 | ||
console.log('모달 확인 버튼 클릭'); | ||
}, | ||
}); | ||
}, [noticeData.content, noticeData.title, noticeModal]); | ||
const dismissCheck = localStorage.getItem('dismiss'); | ||
const seenCheck = sessionStorage.getItem('seen'); | ||
if (dismissCheck !== String(id)) { | ||
localStorage.removeItem('dismiss'); | ||
} | ||
if (seenCheck !== String(id)) { | ||
sessionStorage.removeItem('seen'); | ||
} | ||
const noticeModal = () => { | ||
Modal.confirm({ | ||
title: <h3 className="f20 mb-4 font-bold text-text_primary">{title}</h3>, | ||
content: <p className="f16 font-medium text-text_primary">{content}</p>, | ||
footer: ( | ||
<div className="mt-6 flex flex-row"> | ||
<Button | ||
label="다시보지 않기" | ||
variant="default" | ||
size="full" | ||
onClick={() => { | ||
localStorage.setItem('dismiss', String(id)); | ||
Modal.destroyAll(); | ||
}} | ||
className="mr-2" | ||
/> | ||
<Button | ||
label="확인" | ||
variant="primary" | ||
size="full" | ||
onClick={() => { | ||
sessionStorage.setItem('seen', String(id)); | ||
Modal.destroyAll(); | ||
}} | ||
/> | ||
</div> | ||
), | ||
icon: null, | ||
maskClosable: false, | ||
centered: true, | ||
width: '358px', | ||
style: { top: -100 }, | ||
transitionName: '', | ||
}); | ||
}; | ||
if (!seenCheck && !dismissCheck) { | ||
noticeModal(); | ||
} | ||
}, [content, title, id]); | ||
|
||
return <div />; | ||
} |
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