Skip to content

Commit bb6b8d7

Browse files
committed
chore: misc updates
1 parent c8a9ffc commit bb6b8d7

8 files changed

Lines changed: 128 additions & 82 deletions

File tree

app/(auth)/(forms)/layout.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { BASE_URL } from '@/app/_utils/api_constants';
66

77
export default function Layout({ children }) {
88
return (
9-
<div className="flex min-h-screen max-md:flex-col">
9+
<div className="flex min-h-dvh max-md:flex-col">
1010
<div className="fixed mb-2 ml-2 mt-[1vw] flex h-[5vw] items-center p-[1vw] text-[2vw] max-sm:mt-3 max-sm:h-[72px] max-sm:flex-1 max-sm:text-3xl">
1111
<Link
1212
className="rounded-full transition duration-300 hover:rotate-[360deg]"

app/(lander)/page.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ export default function Home() {
5353
Get Started
5454
</p>
5555

56-
<div className="ml-[-2vw] flex h-[6vw] min-h-[6vw] min-w-max text-[#ffffffb9] transition-all duration-700 group-hover:text-white max-md:ml-[-6vw] max-md:h-[17vw]">
56+
<div className="ml-[-2vw] flex size-[6vw] text-[#ffffffb9] transition-all duration-700 group-hover:text-white max-md:ml-[-6vw] max-md:size-[17vw]">
5757
<ChevronLeft />
5858
</div>
59-
<div className="ml-[-4vw] flex h-[6vw] min-h-[6vw] min-w-max text-[#ffffffb9] transition-all duration-700 group-hover:text-white max-md:ml-[-12vw] max-md:h-[17vw]">
59+
<div className="ml-[-4vw] flex size-[6vw] text-[#ffffffb9] transition-all duration-700 group-hover:text-white max-md:ml-[-12vw] max-md:mr-[-1.2vw] max-md:size-[17vw]">
6060
<ChevronLeft />
6161
</div>
6262

app/dashboard/(timetable)/table/page.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export default function Table() {
9292
{Object.values(rowVal).map((cellValue, colIndex) => (
9393
<td
9494
key={colIndex}
95-
className={`size-[13vw] text-center ${!timetable[rowId][colIndex] ? 'hover:bg-[#0e0e0f]' : 'bg-[#202224] hover:bg-[#292b2e]'} border border-black max-sm:size-[19.5vw]`}
95+
className={`size-[13vw] text-center ${!timetable[rowId][colIndex] ? 'hover:bg-[#0e0e0f]' : 'bg-[#1c1c1c] hover:bg-[#2b2b2b]'} border border-black max-sm:size-[19.5vw]`}
9696
>
9797
<div className="flex h-full flex-wrap items-center justify-center break-all">
9898
{timetable[rowId][colIndex]}

app/dashboard/ranked/page.jsx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
1+
import Image from 'next/image';
2+
13
export default function RankedBunking() {
24
return (
3-
<div className="flex h-full items-center justify-center text-white">
4-
<p className="text-2xl max-sm:-mt-32 max-sm:text-xl">
5-
Ranked bunking will be coming soon..
6-
</p>
5+
<div className="flex h-full flex-col items-center justify-center text-white">
6+
<div className="mt-[-5vw]"></div>
7+
<div className="flex items-center justify-center">
8+
<div className="flex flex-col">
9+
<Image
10+
src={'/assets/construction.png'}
11+
width={1}
12+
height={1}
13+
alt="construction-har"
14+
className="relative z-20 mb-[-4.5vw] ml-[-0.3vw] max-h-[5vw] w-auto -rotate-12 transition duration-300 hover:translate-x-[-1.5vw] hover:-rotate-45 max-sm:mb-[-55px] max-sm:ml-[-6px] max-sm:max-h-[65px] max-sm:hover:translate-x-[-20px]"
15+
unoptimized
16+
/>
17+
18+
<Image
19+
src="/assets/logo.png"
20+
width={1}
21+
height={1}
22+
alt="logo"
23+
className="min-h-[8vw] min-w-[8vw] max-sm:min-h-[95px] max-sm:min-w-[95px]"
24+
unoptimized
25+
/>
26+
</div>
27+
<p className="text-2xl max-sm:-mt-32 max-sm:text-xl">
28+
Ranked bunking <br />
29+
will be coming soon..
30+
</p>
31+
</div>
732
</div>
833
);
934
}

components/navbar/nav_select/nav_mapped.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Link from 'next/link';
44
export default function NavMapped({ option, href, pathname }) {
55
return (
66
<>
7-
{pathname == href ? (
7+
{pathname == href || pathname == '/dashboard/edit' ? (
88
<div className="mb-[-0.5vw]">
99
<NavSelect
1010
props={

components/navbar/navbar.jsx

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { options } from '@/app/_utils/navbarConstants';
22
import NavMapped from '@/components/navbar/nav_select/nav_mapped';
3+
import NavSelect from '@/components/navbar/nav_select/nav_select';
34
import { usePathname } from 'next/navigation';
45
import SideMenu from '@/components/navbar/nav_select/side_menu';
56
import Logo from '@/public/assets/logo.png';
@@ -15,13 +16,13 @@ import { useContext, useEffect, useRef } from 'react';
1516
import { UserContext } from '@/app/_contexts/user_name';
1617
import User from '@/components/svg/user';
1718
import { useNotifications } from '@/app/_contexts/notification';
18-
import { useRouter } from 'next/router';
19+
import { useRouter } from 'next/navigation';
1920

2021
export default function NavBar() {
2122
const pathname = usePathname();
2223
const { userID } = useContext(UserContext);
2324
const { addNotification } = useNotifications();
24-
const router = useRouter;
25+
const router = useRouter();
2526

2627
function handleLogout() {
2728
const header = {
@@ -46,15 +47,23 @@ export default function NavBar() {
4647
}
4748
})
4849
.catch((error) => {
49-
if (error.response.status == 401) {
50-
router.push('/login');
50+
if (error.response) {
51+
if (error.response.status === 401) {
52+
router.push('/login');
53+
}
54+
addNotification('Some error has occurred. Please try again');
55+
} else if (error.request) {
56+
addNotification(
57+
'Server not responding. Check your internet or try again later.'
58+
);
59+
} else {
60+
addNotification('Request setup failed.');
5161
}
52-
addNotification('Some error has occurred. Please try again');
5362
});
5463
}
5564
return (
56-
<nav className="flex h-[5vw] max-sm:h-[72px]">
57-
<div className="mb-2 ml-2 flex h-[5vw] flex-1 items-center p-[1vw] text-[2vw] max-sm:mt-3 max-sm:h-[72px] max-sm:flex-1 max-sm:text-3xl">
65+
<nav className="flex h-[5vw] max-sm:h-[72px] max-sm:pt-3 max-sm:px-3">
66+
<div className="mb-2 flex h-[5vw] flex-1 items-center p-[1vw] text-[2vw] max-sm:h-[72px] max-sm:flex-1 max-sm:text-3xl">
5867
<Image
5968
src={Logo}
6069
alt="logo"
@@ -66,18 +75,32 @@ export default function NavBar() {
6675
</div>
6776
<div className="flex justify-center max-sm:hidden">
6877
<ul className="flex items-center justify-center text-[1.5vw]">
69-
{options.map((option) => (
70-
<li key={option.id}>
71-
<NavMapped
72-
option={option.option}
73-
href={option.href}
74-
pathname={pathname}
75-
/>
78+
{pathname == '/dashboard/edit' ? (
79+
<li key={0}>
80+
<div className="mt-[0.5vw]">
81+
<NavSelect
82+
props={
83+
<div className="mb-[-0.5vw] px-[2vw]">
84+
<p>{'Edit'}</p>
85+
</div>
86+
}
87+
/>
88+
</div>
7689
</li>
77-
))}
90+
) : (
91+
options.map((option) => (
92+
<li key={option.id}>
93+
<NavMapped
94+
option={option.option}
95+
href={option.href}
96+
pathname={pathname}
97+
/>
98+
</li>
99+
))
100+
)}
78101
</ul>
79102
</div>
80-
<div className="flex items-center justify-end px-5 text-5xl sm:hidden">
103+
<div className="flex items-center justify-end px-2 text-5xl sm:hidden">
81104
<SideMenu
82105
options={options}
83106
pathname={pathname}

components/statistics/data.jsx

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useState, useEffect, useContext } from 'react';
1111
import HeightLimit from '../height_limit_scrollable/heightLimit';
1212
import { useRouter } from 'next/navigation';
1313
import { RefreshContext } from '@/app/_contexts/refresh';
14+
import { useNotifications } from '@/app/_contexts/notification';
1415

1516
export default function Data() {
1617
const [hw, setHw] = useState('50vh');
@@ -23,6 +24,7 @@ export default function Data() {
2324
const [threshold, setThreshold] = useState(0);
2425
const { refreshCont } = useContext(RefreshContext);
2526
const router = useRouter();
27+
const { addNotification } = useNotifications();
2628
const header = {
2729
Authorization:
2830
'Token ' + JSON.parse(localStorage.getItem(ACCESS_TOKEN_NAME)),
@@ -31,15 +33,27 @@ export default function Data() {
3133
useEffect(() => {
3234
axios
3335
.get(API_BASE_URL + '/statquery', { headers: header })
34-
.then(function (response) {
36+
.then((response) => {
3537
if (response.status === 200) {
3638
setStatData(response.data);
39+
} else {
40+
addNotification('Unexpected server response.');
3741
}
3842
})
39-
.catch(function (error) {
40-
console.error('Error fetching data:', error);
41-
if (error.response.status == 401) {
42-
router.push('/login');
43+
.catch((error) => {
44+
if (error.response) {
45+
if (error.response.status === 401) {
46+
addNotification('Session expired. Redirecting to login...');
47+
router.push('/login');
48+
} else {
49+
addNotification('Server error while fetching stats.');
50+
}
51+
} else if (error.request) {
52+
addNotification(
53+
'No response from server. Check your connection.'
54+
);
55+
} else {
56+
addNotification('Request setup failed. Please try again.');
4357
}
4458
});
4559
}, [refreshCont]);
@@ -73,14 +87,29 @@ export default function Data() {
7387
setName(list);
7488
setThreshold(response.data.threshold);
7589
} else {
76-
//console.log(response.data,'hhhhhh')
90+
addNotification('Unexpected response from server.');
7791
}
7892
})
79-
.catch(function (error) {
80-
if (error.response.status == 401) {
81-
router.push('/login');
93+
.catch((error) => {
94+
if (error.response) {
95+
if (error.response.status === 401) {
96+
addNotification('Session expired. Redirecting to login...');
97+
router.push('/login');
98+
} else {
99+
addNotification(
100+
'Server error. Error status:',
101+
error.response.status
102+
);
103+
}
104+
} else if (error.request) {
105+
addNotification(
106+
'No response from server. Please check your connection.'
107+
);
108+
} else {
109+
addNotification(
110+
'Failed to send request. Please contact support.'
111+
);
82112
}
83-
//console.log((error),'mmmmmm');
84113
});
85114
}, []);
86115

@@ -99,9 +128,9 @@ export default function Data() {
99128
>
100129
<div className="sticky top-0 bg-[#1c1c1c]">
101130
<div className="mb-0 max-sm:mb-2">
102-
<p className="text-[6vw] max-sm:text-6xl">
131+
<div className="text-[6vw] max-sm:text-6xl">
103132
<ExpandableName name={name} />
104-
</p>
133+
</div>
105134
</div>
106135
<div className="flex">
107136
<div className="flex flex-[2] items-center">
@@ -154,49 +183,21 @@ export default function Data() {
154183

155184
function ExpandableName({ name }) {
156185
const [expanded, setExpanded] = useState(false);
157-
const [isWrapped, setIsWrapped] = useState(false);
158-
159-
useEffect(() => {
160-
if ((name[0] + name[1]).length > 20) {
161-
setIsWrapped(true);
162-
setExpanded(false);
163-
} else {
164-
setExpanded(true);
165-
}
166-
}, [name]);
167186

168187
return (
169188
<div
170-
className="w-full cursor-pointer break-words text-[6vw] max-sm:text-6xl"
171-
onClick={() => {
172-
isWrapped && setExpanded(!expanded);
173-
}}
189+
className="w-full cursor-pointer text-[6vw] max-sm:text-6xl"
190+
onClick={() => setExpanded(!expanded)}
174191
>
175-
<p className="max-sm:hidden">
176-
{expanded ? (
177-
<>
178-
<span>{name[0]}</span>
179-
&nbsp;
180-
<span className="font-thin">{name[1]}</span>
181-
</>
182-
) : name[0]?.length > 20 ? (
183-
<>
184-
<span>{name[0].slice(0, 20)}</span>
185-
</>
186-
) : (
187-
<>
188-
<span>{name[0]}</span>
189-
&nbsp;
190-
<span className="font-thin">
191-
{name[1]?.slice(0, 20 - name[0].length) + '...'}
192-
</span>
193-
</>
194-
)}
195-
</p>
196-
<p className="sm:hidden">
197-
<span>{name[0]}</span>
198-
&nbsp;
199-
<span className="font-thin">{name[1]}</span>
192+
<p
193+
className={`w-full max-w-[90vw] overflow-hidden text-ellipsis ${
194+
expanded
195+
? 'whitespace-normal'
196+
: 'min-h-[67px] overflow-x-hidden whitespace-nowrap'
197+
}`}
198+
title={name[0] + ' ' + name[1]}
199+
>
200+
<span>{name[0]}</span> <span className="font-thin">{name[1]}</span>
200201
</p>
201202
</div>
202203
);

components/statistics/graph.jsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@ export default function Graph({ statData, threshold, setThreshold }) {
1616
return (
1717
<div className="my-[2vw] flex size-full flex-col max-sm:gap-y-3">
1818
{statData.map((key, value) => (
19-
<div
20-
key={value}
21-
className="mb-[2vw] flex flex-1 flex-col text-[1.5vw]"
22-
>
23-
<div className="flex max-sm:flex-col sm:items-center">
19+
<div key={value} className="mb-[2vw] flex flex-col text-[1.5vw]">
20+
<div className="group flex max-sm:flex-col sm:items-center">
2421
{/* Sub Name */}
25-
<div className="group mr-9 flex min-w-[4.6vw] max-sm:m-0 max-sm:min-w-16 max-sm:text-2xl">
22+
<div className="mr-9 flex min-w-[4.6vw] max-sm:m-0 max-sm:min-w-16 max-sm:text-2xl">
2623
{/* Desktop */}
2724
<p className="flex max-sm:hidden">
2825
{key.name.slice(0, 4)}

0 commit comments

Comments
 (0)