From bd9f55d4a06ae4cc87ac821dca23d0f3675376a5 Mon Sep 17 00:00:00 2001 From: Flapjacck Date: Fri, 2 Oct 2026 02:01:36 -0400 Subject: [PATCH 1/2] Remove: Tests page and API challenge submission endpoint - Deleted src/pages/Tests.tsx - Removed /tests route from main.tsx - Removed TestsPage import from main.tsx - Removed Tests page check from Header component - Removed /api/challenges API call references Co-authored-by: Cursor --- src/components/universal/Header.tsx | 9 +- src/main.tsx | 2 - src/pages/Tests.tsx | 256 ---------------------------- 3 files changed, 3 insertions(+), 264 deletions(-) delete mode 100644 src/pages/Tests.tsx diff --git a/src/components/universal/Header.tsx b/src/components/universal/Header.tsx index 626d055..630d7ed 100644 --- a/src/components/universal/Header.tsx +++ b/src/components/universal/Header.tsx @@ -8,7 +8,6 @@ export default function Header() { // Track mobile menu open state const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); const location = useLocation(); - const isTestsPage = location.pathname === '/tests'; useEffect(() => { const handleScroll = () => { @@ -27,11 +26,9 @@ export default function Header() { return (
diff --git a/src/main.tsx b/src/main.tsx index e9c7a8f..55c17da 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -4,7 +4,6 @@ import { BrowserRouter, Route, Routes } from 'react-router-dom' import './index.css' import App from './App.tsx' import HackToTheFuturePage from './pages/HackToTheFuture.tsx' -import TestsPage from './pages/Tests.tsx' import NotFound from './pages/NotFound.tsx' createRoot(document.getElementById('root')!).render( @@ -13,7 +12,6 @@ createRoot(document.getElementById('root')!).render( } /> } /> - } /> } /> diff --git a/src/pages/Tests.tsx b/src/pages/Tests.tsx deleted file mode 100644 index 0dee55d..0000000 --- a/src/pages/Tests.tsx +++ /dev/null @@ -1,256 +0,0 @@ -import { useState } from 'react'; -import { PatternBackground } from '../components/universal/PatternBackground'; -import SeoHead from '../components/seo/SeoHead'; -import Editor from '@monaco-editor/react'; - -const CHALLENGES = [ - { - id: 'grade-calculator-with-curve', - number: 1, - title: 'Grade Calculator with Curve', - difficulty: 'Easy', - initialCode: `def solution(scores): - pass - - -if __name__ == "__main__": - score1 = int(input()) - score2 = int(input()) - score3 = int(input()) - letter_grades, average = solution([score1, score2, score3]) - for grade in letter_grades: - print(grade) - print(f"{average:.1f}")`, - }, - { - id: 'merge-two-sorted-lists', - number: 2, - title: 'Merge Two Sorted Lists', - difficulty: 'Easy', - initialCode: `class ListNode(object): - def __init__(self, val=0, next=None): - self.val = val - self.next = next - - -class Solution(object): - def solve(self, list1, list2): - pass`, - }, - { - id: 'binary-tree-inorder-traversal', - number: 3, - title: 'Binary Tree Inorder Traversal', - difficulty: 'Easy', - initialCode: `class TreeNode(object): - def __init__(self, val=0, left=None, right=None): - self.val = val - self.left = left - self.right = right - - -class Solution(object): - def solve(self, root): - pass`, - }, -]; - -export default function TestsPage() { - const [selectedChallenge, setSelectedChallenge] = useState(() => { - if (typeof window !== 'undefined') { - const savedId = localStorage.getItem('lcs_selected_challenge_id'); - const challenge = CHALLENGES.find(c => c.id === savedId); - return challenge || CHALLENGES[0]; - } - return CHALLENGES[0]; - }); - - const [code, setCode] = useState(() => { - if (typeof window !== 'undefined') { - const savedCodes = JSON.parse(localStorage.getItem('lcs_challenge_codes') || '{}'); - const currentId = localStorage.getItem('lcs_selected_challenge_id') || CHALLENGES[0].id; - const challenge = CHALLENGES.find(c => c.id === currentId) || CHALLENGES[0]; - return savedCodes[challenge.id] || challenge.initialCode; - } - return CHALLENGES[0].initialCode; - }); - - const [result, setResult] = useState<{ text: string; color: string } | null>(null); - const [isLoading, setIsLoading] = useState(false); - - const handleChallengeChange = (challenge: typeof CHALLENGES[0]) => { - setSelectedChallenge(challenge); - setResult(null); - localStorage.setItem('lcs_selected_challenge_id', challenge.id); - - const savedCodes = JSON.parse(localStorage.getItem('lcs_challenge_codes') || '{}'); - setCode(savedCodes[challenge.id] || challenge.initialCode); - }; - - const handleRestart = () => { - if (window.confirm('Are you sure you want to reset your code? All unsaved changes for this question will be lost.')) { - setCode(selectedChallenge.initialCode); - const savedCodes = JSON.parse(localStorage.getItem('lcs_challenge_codes') || '{}'); - savedCodes[selectedChallenge.id] = selectedChallenge.initialCode; - localStorage.setItem('lcs_challenge_codes', JSON.stringify(savedCodes)); - setResult(null); - } - }; - - const handleCodeChange = (newCode: string | undefined) => { - const val = newCode || ''; - setCode(val); - const savedCodes = JSON.parse(localStorage.getItem('lcs_challenge_codes') || '{}'); - savedCodes[selectedChallenge.id] = val; - localStorage.setItem('lcs_challenge_codes', JSON.stringify(savedCodes)); - }; - - const handleSubmit = async () => { - setIsLoading(true); - setResult(null); - try { - const response = await fetch(`/api/challenges/${selectedChallenge.id}/submit`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'X-API-Key': 'bruhh', - }, - body: JSON.stringify({ code }), - }); - - const contentType = response.headers.get('content-type') ?? ''; - if (!response.ok || !contentType.includes('application/json')) { - setResult({ - text: `ERROR: HTTP ${response.status}`, - color: 'text-yellow-500', - }); - return; - } - - const data = await response.json(); - - if (data.allPassed === true) { - setResult({ text: 'COMPLETE', color: 'text-green-500' }); - } else if (data.executionError) { - setResult({ text: `ERROR: ${data.executionError.toUpperCase()}`, color: 'text-yellow-500' }); - } else { - setResult({ text: 'WRONG', color: 'text-red-500' }); - } - } catch { - setResult({ text: 'ERROR CONNECTING TO SERVER', color: 'text-yellow-500' }); - } finally { - setIsLoading(false); - } - }; - - return ( -
- - - -
-
-
- Question {selectedChallenge.number} -
- Difficulty: {selectedChallenge.difficulty} -
-
- -
-
- -
-
-
-

Challenges

-
-
- {CHALLENGES.map((challenge) => ( - - ))} -
-
- -
-
-
- solution.py - Python 3 -
-
- -
-
- -
-
-
- Console -
-
-
-
-
- -
-
- {result ? ( -
- {`> ${result.text}`} -
- ) : ( -
- {`> Ready. Select a challenge and click 'Submit' to verify your code...`} -
- )} -
-
-
-
-
-
- ); -} From e7a55b3e679257f227caf8ad20ffd18a24bed150 Mon Sep 17 00:00:00 2001 From: Flapjacck Date: Fri, 2 Oct 2026 02:04:04 -0400 Subject: [PATCH 2/2] Fix: remove unused useLocation import in Header - Remove unused 'location' variable - Remove unused 'useLocation' import - Fixes eslint error @typescript-eslint/no-unused-vars Co-authored-by: Cursor --- src/components/universal/Header.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/universal/Header.tsx b/src/components/universal/Header.tsx index 630d7ed..ac59752 100644 --- a/src/components/universal/Header.tsx +++ b/src/components/universal/Header.tsx @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react'; -import { useNavigate, useLocation } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; import SocialLinks from './SocialLinks'; export default function Header() { @@ -7,7 +7,6 @@ export default function Header() { const [isScrolled, setIsScrolled] = useState(false); // Track mobile menu open state const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); - const location = useLocation(); useEffect(() => { const handleScroll = () => {