diff --git a/client/src/config/firebase.js b/client/src/config/firebase.js index fe8e97c1..aab8018c 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()) && firebaseApp && 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..55522690 --- /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 = 3600000; // 3 hours,for testing set this value to 0 + + remote.defaultConfig = { + isLivePageVisible: false, + }; + + await fetchAndActivate(remote); + + isLivePageVisible = getValue(remote, 'isLivePageVisible').asBoolean(); + } +} +initRemoteConfig(); diff --git a/client/src/pages/live.jsx b/client/src/pages/live.jsx index fa777e62..18435673 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,9 +84,11 @@ 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 ? : } + )} ); }; diff --git a/client/src/screens/BlockScreen.jsx b/client/src/screens/BlockScreen.jsx new file mode 100644 index 00000000..896ce047 --- /dev/null +++ b/client/src/screens/BlockScreen.jsx @@ -0,0 +1,175 @@ +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. + + This page has been temporarily closed by the{' '} + + + Career Development Center of the National Institute of + Technology, Rourkela. + + + + + + + + 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', + }, + [theme.breakpoints.up('sm')]: { + maxWidth: '60vw', + }, + }, + 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', + }, + }, +}));