refactor: update chat input handling, prune unused settings menu items, and enable turbopack configuration
This commit is contained in:
@@ -5,6 +5,7 @@ import { Brain, Send, MessageSquare, Plus, Trash2, Loader2, Wrench } from "lucid
|
|||||||
import { createClient } from "@/lib/supabase/client";
|
import { createClient } from "@/lib/supabase/client";
|
||||||
import { Button } from "poyraz-ui/atoms";
|
import { Button } from "poyraz-ui/atoms";
|
||||||
import { useChat } from "@ai-sdk/react";
|
import { useChat } from "@ai-sdk/react";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
interface ChatSession {
|
interface ChatSession {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -18,16 +19,22 @@ export default function AIChatPage() {
|
|||||||
const [activeSessionId, setActiveSessionId] = useState<string | null>(null);
|
const [activeSessionId, setActiveSessionId] = useState<string | null>(null);
|
||||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const { messages, input, setInput, handleInputChange, handleSubmit, append, setMessages, isLoading, stop } = useChat({
|
const [input, setInput] = useState("");
|
||||||
|
const { messages, append, setMessages, isLoading, stop } = useChat({
|
||||||
api: "/api/chat",
|
api: "/api/chat",
|
||||||
body: {
|
body: {
|
||||||
sessionId: activeSessionId
|
sessionId: activeSessionId
|
||||||
},
|
},
|
||||||
onError: (err) => {
|
onError: (err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
toast.error(err.message || "Yapay zeka ile iletişim kurulurken bir hata oluştu.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleInputChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
||||||
|
setInput(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
// Auto-scroll to bottom
|
// Auto-scroll to bottom
|
||||||
const scrollToBottom = () => {
|
const scrollToBottom = () => {
|
||||||
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { User, Bell, Shield, Blocks, Brain, CreditCard, Save, Key, AlertTriangle } from "lucide-react";
|
import { User, Shield, Brain, Save, Key, AlertTriangle } from "lucide-react";
|
||||||
import { updatePassword, updateProfile } from "./actions";
|
import { updatePassword, updateProfile } from "./actions";
|
||||||
import { createClient } from "@/lib/supabase/client";
|
import { createClient } from "@/lib/supabase/client";
|
||||||
import { Button, Card, CardContent, Input, Label } from "poyraz-ui/atoms";
|
import { Button, Card, CardContent, Input, Label } from "poyraz-ui/atoms";
|
||||||
@@ -33,9 +33,6 @@ export default function SettingsPage() {
|
|||||||
{ name: "Profile & Account", icon: User },
|
{ name: "Profile & Account", icon: User },
|
||||||
{ name: "AI Preferences", icon: Brain },
|
{ name: "AI Preferences", icon: Brain },
|
||||||
{ name: "Security", icon: Shield },
|
{ name: "Security", icon: Shield },
|
||||||
{ name: "Integrations", icon: Blocks },
|
|
||||||
{ name: "Notifications", icon: Bell },
|
|
||||||
{ name: "Billing & Plans", icon: CreditCard },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ export function DashboardShell({ children, user }: DashboardShellProps) {
|
|||||||
return (
|
return (
|
||||||
<div className="min-h-screen bg-background text-foreground">
|
<div className="min-h-screen bg-background text-foreground">
|
||||||
<div className="flex min-h-screen">
|
<div className="flex min-h-screen">
|
||||||
<aside className="sticky top-0 hidden h-dvh w-[280px] shrink-0 self-start border-r border-border bg-background lg:block">
|
<aside className="sticky top-0 hidden h-dvh shrink-0 self-start border-r border-border bg-background lg:block">
|
||||||
<AppSidebar pathname={pathname} user={user} />
|
<AppSidebar pathname={pathname} user={user} />
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ export function DashboardShell({ children, user }: DashboardShellProps) {
|
|||||||
className="absolute inset-0 bg-overlay"
|
className="absolute inset-0 bg-overlay"
|
||||||
onClick={() => setIsMobileSidebarOpen(false)}
|
onClick={() => setIsMobileSidebarOpen(false)}
|
||||||
/>
|
/>
|
||||||
<aside className="relative h-dvh w-[min(88vw,300px)] border-r border-border bg-background">
|
<aside className="relative h-dvh border-r border-border bg-background">
|
||||||
<AppSidebar
|
<AppSidebar
|
||||||
pathname={pathname}
|
pathname={pathname}
|
||||||
user={user}
|
user={user}
|
||||||
@@ -70,7 +70,7 @@ export function DashboardShell({ children, user }: DashboardShellProps) {
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<div className="flex min-w-0 flex-1 flex-col">
|
<div className="flex flex-1 flex-col">
|
||||||
<header className="sticky top-0 z-30 flex h-14 items-center justify-between border-b border-border bg-background/95 px-4 backdrop-blur lg:hidden">
|
<header className="sticky top-0 z-30 flex h-14 items-center justify-between border-b border-border bg-background/95 px-4 backdrop-blur lg:hidden">
|
||||||
<Link href="/" className="flex items-center gap-2 font-semibold">
|
<Link href="/" className="flex items-center gap-2 font-semibold">
|
||||||
<Image
|
<Image
|
||||||
@@ -78,7 +78,7 @@ export function DashboardShell({ children, user }: DashboardShellProps) {
|
|||||||
alt="Cognis"
|
alt="Cognis"
|
||||||
width={32}
|
width={32}
|
||||||
height={32}
|
height={32}
|
||||||
className="h-8 w-8 rounded-sm object-cover"
|
className="rounded-sm object-cover"
|
||||||
priority
|
priority
|
||||||
/>
|
/>
|
||||||
Cognis
|
Cognis
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const nextConfig: NextConfig = {
|
|||||||
bodySizeLimit: "8mb",
|
bodySizeLimit: "8mb",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
turbopack: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default withPWA(nextConfig);
|
export default withPWA(nextConfig);
|
||||||
|
|||||||
Reference in New Issue
Block a user