Skip to content

Commit e135a13

Browse files
committed
feat: added updated timetable option
1 parent 19cb2a5 commit e135a13

File tree

3 files changed

+47
-30
lines changed

3 files changed

+47
-30
lines changed

src/components/Header.tsx

+45-26
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ import handleGlowBlob from '~/lib/glow';
55

66
import { Secular_One } from 'next/font/google';
77
import { FcGoogle } from 'react-icons/fc';
8-
import { Button as Btn, Button } from '@chakra-ui/react';
8+
import { Button as Btn, Button, HStack } from '@chakra-ui/react';
99

1010
import { signInWithPopup, GoogleAuthProvider, UserCredential, User } from 'firebase/auth';
1111
import { firebase } from '~/lib/firebase';
12-
import { addLoggedInUser } from '~/lib/FirebaseAnalysis';
13-
import { useContext, useEffect, useState } from 'react';
12+
import {
13+
FIREBASE_ANALYTICS_EVENTS,
14+
addLoggedInUser,
15+
reportFirebaseAnalytics
16+
} from '~/lib/FirebaseAnalysis';
17+
import { useContext } from 'react';
1418
import { UserCredentialsContext } from '~/hooks/UserCredentialsContext';
15-
1619
import { Tooltip } from '@chakra-ui/react';
17-
import { getTimeRemaining } from '~/lib/util';
20+
import { useRouter } from 'next/router';
21+
import { ROUTING } from '~/lib/constant';
1822

1923
const secular_One = Secular_One({ subsets: ['latin'], weight: '400' });
2024

@@ -62,27 +66,42 @@ export const NotLoggedIn = ({ text, isLoading }: { text: string; isLoading?: boo
6266
};
6367

6468
const LoggedIn = ({ user }: { user: User }) => {
69+
const router = useRouter();
70+
6571
return (
66-
<Link href="/profile">
67-
<Tooltip
68-
background={'var(--bg-color)'}
69-
color={'white'}
70-
border={'1px solid var(--border-color)'}
71-
label="profile link"
72-
fontSize={'1xl'}
73-
className="roboto">
74-
<Image
75-
src={user.photoURL as string}
76-
alt={'user_avatar'}
77-
width={40}
78-
height={40}
79-
style={{
80-
borderRadius: '50%',
81-
border: '1px solid var(--border-color)',
82-
transform: 'translateY(1px)'
83-
}}
84-
/>
85-
</Tooltip>
86-
</Link>
72+
<>
73+
<HStack alignItems={'center'}>
74+
<Button
75+
fontWeight={'normal'}
76+
border={'1px solid var(--border-color)'}
77+
onClick={() => {
78+
reportFirebaseAnalytics(FIREBASE_ANALYTICS_EVENTS.updated_timetable, {});
79+
router.push(ROUTING.developer);
80+
}}>
81+
Update Timetable
82+
</Button>
83+
<Link href="/profile">
84+
<Tooltip
85+
background={'var(--bg-color)'}
86+
color={'white'}
87+
border={'1px solid var(--border-color)'}
88+
label="profile link"
89+
fontSize={'1xl'}
90+
className="roboto">
91+
<Image
92+
src={user.photoURL as string}
93+
alt={'user_avatar'}
94+
width={40}
95+
height={40}
96+
style={{
97+
borderRadius: '50%',
98+
border: '1px solid var(--border-color)',
99+
transform: 'translateY(1px)'
100+
}}
101+
/>
102+
</Tooltip>
103+
</Link>
104+
</HStack>
105+
</>
87106
);
88107
};

src/lib/FirebaseAnalysis.ts

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export enum FIREBASE_ANALYTICS_EVENTS {
4141
notifications = 'notifications',
4242
clash_resolver = 'clash_resolver',
4343
// click events
44+
updated_timetable = 'updated_timetable',
4445
link_share_on_whatsapp = 'link_share_on_whatsapp',
4546
print_time_table = 'print_time_table',
4647
promotion_closed = 'promotion_closed',

src/pages/timetable/[id].tsx

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1+
import Head from 'next/head';
12
import Timetable from '~/components/Timetable';
23

34
import { useRouter } from 'next/router';
45
import ClipLoader from 'react-spinners/ClipLoader';
56
import { useContext, useEffect, useState } from 'react';
67

7-
import { doc, getDocs, getDoc } from 'firebase/firestore';
8-
import { timeTableCol } from '~/lib/firebase';
9-
108
import { motion } from 'framer-motion';
119
import { Center } from '@chakra-ui/react';
12-
import Head from 'next/head';
1310
import { SocialLinks } from '~/components/seo/Seo';
1411
import { GetStaticPropsContext } from 'next';
1512
import { TimetableDocType } from '~/types/typedef';

0 commit comments

Comments
 (0)