diff --git a/src/components/NewUpdateModal/NewUpdateModal.module.scss b/src/components/NewUpdateModal/NewUpdateModal.module.scss index 9c0335c..7ec109a 100644 --- a/src/components/NewUpdateModal/NewUpdateModal.module.scss +++ b/src/components/NewUpdateModal/NewUpdateModal.module.scss @@ -1,29 +1,37 @@ .modalBody { padding: 0 0 22px 0 !important; + .img { position: relative; width: 100%; } } + .content { - text-align: center; + text-align: left; padding: 8px 30px 0 30px; } + .instaIcon { position: absolute; right: 34%; top: 21%; cursor: pointer; } -.closeBtn { - border-radius: 0; - background-color: #000; - color: #fff; - margin-top: 32px; - border: 1px solid #000 !important; - &:hover { +.btnWrapper { + text-align: center; + + .closeBtn { + border-radius: 0; + background-color: #000; + color: #fff; + margin-top: 32px; border: 1px solid #000 !important; - color: #fff !important; + + &:hover { + border: 1px solid #000 !important; + color: #fff !important; + } } } diff --git a/src/components/NewUpdateModal/NewUpdateModal.tsx b/src/components/NewUpdateModal/NewUpdateModal.tsx index a19cb45..471857d 100644 --- a/src/components/NewUpdateModal/NewUpdateModal.tsx +++ b/src/components/NewUpdateModal/NewUpdateModal.tsx @@ -42,11 +42,13 @@ const NewUpdateModal: FC = ({ data, onClose }) => {
{data?.description} -
); diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 70b1511..5a8408e 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -288,23 +288,39 @@ function App({ Component, pageProps: { session, ...pageProps } }: TApp) { getData(); }, [router.isReady, router.locale]); + const setUpdateModalSeen = () => { + document.cookie = `updateModalSeen=true; path=/; max-age=31536000`; + }; + useEffect(() => { + if (!newUpdateModalData) return; + + const visibility = newUpdateModalData['Frontend modal visibility']; + if (visibility == null) return; + + if (visibility === false) { + setIsNewUpdateModalVisible(false); + document.cookie = `updateModalSeen=; path=/; max-age=0`; + return; + } + const hasSeen = document.cookie.includes('updateModalSeen=true'); if (hasSeen) return; - if (!newUpdateModalData?.['Frontend modal visibility']) return; - const appearsAfter = newUpdateModalData?.['Appears after x seconds']; - const timeout = setTimeout(() => { + const appearsAfter = Number( + newUpdateModalData['Appears after x seconds'] ?? 0, + ); + + const timeout = window.setTimeout(() => { setIsNewUpdateModalVisible(true); }, appearsAfter * 1000); - return () => clearTimeout(timeout); - }, [newUpdateModalData, newUpdateModalData?.['Appears after x seconds']]); + return () => window.clearTimeout(timeout); + }, [newUpdateModalData]); const handleCloseModal = () => { setIsNewUpdateModalVisible(false); - - document.cookie = 'updateModalSeen=true; path=/; max-age=31536000'; + setUpdateModalSeen(); }; useEffect(() => {