zeroed-some/bashamole / f72c663

Browse files

satisfy linter; api things

Authored by espadonne
SHA
f72c663001b8d6c56c4e765d1f7b62db6edaf294
Parents
6df5afc
Tree
e820908

2 changed files

StatusFile+-
M frontend/src/components/Game.tsx 13 13
M frontend/src/lib/api.ts 1 1
frontend/src/components/Game.tsxmodified
@@ -2,7 +2,7 @@
22
 
33
 import React, { useState, useEffect, useRef } from 'react';
44
 import TreeVisualizer from './TreeVisualizer';
5
-import { gameApi, FileSystemTree, FHSDirectory, CommandReferenceResponse, MoleDirection } from '@/lib/api';
5
+import { gameApi, FileSystemTree, FHSDirectory, CommandReferenceResponse, MoleDirection, TreeNode } from '@/lib/api';
66
 
77
 interface CommandHistoryEntry {
88
   command: string;
@@ -114,7 +114,7 @@ const Game: React.FC = () => {
114114
       setTerminalMinimized(true); // Keep terminal minimized on new game
115115
       setHasPlayedIntro(false); // Reset intro for new game
116116
       setMoleKilled(false); // Reset mole killed state
117
-    } catch (error) {
117
+    } catch {
118118
       setGameState({
119119
         ...gameState,
120120
         loading: false,
@@ -131,8 +131,8 @@ const Game: React.FC = () => {
131131
       const response = await gameApi.getHint(gameState.tree.id);
132132
       setHints(response.hints);
133133
       setShowHints(true);
134
-    } catch (error) {
135
-      console.error('Failed to get hints', error);
134
+    } catch {
135
+      console.error('Failed to get hints');
136136
     }
137137
   };
138138
 
@@ -142,8 +142,8 @@ const Game: React.FC = () => {
142142
       const response = await gameApi.getFHSReference();
143143
       setFhsDirs(response.directories);
144144
       setShowFHS(true);
145
-    } catch (error) {
146
-      console.error('Failed to get FHS reference', error);
145
+    } catch {
146
+      console.error('Failed to get FHS reference');
147147
     }
148148
   };
149149
 
@@ -155,8 +155,8 @@ const Game: React.FC = () => {
155155
         setCommandRef(response);
156156
       }
157157
       setShowCommands(true);
158
-    } catch (error) {
159
-      console.error('Failed to get command reference', error);
158
+    } catch {
159
+      console.error('Failed to get command reference');
160160
     }
161161
   };
162162
 
@@ -256,7 +256,7 @@ const Game: React.FC = () => {
256256
       }
257257
 
258258
       setCommand('');
259
-    } catch (error) {
259
+    } catch {
260260
       setCommandHistory(prev => [...prev, {
261261
         command: cmd,
262262
         output: 'Error: Failed to execute command. Check your connection.',
@@ -268,14 +268,14 @@ const Game: React.FC = () => {
268268
   };
269269
 
270270
   // Update tree data to show mole when found
271
-  const updateTreeDataToShowMole = (treeData: any, molePath: string): any => {
271
+  const updateTreeDataToShowMole = (treeData: TreeNode, molePath: string): TreeNode => {
272272
     if (treeData.path === molePath) {
273273
       return { ...treeData, has_mole: true };
274274
     }
275275
     if (treeData.children) {
276276
       return {
277277
         ...treeData,
278
-        children: treeData.children.map((child: any) => 
278
+        children: treeData.children.map((child) => 
279279
           updateTreeDataToShowMole(child, molePath)
280280
         ),
281281
       };
@@ -284,11 +284,11 @@ const Game: React.FC = () => {
284284
   };
285285
 
286286
   // Remove mole from tree data
287
-  const removeMoleFromTree = (treeData: any): any => {
287
+  const removeMoleFromTree = (treeData: TreeNode): TreeNode => {
288288
     return {
289289
       ...treeData,
290290
       has_mole: false,
291
-      children: treeData.children ? treeData.children.map((child: any) => removeMoleFromTree(child)) : []
291
+      children: treeData.children ? treeData.children.map((child) => removeMoleFromTree(child)) : []
292292
     };
293293
   };
294294
 
frontend/src/lib/api.tsmodified
@@ -1,7 +1,7 @@
11
 // src/lib/api.ts
22
 import axios from 'axios';
33
 
4
-const API_BASE_URL = 'http://localhost:8000/api';
4
+const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8000/api';
55
 
66
 const api = axios.create({
77
   baseURL: API_BASE_URL,