Skip to content

Commit a460759

Browse files
committed
PEER-236: UI Fixes
1 parent 1abcd02 commit a460759

File tree

5 files changed

+39
-36
lines changed

5 files changed

+39
-36
lines changed

frontend/src/components/blocks/interview/ai-chat.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const AIChat: React.FC<AIChatProps> = ({ isOpen, onClose }) => {
2121
const [messages, setMessages] = useState<ChatMessageType[]>([]);
2222
const [isLoading, setIsLoading] = useState<boolean>(false);
2323
const [error, setError] = useState<string | null>(null);
24-
const [isExpanded, setIsExpanded] = useState<boolean>(false);
2524

2625
const callOpenAI = async (userMessage: string): Promise<string> => {
2726
if (!API_KEY) {
@@ -91,8 +90,6 @@ export const AIChat: React.FC<AIChatProps> = ({ isOpen, onClose }) => {
9190
isLoading={isLoading}
9291
error={error}
9392
title='AI Assistant'
94-
isExpanded={isExpanded}
95-
setIsExpanded={setIsExpanded}
9693
/>
9794
);
9895
};

frontend/src/components/blocks/interview/chat/chat-layout.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ interface ChatLayoutProps {
1616
isLoading: boolean;
1717
error: string | null;
1818
title: string;
19-
isExpanded?: boolean;
20-
setIsExpanded?: React.Dispatch<React.SetStateAction<boolean>>;
2119
}
2220

2321
export const ChatLayout: React.FC<ChatLayoutProps> = ({
@@ -28,10 +26,9 @@ export const ChatLayout: React.FC<ChatLayoutProps> = ({
2826
isLoading,
2927
error,
3028
title,
31-
isExpanded = false,
32-
setIsExpanded,
3329
}) => {
3430
const [input, setInput] = useState<string>('');
31+
const [isExpanded, setIsExpanded] = useState<boolean>(false);
3532
const inputRef = useRef<HTMLInputElement>(null);
3633
const messagesEndRef = useRef<HTMLDivElement>(null);
3734

@@ -68,7 +65,7 @@ export const ChatLayout: React.FC<ChatLayoutProps> = ({
6865
<div
6966
className={`fixed right-0 top-14 h-[calc(100%-3.5rem)] bg-white shadow-xl transition-all duration-300 ease-in-out ${
7067
isOpen ? 'translate-x-0' : 'translate-x-full'
71-
} ${isExpanded ? 'w-3/4' : 'w-96'}`}
68+
} ${isExpanded ? 'w-3/4' : 'w-1/5'}`}
7269
>
7370
<div className='flex h-full flex-col'>
7471
<div className='flex items-center justify-between border-b bg-white px-4 py-3'>
@@ -77,16 +74,14 @@ export const ChatLayout: React.FC<ChatLayoutProps> = ({
7774
<h2 className='text-base font-semibold'>{title}</h2>
7875
</div>
7976
<div className='flex items-center gap-2'>
80-
{setIsExpanded && (
81-
<Button
82-
variant='ghost'
83-
size='icon'
84-
onClick={() => setIsExpanded(!isExpanded)}
85-
className='rounded-full hover:bg-gray-100'
86-
>
87-
{isExpanded ? <Minimize2 className='size-5' /> : <Maximize2 className='size-5' />}
88-
</Button>
89-
)}
77+
<Button
78+
variant='ghost'
79+
size='icon'
80+
onClick={() => setIsExpanded(!isExpanded)}
81+
className='rounded-full hover:bg-gray-100'
82+
>
83+
{isExpanded ? <Minimize2 className='size-5' /> : <Maximize2 className='size-5' />}
84+
</Button>
9085
<Button
9186
variant='ghost'
9287
size='icon'

frontend/src/components/blocks/interview/editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const Editor = ({ room }: EditorProps) => {
4343
}, [theme]);
4444

4545
return (
46-
<div className='flex flex-col gap-4 p-4'>
46+
<div className='flex w-full flex-col gap-4 p-4'>
4747
{isLoading ? (
4848
<div className='flex h-[60px] w-full flex-row justify-between pt-3'>
4949
<div className='flex h-10 flex-row gap-4'>

frontend/src/components/blocks/interview/floating-chat-button.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,27 @@ import { PartnerChat } from './partner-chat';
99

1010
type FloatingChatButtonProps = {
1111
room: string;
12+
onChatOpenChange: (isOpen: boolean) => void;
1213
};
1314

14-
export const FloatingChatButton = ({ room }: FloatingChatButtonProps) => {
15+
export const FloatingChatButton = ({ room, onChatOpenChange }: FloatingChatButtonProps) => {
1516
const [isAIChatOpen, setIsAIChatOpen] = useState<boolean>(false);
1617
const [isPartnerChatOpen, setIsPartnerChatOpen] = useState<boolean>(false);
1718

19+
const toggleAIChat = () => {
20+
const newStatus = !isAIChatOpen;
21+
setIsAIChatOpen(newStatus);
22+
onChatOpenChange(newStatus || isPartnerChatOpen);
23+
};
24+
25+
const togglePartnerChat = () => {
26+
const newStatus = !isPartnerChatOpen;
27+
setIsPartnerChatOpen(newStatus);
28+
onChatOpenChange(newStatus || isAIChatOpen);
29+
};
30+
1831
return (
19-
<div className='fixed bottom-6 right-6'>
32+
<div className='fixed bottom-3 right-3'>
2033
<div className='group relative'>
2134
<Button className='size-12 rounded-full bg-blue-500 shadow-lg transition-transform hover:scale-105 hover:bg-blue-600'>
2235
<MessageSquare className='size-6' />
@@ -29,7 +42,7 @@ export const FloatingChatButton = ({ room }: FloatingChatButtonProps) => {
2942
<TooltipTrigger asChild>
3043
<Button
3144
className='size-12 rounded-full bg-blue-500 hover:bg-blue-600'
32-
onClick={() => setIsAIChatOpen(true)}
45+
onClick={toggleAIChat}
3346
>
3447
<Bot className='size-10' />
3548
</Button>
@@ -46,7 +59,7 @@ export const FloatingChatButton = ({ room }: FloatingChatButtonProps) => {
4659
<TooltipTrigger asChild>
4760
<Button
4861
className='size-12 rounded-full bg-blue-500 hover:bg-blue-600'
49-
onClick={() => setIsPartnerChatOpen(true)}
62+
onClick={togglePartnerChat}
5063
>
5164
<User className='size-10' />
5265
</Button>
@@ -60,13 +73,9 @@ export const FloatingChatButton = ({ room }: FloatingChatButtonProps) => {
6073
</div>
6174
</div>
6275

63-
{isAIChatOpen && <AIChat isOpen={isAIChatOpen} onClose={() => setIsAIChatOpen(false)} />}
76+
{isAIChatOpen && <AIChat isOpen={isAIChatOpen} onClose={() => toggleAIChat()} />}
6477
{isPartnerChatOpen && (
65-
<PartnerChat
66-
roomId={room}
67-
isOpen={isPartnerChatOpen}
68-
onClose={() => setIsPartnerChatOpen(false)}
69-
/>
78+
<PartnerChat roomId={room} isOpen={isPartnerChatOpen} onClose={() => togglePartnerChat()} />
7079
)}
7180
</div>
7281
);

frontend/src/routes/interview/[room]/main.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { QueryClient, useSuspenseQuery } from '@tanstack/react-query';
2-
import { useMemo } from 'react';
2+
import { useMemo, useState } from 'react';
33
import { type LoaderFunctionArgs, Navigate, useLoaderData } from 'react-router-dom';
44

55
import { WithNavBanner, WithNavBlocker } from '@/components/blocks/authed';
@@ -28,24 +28,26 @@ export const InterviewRoom = () => {
2828
const { questionId, roomId } = useLoaderData() as Awaited<ReturnType<ReturnType<typeof loader>>>;
2929
const { crumbs } = useCrumbs();
3030
const { data: details } = useSuspenseQuery(questionDetailsQuery(questionId));
31-
const questionDetails = useMemo(() => {
32-
return details.question;
33-
}, [details]);
31+
const questionDetails = useMemo(() => details.question, [details]);
32+
const [isChatOpen, setIsChatOpen] = useState(false);
33+
3434
return !questionId || !roomId ? (
3535
<Navigate to={ROUTES.HOME} />
3636
) : (
3737
<WithNavBlocker>
3838
<WithNavBanner crumbs={crumbs}>
3939
<div className='flex'>
40-
<div className='flex flex-1 overflow-hidden'>
40+
<div className={`flex ${isChatOpen ? 'w-4/5' : 'w-full'} transition-all duration-300`}>
4141
<Card className='border-border m-4 w-1/3 max-w-[500px] overflow-hidden p-4 md:w-2/5'>
4242
<QuestionDetails {...{ questionDetails }} />
4343
</Card>
44-
<div className='flex flex-1 flex-col overflow-hidden'>
44+
<div
45+
className={`flex flex-1 ${isChatOpen ? 'w-2/3' : 'w-full'} transition-all duration-300`}
46+
>
4547
<Editor room={roomId as string} />
4648
</div>
47-
<FloatingChatButton room={roomId as string} />
4849
</div>
50+
<FloatingChatButton room={roomId as string} onChatOpenChange={setIsChatOpen} />
4951
</div>
5052
</WithNavBanner>
5153
</WithNavBlocker>

0 commit comments

Comments
 (0)