Skip to content

Commit 889e2c0

Browse files
carddev81corypride
authored andcommitted
fix: add conditional check for whether user is in session to determine navigation
1 parent a57b60c commit 889e2c0

File tree

2 files changed

+25
-21
lines changed

2 files changed

+25
-21
lines changed

config/zims.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ ZIM_COUNT=$(find ./csvs/zims -type f -name "*.zim" | wc -l)
66

77
if [ "$ZIM_COUNT" -eq 0 ]; then
88
echo "No ZIM files found. Downloading..."
9-
wget -q https://download.kiwix.org/zim/devdocs/devdocs_en_go_2025-07.zim -P ./csvs/zims
10-
wget -q https://download.kiwix.org/zim/devdocs/devdocs_en_bash_2025-07.zim -P ./csvs/zims
11-
wget -q https://download.kiwix.org/zim/devdocs/devdocs_en_c_2025-07.zim -P ./csvs/zims
9+
wget -q https://download.kiwix.org/zim/devdocs/devdocs_en_go_2026-01.zim -P ./csvs/zims
10+
wget -q https://download.kiwix.org/zim/devdocs/devdocs_en_bash_2026-01.zim -P ./csvs/zims
11+
wget -q https://download.kiwix.org/zim/devdocs/devdocs_en_c_2026-01.zim -P ./csvs/zims
1212
else
1313
echo "ZIM files already exist. No download needed."
1414
fi

frontend/src/Pages/Error.tsx

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { ErrorType, User } from '@/common';
2+
import API from '@/api/api';
13
import { AUTHCALLBACK } from '@/useAuth';
2-
import { ErrorType } from '@/common';
34
import { useNavigate } from 'react-router-dom';
45

56
interface ErrorPageProps {
@@ -9,25 +10,19 @@ interface ErrorPageProps {
910
navigateTo?: string;
1011
}
1112

12-
const errorMap: Record<
13-
ErrorType,
14-
{ message: string; buttonText: string; onClick: () => void }
15-
> = {
13+
const errorMap: Record<ErrorType, { message: string; buttonText: string }> = {
1614
unauthorized: {
1715
message:
1816
'You do not have permission to access this page. Contact your administrator if you believe you have reached this page in error.',
19-
buttonText: 'Home Page',
20-
onClick: () => (window.location.href = AUTHCALLBACK)
17+
buttonText: 'Home Page'
2118
},
2219
'not-found': {
2320
message: 'The page you requested does not exist.',
24-
buttonText: 'Home Page',
25-
onClick: () => (window.location.href = AUTHCALLBACK)
21+
buttonText: 'Home Page'
2622
},
2723
'server-error': {
2824
message: 'An unexpected error occurred. Please try again later.',
29-
buttonText: 'Home Page',
30-
onClick: () => (window.location.href = AUTHCALLBACK)
25+
buttonText: 'Home Page'
3126
}
3227
};
3328

@@ -37,19 +32,28 @@ export default function Error({
3732
message: customMessage,
3833
navigateTo
3934
}: ErrorPageProps) {
40-
const {
41-
message: defaultMessage,
42-
buttonText,
43-
onClick
44-
} = errorMap[type ?? 'server-error'];
35+
const { message: defaultMessage, buttonText } =
36+
errorMap[type ?? 'server-error'];
4537
const navigate = useNavigate();
4638
const label = back ? 'Go Back' : buttonText;
4739
const displayMessage = customMessage ?? defaultMessage;
40+
41+
const handleHomeClick = async () => {
42+
const response = await API.get<User>('auth');
43+
if (response.success) {
44+
window.location.href = AUTHCALLBACK;
45+
return;
46+
}
47+
window.location.href = '/';
48+
};
49+
4850
const clickHandler = navigateTo
4951
? () => navigate(navigateTo)
5052
: back
51-
? () => navigate(-2)
52-
: onClick;
53+
? () => navigate(-1)
54+
: () => {
55+
void handleHomeClick();
56+
};
5357

5458
return (
5559
<div className="flex items-center justify-center min-h-screen">

0 commit comments

Comments
 (0)