Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add firebase remote config #376

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
feat: add remote config to live page
120EE0692 committed Dec 25, 2022
commit d109c408e86e6915436e67c53a25badec17736f1
36 changes: 23 additions & 13 deletions client/src/pages/live.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Head>
@@ -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.'
/>
</Head>
<Marginals>
<Live />
</Marginals>
{loading ? (
<ActivityIndicator />
) : (
<Marginals>{isPageVisible ? <Live /> : <BlockScreen />}</Marginals>
)}
</>
);
};

export async function getServerSideProps() {
return {
redirect: {
destination: '/comingSoon',
permanent: false,
},
};
}

export default LivePage;