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

Production #46

Merged
merged 19 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
const nextConfig = {
reactStrictMode: false,
images: {
unoptimized: true,
remotePatterns: [
{
protocol: "https",
hostname: "**",
},
],
protocol: 'https',
hostname: '**'
}
]
}
}
};

module.exports = nextConfig
module.exports = nextConfig;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"lint": "next lint",
"format": "prettier --write ./src",
"postbuild": "next-sitemap",
"prepare": "husky"
"prepare": "husky",
"export": "next export"
},
"dependencies": {
"@chakra-ui/icons": "^2.0.18",
Expand Down
1 change: 1 addition & 0 deletions public/google309f484796503244.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google-site-verification: google309f484796503244.html
1,143 changes: 690 additions & 453 deletions public/sitemap-0.xml

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,27 @@ export default function Footer({ fixedBottom }: { fixedBottom: boolean }): JSX.E
<Container
as={Stack}
maxW={'6xl'}
py={2}
padding={0}
py={4}
px={0.1}
direction={{ base: 'column', md: 'row' }}
spacing={4}
justify={{ base: 'center', md: 'space-between' }}
align={{ base: 'center', md: 'center' }}>
<Flex flexDirection={'row'}>
<Text>© OPEN SOURCE MADE WITH </Text>
<Box color={'red'} pt={'5px'} px={'3px'}>
{' '}
<BsSuitHeartFill />
</Box>
</Flex>
<Link href={'https://www.orbisdev.co/'}>
<Flex
color={'orange.400'}
fontWeight={'medium'}
flexDirection={'row'}
align={'center'}
fontSize={'md'}
gap={1}>
{/* <Text>© OPEN SOURCE MADE WITH </Text> */}
<Text>Backed By - OrbisDev</Text>
<ExternalLinkIcon />
<Box> {/* <BsSuitHeartFill /> */}</Box>
</Flex>
</Link>

<Stack direction={'row'} spacing={4}>
<SocialButton label={'GitHub Front-End'} href={LINKS.GIT_HUB_REPO_LINK}>
Expand Down Expand Up @@ -121,6 +130,7 @@ const FooterLinks = () => {
<Flex
gap={isUnder600 ? '1.5rem' : '4rem'}
columnGap={'1rem'}
rowGap={'1rem'}
maxWidth={'1200px'}
margin={'0.5rem auto'}
justifyContent={'center'}
Expand Down Expand Up @@ -174,6 +184,7 @@ const githubApiResponseSample = {
type GithubApiResponse = typeof githubApiResponseSample;

import Link from 'next/link';
import { ExternalLinkIcon } from '@chakra-ui/icons';

const GithubContributors = ({ urls }: { urls: string[] }) => {
const [contributors, setContributors] = useState<Array<GithubApiResponse>>([]);
Expand Down
14 changes: 10 additions & 4 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
addLoggedInUser,
reportFirebaseAnalytics
} from '~/lib/FirebaseAnalysis';
import { useContext } from 'react';
import { useContext, useEffect } from 'react';
import { UserCredentialsContext } from '~/hooks/UserCredentialsContext';
import { Tooltip } from '@chakra-ui/react';
import { useRouter } from 'next/router';
Expand All @@ -25,6 +25,11 @@ const secular_One = Secular_One({ subsets: ['latin'], weight: '400' });
export default function Header() {
const user = useContext(UserCredentialsContext);

useEffect(() => {
if(!user || !user.user) return;
addLoggedInUser(user.user as User);
}, [user])

return (
<div
className={styles.header_wrapper + ' ' + 'glow glow_sm' + ' roboto'}
Expand All @@ -51,9 +56,10 @@ export const NotLoggedIn = ({ text, isLoading }: { text: string; isLoading?: boo
<Btn
colorScheme="linkedin"
onClick={(e) => {
signInWithPopup(firebase.firebaseAuth, new GoogleAuthProvider()).then(
(data: UserCredential) => addLoggedInUser(data.user)
);
signInWithPopup(firebase.firebaseAuth, new GoogleAuthProvider());
// .then(
// (data: UserCredential) =>
// );
}}
fontWeight={'bold'}
isLoading={isLoading}>
Expand Down
119 changes: 57 additions & 62 deletions src/components/Timetable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ import {
AccordionIcon
} from '@chakra-ui/react';

import { FaFileImage } from 'react-icons/fa';
import TimeTablePrint from './TimetablePrint';
import ReactToPrint from 'react-to-print';

import { APIS_ENDPOINTS, ROUTING, timetableHeadTitles } from '~/lib/constant';
import { ROUTING, timetableHeadTitles } from '~/lib/constant';

const day_sorter = {
monday: 1,
Expand Down Expand Up @@ -104,77 +103,73 @@ export default function Timetable({ metaData, timetableData, ad }: IProps) {
updatedAt={new Date(timetableData.updatedAt as string)}
/>

{!false ? (
{/* {!false ? (
<FreeForAdvertisement link="/discussions?active_route=View&discussion_id=FLbqhsFKlwny9VxInN8b" />
) : (
<Educative mx={'1rem'} link={ad.link} description={ad.description} title={ad.title} />
)}
)} */}

{/* <RenderOnce uid="Palestine_Side">
<PalestineSideAd url="/discussions?active_route=View&discussion_id=mIPtC9zPO8GaH7Pltx87" />
</RenderOnce> */}

<div>
{!timetableData ? (
<Loader>Loading...</Loader>
) : (
<>
<div ref={printTableRef} className="print_timetable">
<TimeTablePrint
headTitles={timetableHeadTitles}
data={timetableData.timetable}
payload={`${metaData} (Updated At: ${new Date(
timetableData.updatedAt
).toDateString()})`}
/>
</div>
<>
<div ref={printTableRef} className="print_timetable">
<TimeTablePrint
headTitles={timetableHeadTitles}
data={timetableData.timetable}
payload={`${metaData} (Updated At: ${new Date(
timetableData.updatedAt
).toDateString()})`}
/>
</div>

{/* chart render */}
<Accordion mx={2} my={4} mb={8}>
<AccordionItem>
<AccordionButton>
<Box mr={2}>Show Chart</Box>
<AccordionIcon />
</AccordionButton>
<AccordionPanel>
<TimetableChart
timetable={Object.entries(timetableData.timetable).sort(([lhs], [rhs]) => {
let day1 = lhs.toLowerCase();
let day2 = rhs.toLowerCase();
return day_sorter[day1 as keyof object] - day_sorter[day2 as keyof object];
})}
/>
</AccordionPanel>
</AccordionItem>
</Accordion>
{/* chart render */}
<Accordion mx={2} my={4} mb={8}>
<AccordionItem>
<AccordionButton>
<Box mr={2}>Show Chart</Box>
<AccordionIcon />
</AccordionButton>
<AccordionPanel>
<TimetableChart
timetable={Object.entries(timetableData.timetable).sort(([lhs], [rhs]) => {
let day1 = lhs.toLowerCase();
let day2 = rhs.toLowerCase();
return day_sorter[day1 as keyof object] - day_sorter[day2 as keyof object];
})}
/>
</AccordionPanel>
</AccordionItem>
</Accordion>

{Object.entries(timetableData.timetable)
.sort(([lhs], [rhs]) => {
let day1 = lhs.toLowerCase();
let day2 = rhs.toLowerCase();
return day_sorter[day1 as keyof object] - day_sorter[day2 as keyof object];
})
.map(([day, data], idx) => {
return (
<React.Fragment key={idx}>
{(data as Array<TimetableData>).length > 0 && (
<Card
data={(data as Array<TimetableData>).sort((lhs, rhs) => {
return (
lhs.startTime.hours * 60 +
lhs.startTime.minutes -
(rhs.startTime.hours * 60 + rhs.startTime.minutes)
);
})}
day={day}
idx={idx}
/>
)}
</React.Fragment>
);
})}
</>
)}
{Object.entries(timetableData.timetable)
.sort(([lhs], [rhs]) => {
let day1 = lhs.toLowerCase();
let day2 = rhs.toLowerCase();
return day_sorter[day1 as keyof object] - day_sorter[day2 as keyof object];
})
.map(([day, data], idx) => {
return (
<React.Fragment key={idx}>
{(data as Array<TimetableData>).length > 0 && (
<Card
data={(data as Array<TimetableData>).sort((lhs, rhs) => {
return (
lhs.startTime.hours * 60 +
lhs.startTime.minutes -
(rhs.startTime.hours * 60 + rhs.startTime.minutes)
);
})}
day={day}
idx={idx}
/>
)}
</React.Fragment>
);
})}
</>
</div>
</div>
</>
Expand Down
3 changes: 2 additions & 1 deletion src/components/pastpaper/PastPapersToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export default function PastPaperToast() {
const toastId = 'past-paper-toast';

useEffect(() => {
if (router.pathname === ROUTING.past_papers || !show) return;
if (router.pathname === ROUTING.past_papers || router.pathname.includes('/blogs') || !show)
return;
setShow(false);

toast({
Expand Down
12 changes: 7 additions & 5 deletions src/lib/FirebaseAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { firebase, userColsRef } from './firebase';
import { useEffect } from 'react';
import { UserDocType } from './firebase_doctypes';

export function addLoggedInUser(user: User) {
export async function addLoggedInUser(user: User) {
if (!user) return;

const userDoc = doc(userColsRef, user.email as string);
Expand All @@ -23,11 +23,13 @@ export function addLoggedInUser(user: User) {
isPublic: true,
repo: 0
};

getDoc(userDoc).then((doc) => {
if (doc.exists()) return;

try {
const docSnapShot = await getDoc(userDoc);
if(!docSnapShot.exists()) setDoc(userDoc, userData, { merge: true });
} catch(_) {
setDoc(userDoc, userData, { merge: true });
});
}
}

export enum FIREBASE_ANALYTICS_EVENTS {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export const ROUTING = {
rooms: '/timetable/rooms',
clash_resolver: '/util/timetable_clashresolver',
room_activities: '/room-activities',
past_papers: '/pastpaper'
past_papers: '/pastpaper',
blogs: '/blogs'
};

export const APIS_ENDPOINTS = {
Expand Down
1 change: 1 addition & 0 deletions src/lib/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const workFlowColRef = collection(firebase.firebaseStore, 'workflow');
export const discussionSubColName = 'participants';
export const electionColRef = collection(firebase.firebaseStore, 'election');
export const newsLetterColRef = collection(firebase.firebaseStore, 'news_letter');
export const affiliatesColRef = collection(firebase.firebaseStore, 'affiliates');

///
/// firebase storage
Expand Down
21 changes: 19 additions & 2 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Header from '~/components/Header';
import Footer from '~/components/Footer';
import NextNProgress from 'nextjs-progressbar';
import DarkTheme from '~/components/design/DarkTheme';
import BgGlow from '~/components/BgGlow';
// import BgGlow from '~/components/BgGlow';
import { AppStyleProvider, appTheme } from '~/styles/Style';

import OneTap from '~/components/OneTap';
Expand All @@ -24,9 +24,12 @@ import { useReferrer } from '~/hooks/useReferrer';
import PalestineSupportBanner from '~/components/announcements/PalestineSupportBanner';
import NewFeature from '~/components/design/NewFeature';
import PastPaperToast from '~/components/pastpaper/PastPapersToast';
import React from 'react';

// import NewFeature from '~/components/design/NewFeature';
// import UpComingEvent from '~/components/design/UpCommingEvent';
// import { Flex, Text } from '@chakra-ui/react';
// import Link from 'next/link';

const footerPages = ['/', '/contribute', '/developer', '/freeclassrooms'];
const excludeHeadPages = ['/contribute'];
Expand Down Expand Up @@ -57,6 +60,18 @@ export default function App({ Component, pageProps }: AppProps) {
<DarkTheme />
<OneTap />

{/* <Flex justify={'center'} bg={'blue.300'} alignItems={'center'} py={4}>
<Text fontSize={'xl'}>
To know current status of this project check
<Link
style={{ textDecoration: 'underline', marginLeft: '0.4rem' }}
href={'https://github.com/Zain-ul-din/LGU-Timetable/issues/40'}
target="_blank">
this link
</Link>
</Text>
</Flex> */}

<PalestineSupportBanner hideMessage={!footerPages.includes(router.pathname)} />
<PastPaperToast />

Expand All @@ -80,7 +95,9 @@ export default function App({ Component, pageProps }: AppProps) {
<Component {...pageProps} />
</ChatAppStateProvider.Provider>
{footerPages.includes(router.pathname) && <Footer fixedBottom={false} />}
{router.pathname.includes('/timetable/') && <Footer fixedBottom={false} />}
{(router.pathname.includes('/timetable/') || router.pathname.includes('/blogs')) && (
<Footer fixedBottom={false} />
)}
</AppStyleProvider>
</UserCredentialsContext.Provider>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function Document() {
<script
async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9921497734267177"
crossOrigin="anonymous"></script>
crossOrigin="anonymous"></script>

<link
href="https://fonts.googleapis.com/css2?family=Oxygen:wght@300&family=Roboto:wght@300&display=swap"
Expand Down
Loading
Loading