From b94a605851dd37208bf3de901ae45a6f43f482bc Mon Sep 17 00:00:00 2001 From: Aashish Date: Sun, 25 Dec 2022 16:37:44 +0530 Subject: [PATCH 1/8] feat: add firebase remote config --- client/src/config/firebase.js | 4 ++++ client/src/config/remoteConfig.js | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 client/src/config/remoteConfig.js diff --git a/client/src/config/firebase.js b/client/src/config/firebase.js index fe8e97c1..03cf7dbf 100644 --- a/client/src/config/firebase.js +++ b/client/src/config/firebase.js @@ -1,5 +1,6 @@ import { initializeApp } from 'firebase/app'; import { getAuth, connectAuthEmulator } from 'firebase/auth'; +import { getRemoteConfig, isSupported } from 'firebase/remote-config'; const firebaseConfig = { apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY, @@ -15,6 +16,9 @@ export const firebaseApp = initializeApp(firebaseConfig); export const auth = firebaseApp ? getAuth(firebaseApp) : null; +export const remoteConfig = async () => + (await isSupported()) && getRemoteConfig(firebaseApp); + if (process.env.NODE_ENV !== 'production' && auth) { connectAuthEmulator(auth, 'http://localhost:9099'); } diff --git a/client/src/config/remoteConfig.js b/client/src/config/remoteConfig.js new file mode 100644 index 00000000..017ec189 --- /dev/null +++ b/client/src/config/remoteConfig.js @@ -0,0 +1,20 @@ +import { fetchAndActivate, getValue } from 'firebase/remote-config'; +import { remoteConfig } from './firebase'; + +export let isLivePageVisible = false; + +export async function initRemoteConfig() { + const remote = await remoteConfig(); + if (remote) { + remote.settings.minimumFetchIntervalMillis = 10800000; // 3 hours,for testing set this value to 0 + + remote.defaultConfig = { + isLivePageVisible: false, + }; + + await fetchAndActivate(remote); + + isLivePageVisible = getValue(remote, 'isLivePageVisible').asBoolean(); + } +} +initRemoteConfig(); From 280046f68e8a46e0aba513c9547d83655066e0bc Mon Sep 17 00:00:00 2001 From: Aashish Date: Sun, 25 Dec 2022 16:38:10 +0530 Subject: [PATCH 2/8] feat: add block screen --- client/src/screens/BlockScreen.jsx | 166 +++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 client/src/screens/BlockScreen.jsx diff --git a/client/src/screens/BlockScreen.jsx b/client/src/screens/BlockScreen.jsx new file mode 100644 index 00000000..284998c1 --- /dev/null +++ b/client/src/screens/BlockScreen.jsx @@ -0,0 +1,166 @@ +import React from 'react'; + +import Link from 'next/link'; +import Image from 'next/image'; + +import { Grid, Typography } from '@mui/material'; +import makeStyles from '@mui/styles/makeStyles'; +import { ArrowForward } from '@mui/icons-material'; + +import logo from '../assets/images/logo_mm.png'; +import LINKS from '../utils/getLinks'; + +const SOCIALS = [ + { + link: 'https://www.facebook.com/mondaymorningnitr/', + icons: 'fab fa-facebook-f', + }, + { + link: 'https://twitter.com/mmnitrkl?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor', + icons: 'fab fa-twitter', + }, + { + link: 'https://www.youtube.com/c/MondayMorningNITR', + icons: 'fab fa-youtube', + }, + { + link: 'https://in.linkedin.com/company/monday-morning-the-official-student-media-body-of-nit-rourkela', + icons: 'fab fa-linkedin', + }, + { + link: 'https://www.instagram.com/mondaymorningnitrofficial/?hl=en', + icons: 'fab fa-instagram', + }, +]; + +const PageNotFound = () => { + const classes = useStyles(); + return ( +
+ + + MM Logo + + + Page blocked. + + Sorry, the page is blocked by the admin. + + + + + + Go back home + + + + +
+ {SOCIALS.map(({ icons, link }) => ( + + + + + + + + ))} +
+
+ ); +}; + +export default PageNotFound; + +const useStyles = makeStyles((theme) => ({ + root: { + width: '100%', + height: '100%', + textAlign: 'center', + display: 'flex', + alignItems: 'center', + flexDirection: 'column', + [theme.breakpoints.down('lg')]: { + padding: '20px', + }, + }, + gridContainerLogo: { + marginTop: '70px', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + flexDirection: 'column', + height: 84, + width: 86, + [theme.breakpoints.down('lg')]: { + height: 60, + width: 60, + marginTop: '20px', + }, + }, + gridContainer: { + marginTop: '70px', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + flexDirection: 'column', + [theme.breakpoints.down('lg')]: { + marginTop: '20px', + }, + }, + subTitle: { + fontSize: '52px', + fontWeight: '700', + [theme.breakpoints.down('md')]: { + fontSize: '30px', + }, + }, + body: { + marginTop: '28px', + fontSize: '24px', + color: '#6E6E6E', + [theme.breakpoints.down('md')]: { + fontSize: '19px', + }, + }, + link: { + cursor: 'pointer', + textDecoration: 'none', + }, + homeLink: { + fontSize: '24px', + fontWeight: '600', + color: '#006DCC', + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + cursor: 'default', + [theme.breakpoints.down('md')]: { + fontSize: '18px', + }, + }, + socialIcons: { + display: 'flex', + justifyContent: 'center', + alignItems: 'flex-end', + marginTop: '105px', + [theme.breakpoints.down('lg')]: { + marginTop: '20px', + }, + }, + socialIcon: { + marginLeft: '20px', + fontSize: '21px', + color: '#999999', + cursor: 'pointer', + [theme.breakpoints.down('md')]: { + marginLeft: '10px', + fontSize: '15px', + }, + }, +})); From d109c408e86e6915436e67c53a25badec17736f1 Mon Sep 17 00:00:00 2001 From: Aashish Date: Sun, 25 Dec 2022 16:38:38 +0530 Subject: [PATCH 3/8] feat: add remote config to live page --- client/src/pages/live.jsx | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/client/src/pages/live.jsx b/client/src/pages/live.jsx index 1d72d951..c5382105 100644 --- a/client/src/pages/live.jsx +++ b/client/src/pages/live.jsx @@ -1,11 +1,28 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; import Head from 'next/head'; //Components import Marginals from '../components/marginals/Marginals'; import Live from '../screens/Live'; +import BlockScreen from '../screens/BlockScreen'; +import ActivityIndicator from '../components/shared/ActivityIndicator'; + +//firebase remote config +import { isLivePageVisible, initRemoteConfig } from '../config/remoteConfig'; const LivePage = () => { + const [isPageVisible, setIsPageVisible] = useState(isLivePageVisible); + const [loading, setLoading] = useState(true); + + useEffect(() => { + setLoading(true); + (async () => { + await initRemoteConfig(); + setIsPageVisible(isLivePageVisible); + setLoading(false); + })(); + }, []); + return ( <> @@ -67,20 +84,13 @@ const LivePage = () => { content='Monday Morning is the Media Body of National Institute Of Technology Rourkela. Monday Morning covers all the events, issues and activities going on inside the campus. Monday morning also serves as a link between the administration and the students.' /> - - - + {loading ? ( + + ) : ( + {isPageVisible ? : } + )} ); }; -export async function getServerSideProps() { - return { - redirect: { - destination: '/comingSoon', - permanent: false, - }, - }; -} - export default LivePage; From 8c6f9a4051301a64c7f7083624adf26b0a43a401 Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Tue, 3 Jan 2023 12:27:40 +0530 Subject: [PATCH 4/8] chore: redirect live page (#391) --- client/src/pages/live.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/src/pages/live.jsx b/client/src/pages/live.jsx index fa777e62..31ba2f91 100644 --- a/client/src/pages/live.jsx +++ b/client/src/pages/live.jsx @@ -74,6 +74,15 @@ const LivePage = () => { ); }; +export async function getServerSideProps() { + return { + redirect: { + destination: '/comingSoon', + permanent: false, + }, + }; +} + // export async function getServerSideProps() { /** * For lan restriction, if ever required From 6874d24c4535e78ef085cf0e5a17fd248c9d232a Mon Sep 17 00:00:00 2001 From: Aashish Date: Tue, 3 Jan 2023 17:48:49 +0530 Subject: [PATCH 5/8] chore: remove redirect to coming soon --- client/src/pages/live.jsx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/client/src/pages/live.jsx b/client/src/pages/live.jsx index 7358c5b7..18435673 100644 --- a/client/src/pages/live.jsx +++ b/client/src/pages/live.jsx @@ -93,15 +93,6 @@ const LivePage = () => { ); }; -export async function getServerSideProps() { - return { - redirect: { - destination: '/comingSoon', - permanent: false, - }, - }; -} - // export async function getServerSideProps() { /** * For lan restriction, if ever required From 6514e7f114b4b5b4a10a2969d24406d0213d1da3 Mon Sep 17 00:00:00 2001 From: Aashish Date: Wed, 4 Jan 2023 21:09:33 +0530 Subject: [PATCH 6/8] chore: change block page message --- client/src/screens/BlockScreen.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/client/src/screens/BlockScreen.jsx b/client/src/screens/BlockScreen.jsx index 284998c1..896ce047 100644 --- a/client/src/screens/BlockScreen.jsx +++ b/client/src/screens/BlockScreen.jsx @@ -49,7 +49,13 @@ const PageNotFound = () => { Page blocked. - Sorry, the page is blocked by the admin. + This page has been temporarily closed by the{' '} + + + Career Development Center of the National Institute of + Technology, Rourkela. + + @@ -127,6 +133,9 @@ const useStyles = makeStyles((theme) => ({ [theme.breakpoints.down('md')]: { fontSize: '19px', }, + [theme.breakpoints.up('sm')]: { + maxWidth: '60vw', + }, }, link: { cursor: 'pointer', From 8c3e2d4af33af3c0a99b643092f0dd4a17c58911 Mon Sep 17 00:00:00 2001 From: Aashish Date: Wed, 4 Jan 2023 21:10:11 +0530 Subject: [PATCH 7/8] feat: check firebase init --- client/src/config/firebase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/config/firebase.js b/client/src/config/firebase.js index 03cf7dbf..aab8018c 100644 --- a/client/src/config/firebase.js +++ b/client/src/config/firebase.js @@ -17,7 +17,7 @@ export const firebaseApp = initializeApp(firebaseConfig); export const auth = firebaseApp ? getAuth(firebaseApp) : null; export const remoteConfig = async () => - (await isSupported()) && getRemoteConfig(firebaseApp); + (await isSupported()) && firebaseApp && getRemoteConfig(firebaseApp); if (process.env.NODE_ENV !== 'production' && auth) { connectAuthEmulator(auth, 'http://localhost:9099'); From c3f403a410ce72ccb013d4d6985d0aa58f629b07 Mon Sep 17 00:00:00 2001 From: Aashish Date: Wed, 4 Jan 2023 21:10:37 +0530 Subject: [PATCH 8/8] feat: set minimum fetch interval to one hour --- client/src/config/remoteConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/config/remoteConfig.js b/client/src/config/remoteConfig.js index 017ec189..55522690 100644 --- a/client/src/config/remoteConfig.js +++ b/client/src/config/remoteConfig.js @@ -6,7 +6,7 @@ export let isLivePageVisible = false; export async function initRemoteConfig() { const remote = await remoteConfig(); if (remote) { - remote.settings.minimumFetchIntervalMillis = 10800000; // 3 hours,for testing set this value to 0 + remote.settings.minimumFetchIntervalMillis = 3600000; // 3 hours,for testing set this value to 0 remote.defaultConfig = { isLivePageVisible: false,