22
33import { useCallback , useEffect , useRef , useState } from "react" ;
44import { useMutation , useQuery , useQueryClient } from "@tanstack/react-query" ;
5- import { Loader2 , Play , RotateCcw , Save , Square , Unplug } from "lucide-react" ;
5+ import { Loader2 , Play , RotateCcw , Save , SquareStop , Unplug } from "lucide-react" ;
6+ import { useRouter } from "next/navigation" ;
67import { useSearchParams } from "next/navigation" ;
78import { toast } from "sonner" ;
89
@@ -22,13 +23,10 @@ import {
2223} from "@/components/ui/card" ;
2324import { Label } from "@/components/ui/label" ;
2425import { Separator } from "@/components/ui/separator" ;
25- import { Tabs , TabsContent , TabsList , TabsTrigger } from "@/components/ui/tabs" ;
2626import { Skeleton } from "@/components/ui/skeleton" ;
2727import { Switch } from "@/components/ui/switch" ;
28- import { TaskMessageEditor , TimerMessageEditor } from "@/components/bot-settings/message-editor" ;
29- import { CommandAliasEditor } from "@/components/bot-settings/command-alias-editor" ;
30- import { TaskVariableReference , TimerVariableReference } from "@/components/bot-settings/variable-reference" ;
3128import { CommandsReference } from "@/components/bot-settings/commands-reference" ;
29+ import { BotMessagesCard } from "@/components/bot-settings/bot-messages-card" ;
3230import { trpc } from "@/utils/trpc" ;
3331
3432const defaultTaskMessages : TaskMessagesConfig = {
@@ -107,6 +105,7 @@ function BotSettingsSkeleton() {
107105}
108106
109107export default function BotSettingsPage ( ) {
108+ const router = useRouter ( ) ;
110109 const queryClient = useQueryClient ( ) ;
111110 const searchParams = useSearchParams ( ) ;
112111 const config = useQuery ( trpc . config . get . queryOptions ( ) ) ;
@@ -117,11 +116,11 @@ export default function BotSettingsPage() {
117116 const botStatus = searchParams . get ( "bot" ) ;
118117 if ( botStatus === "connected" ) {
119118 toast . success ( "Bot account connected successfully!" ) ;
120- window . history . replaceState ( { } , "" , "/dashboard/bot" ) ;
119+ router . replace ( "/dashboard/bot" ) ;
121120 } else if ( botStatus === "error" ) {
122121 const reason = searchParams . get ( "reason" ) ?? "unknown" ;
123122 toast . error ( `Failed to connect bot account: ${ reason } ` ) ;
124- window . history . replaceState ( { } , "" , "/dashboard/bot" ) ;
123+ router . replace ( "/dashboard/bot" ) ;
125124 }
126125 } , [ searchParams ] ) ;
127126
@@ -291,7 +290,7 @@ export default function BotSettingsPage() {
291290 return (
292291 < div className = { cn ( "container mx-auto max-w-5xl px-4 py-8" , hasUnsaved && "pb-24" ) } >
293292 < div className = "mb-6" >
294- < h1 className = "text-2xl font-bold" > Bot Settings</ h1 >
293+ < h1 className = "font-heading text-2xl font-bold" > Bot Settings</ h1 >
295294 < p className = "text-sm text-muted-foreground" >
296295 Configure your bot account, response messages, and command aliases
297296 </ p >
@@ -350,7 +349,7 @@ export default function BotSettingsPage() {
350349 disabled = { stopBot . isPending }
351350 className = "text-destructive"
352351 >
353- < Square className = "size-3" />
352+ < SquareStop className = "size-3" />
354353 Stop Bot
355354 </ Button >
356355 ) : (
@@ -432,51 +431,25 @@ export default function BotSettingsPage() {
432431 </ CardContent >
433432 </ Card >
434433
435- { /* Command Aliases */ }
436- < CommandAliasEditor
437- aliases = { commandAliases }
438- onChange = { handleAliasesChange }
439- />
440434 </ div >
441435
442- { /* Right column — tabbed message editors */ }
443- < div className = "min-w-0 flex-1" >
444- < Tabs defaultValue = "task" >
445- < TabsList className = "mb-4" >
446- < TabsTrigger value = "task" > Task Messages</ TabsTrigger >
447- < TabsTrigger value = "timer" > Timer Messages</ TabsTrigger >
448- </ TabsList >
449-
450- < TabsContent value = "task" className = "space-y-4" >
451- < p className = "text-xs text-muted-foreground" >
452- Customize bot responses for task-related commands
453- </ p >
454- < TaskVariableReference />
455- < TaskMessageEditor
456- messages = { taskMessages }
457- onChange = { handleTaskMessagesChange }
458- disabled = { ! taskCommandsEnabled }
459- />
460- </ TabsContent >
461-
462- < TabsContent value = "timer" className = "space-y-4" >
463- < p className = "text-xs text-muted-foreground" >
464- Customize bot responses for timer-related commands
465- </ p >
466- < TimerVariableReference />
467- < TimerMessageEditor
468- messages = { timerMessages }
469- onChange = { handleTimerMessagesChange }
470- disabled = { ! timerCommandsEnabled }
471- />
472- </ TabsContent >
473- </ Tabs >
436+ { /* Right column — commands reference + messages */ }
437+ < div className = "min-w-0 flex-1 space-y-6" >
438+ < CommandsReference
439+ aliases = { commandAliases }
440+ onAliasesChange = { handleAliasesChange }
441+ />
442+ < BotMessagesCard
443+ taskMessages = { taskMessages }
444+ timerMessages = { timerMessages }
445+ onTaskChange = { handleTaskMessagesChange }
446+ onTimerChange = { handleTimerMessagesChange }
447+ taskCommandsEnabled = { taskCommandsEnabled }
448+ timerCommandsEnabled = { timerCommandsEnabled }
449+ />
474450 </ div >
475451 </ div >
476452
477- { /* Commands Reference — full width */ }
478- < CommandsReference />
479-
480453 { /* Sticky Save / Reset Bar */ }
481454 { hasUnsaved && (
482455 < div className = "fixed inset-x-0 bottom-0 z-40 border-t bg-background/80 backdrop-blur-2xl" >
0 commit comments