From c1e6ab9360c56de05164ab3110ad20c0292fdce8 Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Fri, 20 Jun 2025 11:55:25 -0700 Subject: [PATCH] Prettier and eslint fixes in progress --- frontend/src/components/layout/Header.tsx | 12 +++- .../src/components/ui/CandidatePicker.tsx | 3 +- frontend/src/components/ui/ComingSoon.tsx | 1 - frontend/src/pages/BetaPage.tsx | 2 +- frontend/src/pages/CandidateChatPage.tsx | 3 +- frontend/src/pages/HowItWorks.tsx | 1 - frontend/src/pages/LoginPage.tsx | 3 +- frontend/src/routes/CandidateRoute.tsx | 3 +- frontend/src/services/api-client.ts | 61 +++++++++++-------- 9 files changed, 49 insertions(+), 40 deletions(-) diff --git a/frontend/src/components/layout/Header.tsx b/frontend/src/components/layout/Header.tsx index 83f5504..22e5e43 100644 --- a/frontend/src/components/layout/Header.tsx +++ b/frontend/src/components/layout/Header.tsx @@ -171,7 +171,9 @@ const Header: React.FC = (props: HeaderProps) => { id: 'divider', label: '', icon: null, - action: () => {}, + action: () => { + console.log('Divider clicked'); + }, group: 'divider', }); } @@ -197,7 +199,9 @@ const Header: React.FC = (props: HeaderProps) => { id: 'divider', label: '', icon: null, - action: () => {}, + action: () => { + console.log('Divider clicked'); + }, group: 'divider', }); } @@ -223,7 +227,9 @@ const Header: React.FC = (props: HeaderProps) => { id: 'divider', label: '', icon: null, - action: () => {}, + action: () => { + console.log('Divider clicked'); + }, group: 'divider', }); } diff --git a/frontend/src/components/ui/CandidatePicker.tsx b/frontend/src/components/ui/CandidatePicker.tsx index 762c507..1de1e08 100644 --- a/frontend/src/components/ui/CandidatePicker.tsx +++ b/frontend/src/components/ui/CandidatePicker.tsx @@ -1,5 +1,4 @@ import React, { useEffect, useState } from 'react'; -import { useNavigate } from 'react-router-dom'; import Box from '@mui/material/Box'; import { BackstoryElementProps } from 'components/BackstoryTab'; @@ -15,7 +14,7 @@ interface CandidatePickerProps extends BackstoryElementProps { const CandidatePicker = (props: CandidatePickerProps) => { const { onSelect, sx } = props; - const { apiClient, user } = useAuth(); + const { apiClient } = useAuth(); const { selectedCandidate, setSelectedCandidate } = useSelectedCandidate(); const { setSnack } = useAppState(); const [candidates, setCandidates] = useState(null); diff --git a/frontend/src/components/ui/ComingSoon.tsx b/frontend/src/components/ui/ComingSoon.tsx index e3484b0..27c9952 100644 --- a/frontend/src/components/ui/ComingSoon.tsx +++ b/frontend/src/components/ui/ComingSoon.tsx @@ -1,6 +1,5 @@ import React from 'react'; import Box from '@mui/material/Box'; -import { useTheme } from '@mui/material/styles'; import './ComingSoon.css'; diff --git a/frontend/src/pages/BetaPage.tsx b/frontend/src/pages/BetaPage.tsx index 806fe4f..da857f1 100644 --- a/frontend/src/pages/BetaPage.tsx +++ b/frontend/src/pages/BetaPage.tsx @@ -202,7 +202,7 @@ const BetaPage: React.FC = ({ }} /> - We're working hard to bring you this exciting new feature! + We're working hard to bring you this exciting new feature! Check back soon for updates. diff --git a/frontend/src/pages/CandidateChatPage.tsx b/frontend/src/pages/CandidateChatPage.tsx index 5cdd2bc..bf89f1a 100644 --- a/frontend/src/pages/CandidateChatPage.tsx +++ b/frontend/src/pages/CandidateChatPage.tsx @@ -1,5 +1,5 @@ import React, { forwardRef, useState, useEffect, useRef } from 'react'; -import { Box, Paper, Button, useTheme, Tooltip } from '@mui/material'; +import { Box, Paper, Button, Tooltip } from '@mui/material'; import { Send as SendIcon } from '@mui/icons-material'; import { useAuth } from 'hooks/AuthContext'; import { @@ -15,7 +15,6 @@ import { BackstoryPageProps } from 'components/BackstoryTab'; import { Message } from 'components/Message'; import { DeleteConfirmation } from 'components/DeleteConfirmation'; import { CandidateInfo } from 'components/ui/CandidateInfo'; -import { useNavigate } from 'react-router-dom'; import { useAppState, useSelectedCandidate } from 'hooks/GlobalContext'; import PropagateLoader from 'react-spinners/PropagateLoader'; import { BackstoryTextField, BackstoryTextFieldRef } from 'components/BackstoryTextField'; diff --git a/frontend/src/pages/HowItWorks.tsx b/frontend/src/pages/HowItWorks.tsx index c769db8..d9bbc91 100644 --- a/frontend/src/pages/HowItWorks.tsx +++ b/frontend/src/pages/HowItWorks.tsx @@ -227,7 +227,6 @@ const HeroButton = (props: HeroButtonProps) => { const HowItWorks: React.FC = () => { const navigate = useNavigate(); - const theme = useTheme(); const handleGetStarted = () => { navigate('/job-analysis'); diff --git a/frontend/src/pages/LoginPage.tsx b/frontend/src/pages/LoginPage.tsx index 2eb4823..6bbdb31 100644 --- a/frontend/src/pages/LoginPage.tsx +++ b/frontend/src/pages/LoginPage.tsx @@ -24,9 +24,8 @@ import { LoginForm } from 'components/EmailVerificationComponents'; import { CandidateRegistrationForm } from 'pages/candidate/RegistrationForms'; import { useNavigate, useParams } from 'react-router-dom'; import { useAppState } from 'hooks/GlobalContext'; -import * as Types from 'types/types'; -const LoginPage: React.FC = (props: BackstoryPageProps) => { +const LoginPage: React.FC = (_props: BackstoryPageProps) => { const navigate = useNavigate(); const { setSnack } = useAppState(); const [tabValue, setTabValue] = useState('login'); diff --git a/frontend/src/routes/CandidateRoute.tsx b/frontend/src/routes/CandidateRoute.tsx index cf507cf..3aa661a 100644 --- a/frontend/src/routes/CandidateRoute.tsx +++ b/frontend/src/routes/CandidateRoute.tsx @@ -2,7 +2,6 @@ import React, { useEffect } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; import { Box } from '@mui/material'; -import { SetSnackType } from '../components/Snack'; import { LoadingComponent } from '../components/LoadingComponent'; import { User, Guest, Candidate } from 'types/types'; import { useAuth } from 'hooks/AuthContext'; @@ -13,7 +12,7 @@ interface CandidateRouteProps { user?: User | null; } -const CandidateRoute: React.FC = (props: CandidateRouteProps) => { +const CandidateRoute: React.FC = (_props: CandidateRouteProps) => { const { apiClient } = useAuth(); const { selectedCandidate, setSelectedCandidate } = useSelectedCandidate(); const { setSnack } = useAppState(); diff --git a/frontend/src/services/api-client.ts b/frontend/src/services/api-client.ts index fdbd7bb..36f6e3f 100644 --- a/frontend/src/services/api-client.ts +++ b/frontend/src/services/api-client.ts @@ -1470,11 +1470,13 @@ class ApiClient { let streamingMessage: Types.ChatMessageStreaming | null = null; try { - while (true) { + let exit = false; + while (!exit) { const { done, value } = await reader.read(); if (done) { // Stream ended naturally + exit = true; break; } @@ -1495,40 +1497,48 @@ class ApiClient { // Handle different status types switch (incoming.status) { case 'streaming': - const streaming = Types.convertChatMessageStreamingFromApi(incoming); - if (streamingMessage === null) { - streamingMessage = { ...streaming }; - } else { - // Can't do a simple += as typescript thinks .content might not be there - streamingMessage.content = - (streamingMessage?.content || '') + streaming.content; - // Update timestamp to latest - streamingMessage.timestamp = streaming.timestamp; + { + const streaming = Types.convertChatMessageStreamingFromApi(incoming); + if (streamingMessage === null) { + streamingMessage = { ...streaming }; + } else { + // Can't do a simple += as typescript thinks .content might not be there + streamingMessage.content = + (streamingMessage?.content || '') + streaming.content; + // Update timestamp to latest + streamingMessage.timestamp = streaming.timestamp; + } + options.onStreaming?.(streamingMessage); } - options.onStreaming?.(streamingMessage); break; case 'status': - const status = Types.convertChatMessageStatusFromApi(incoming); - options.onStatus?.(status); + { + const status = Types.convertChatMessageStatusFromApi(incoming); + options.onStatus?.(status); + } break; case 'error': - const error = Types.convertChatMessageErrorFromApi(incoming); - options.onError?.(error); + { + const error = Types.convertChatMessageErrorFromApi(incoming); + options.onError?.(error); + } break; case 'done': - const message = ( - modelType - ? convertFromApi(parseApiResponse(incoming), modelType) - : incoming - ) as T; - finalMessage = message; - try { - options.onMessage?.(message); - } catch (error) { - console.error('onMessage handler failed: ', error); + { + const message = ( + modelType + ? convertFromApi(parseApiResponse(incoming), modelType) + : incoming + ) as T; + finalMessage = message; + try { + options.onMessage?.(message); + } catch (error) { + console.error('onMessage handler failed: ', error); + } } break; } @@ -1538,7 +1548,6 @@ class ApiClient { if (error instanceof Error) { options.onWarn?.(error.message); } - // Continue processing other lines } } }