Skip to content

Commit 98f7ba8

Browse files
author
pengyu
committed
fix the click sidebar codefox and icon will not turn to main page
1 parent 9644c22 commit 98f7ba8

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

frontend/src/app/(main)/page.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@ import { useAuthContext } from '@/providers/AuthProvider';
88
import { ProjectsSection } from '@/components/root/projects-section';
99
import { PromptForm, PromptFormRef } from '@/components/root/prompt-form';
1010
import { ProjectContext } from '@/components/chat/code-engine/project-context';
11-
12-
// ✅ Import your SignInModal and SignUpModal
1311
import { SignInModal } from '@/components/sign-in-modal';
1412
import { SignUpModal } from '@/components/sign-up-modal';
15-
13+
import { useRouter } from 'next/navigation';
1614
export default function HomePage() {
1715
// States for AuthChoiceModal
1816
const [showAuthChoice, setShowAuthChoice] = useState(false);
19-
20-
// ✅ Add states for sign in / sign up modals
17+
const router = useRouter();
2118
const [showSignIn, setShowSignIn] = useState(false);
2219
const [showSignUp, setShowSignUp] = useState(false);
2320

@@ -32,11 +29,8 @@ export default function HomePage() {
3229
if (!message.trim()) return;
3330

3431
try {
35-
const result = await createProjectFromPrompt(message, isPublic, model);
36-
if (result) {
37-
promptFormRef.current.clearMessage();
38-
// No need to navigate here, ProjectContext handles navigation
39-
}
32+
await createProjectFromPrompt(message, isPublic, model);
33+
promptFormRef.current.clearMessage();
4034
} catch (error) {
4135
console.error('Error creating project:', error);
4236
}
@@ -76,7 +70,6 @@ export default function HomePage() {
7670
ref={promptFormRef}
7771
isAuthorized={isAuthorized}
7872
onSubmit={handleSubmit}
79-
// 💡 If the user isn't authorized, show the AuthChoiceModal
8073
onAuthRequired={() => setShowAuthChoice(true)}
8174
isLoading={isLoading}
8275
/>
@@ -92,9 +85,7 @@ export default function HomePage() {
9285
isOpen={showAuthChoice}
9386
onClose={() => setShowAuthChoice(false)}
9487
onSignUpClick={() => {
95-
// 1) Close the AuthChoice
9688
setShowAuthChoice(false);
97-
// 2) Then open SignUpModal
9889
setTimeout(() => {
9990
setShowSignUp(true);
10091
}, 100);

frontend/src/components/root/nav.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ const FloatingNavbar = forwardRef<NavbarRef, FloatingNavbarProps>(
182182

183183
return (
184184
<>
185-
<div className={`fixed top-5 left-0 right-0 z-50 ${className}`}>
185+
<div className={` top-5 left-0 right-0 z-50 ${className}`}>
186186
<motion.div
187187
className={`w-full flex justify-around items-center px-6 py-4 ${containerClassName}`}
188188
initial="hidden"

frontend/src/components/sidebar.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import UserSettings from './user-settings';
88
import { SideBarItem } from './sidebar-item';
99
import { Chat } from '@/graphql/type';
1010
import { EventEnum } from '../const/EventEnum';
11+
import { useRouter } from 'next/navigation';
1112

1213
import {
1314
SidebarContent,
@@ -48,6 +49,7 @@ export function ChatSideBar({
4849
onRefetch,
4950
}: SidebarProps) {
5051
// Use a local state only for the currently selected chat.
52+
const router = useRouter();
5153
const [currentChatid, setCurrentChatid] = useState('');
5254
const { setCurProject, pollChatProject } = useContext(ProjectContext);
5355
// Handler for starting a new chat.
@@ -82,8 +84,27 @@ export function ChatSideBar({
8284
className="lg:flex items-center justify-center cursor-pointer p-2 ml-3.5 mt-2"
8385
onClick={() => setIsCollapsed(!isCollapsed)}
8486
/>
85-
86-
<div className="flex items-center justify-start w-[85%] h-14 text-sm xl:text-lg font-normal pl-4 gap-2">
87+
<Button
88+
onClick={() => router.push('/')}
89+
variant="ghost"
90+
className="
91+
w-full
92+
h-14
93+
flex
94+
items-center
95+
justify-start
96+
px-4
97+
gap-2
98+
text-sm
99+
xl:text-lg
100+
font-normal
101+
rounded-md
102+
hover:bg-yellow-50
103+
transition-all
104+
duration-200
105+
ease-in-out
106+
"
107+
>
87108
<Image
88109
src="/codefox.svg"
89110
alt="CodeFox Logo"
@@ -96,9 +117,10 @@ export function ChatSideBar({
96117
CodeFox
97118
</span>
98119
)}
99-
</div>
120+
</Button>
121+
100122
{/* Divider Line */}
101-
<div className="border-t border-dotted border-gray-300 my-2 w-[85%] mx-auto"></div>
123+
<div className="border-t border-dotted border-gray-300 my-2 w-full mx-auto" />
102124

103125
<Button
104126
onClick={() => setIsModalOpen(true)}

frontend/src/graphql/schema.gql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ input CreateProjectInput {
5454
public: Boolean
5555
}
5656

57-
"""
58-
Date custom scalar type
59-
"""
57+
"""Date custom scalar type"""
6058
scalar Date
6159

6260
input FetchPublicProjectsInputs {
@@ -221,4 +219,4 @@ type User {
221219
subscribedProjects: [Project!] @deprecated(reason: "Use projects with forkedFromId instead")
222220
updatedAt: Date!
223221
username: String!
224-
}
222+
}

0 commit comments

Comments
 (0)