11import { Label } from "@/components/ui/label" ;
22import { Button } from "@/components/ui/button" ;
3- import { Input } from "@/components/ui/input" ;
4- import { Badge } from "@/components/ui/badge" ;
5- import { useState } from "react" ;
6- import { FileText , Mail , GitCommit , Sparkles , X } from "lucide-react" ;
3+ import { FileText , Mail , GitCommit , Sparkles } from "lucide-react" ;
74
85interface EnhancementSettingsProps {
96 settings : {
107 preset : "Default" | "Prompts" | "Email" | "Commit" ;
118 customVocabulary : string [ ] ;
129 } ;
1310 onSettingsChange : ( settings : any ) => void ;
11+ disabled ?: boolean ;
1412}
1513
16- export function EnhancementSettings ( { settings, onSettingsChange } : EnhancementSettingsProps ) {
17- const [ vocabularyInput , setVocabularyInput ] = useState ( "" ) ;
18-
14+ export function EnhancementSettings ( { settings, onSettingsChange, disabled = false } : EnhancementSettingsProps ) {
1915 const presets = [
2016 {
2117 id : "Default" ,
@@ -52,32 +48,9 @@ export function EnhancementSettings({ settings, onSettingsChange }: EnhancementS
5248 }
5349 } ;
5450
55- const handleAddVocabulary = ( ) => {
56- const terms = vocabularyInput . split ( "," ) . map ( t => t . trim ( ) ) . filter ( t => t ) ;
57- if ( terms . length > 0 ) {
58- onSettingsChange ( {
59- ...settings ,
60- customVocabulary : [ ...settings . customVocabulary , ...terms ]
61- } ) ;
62- setVocabularyInput ( "" ) ;
63- }
64- } ;
65-
66- const handleKeyDown = ( e : React . KeyboardEvent < HTMLInputElement > ) => {
67- if ( e . key === 'Enter' && vocabularyInput . trim ( ) ) {
68- handleAddVocabulary ( ) ;
69- }
70- } ;
71-
72- const handleRemoveTerm = ( term : string ) => {
73- onSettingsChange ( {
74- ...settings ,
75- customVocabulary : settings . customVocabulary . filter ( t => t !== term )
76- } ) ;
77- } ;
7851
7952 return (
80- < div className = " space-y-6" >
53+ < div className = { ` space-y-6 ${ disabled ? 'opacity-50' : '' } ` } >
8154 { /* Enhancement Mode */ }
8255 < div className = "space-y-3" >
8356 < Label className = "text-sm font-medium" > Enhancement Mode</ Label >
@@ -91,8 +64,9 @@ export function EnhancementSettings({ settings, onSettingsChange }: EnhancementS
9164 key = { preset . id }
9265 variant = { isSelected ? "default" : "outline" }
9366 size = "sm"
94- className = "gap-2"
95- onClick = { ( ) => handlePresetChange ( preset . id ) }
67+ className = { `gap-2 ${ disabled ? 'cursor-not-allowed' : '' } ` }
68+ onClick = { ( ) => ! disabled && handlePresetChange ( preset . id ) }
69+ disabled = { disabled }
9670 >
9771 < Icon className = "h-4 w-4" />
9872 { preset . label }
@@ -109,40 +83,6 @@ export function EnhancementSettings({ settings, onSettingsChange }: EnhancementS
10983 { settings . preset === "Commit" && "Creates conventional commit messages with type and scope" }
11084 </ p >
11185 </ div >
112-
113- { /* Custom Vocabulary */ }
114- < div className = "space-y-3" >
115- < Label className = "text-sm font-medium" > Custom Vocabulary</ Label >
116- < Input
117- placeholder = "Add terms (comma separated)"
118- value = { vocabularyInput }
119- onChange = { ( e ) => setVocabularyInput ( e . target . value ) }
120- onKeyDown = { handleKeyDown }
121- className = "text-sm"
122- />
123-
124- { settings . customVocabulary . length > 0 && (
125- < div className = "flex flex-wrap gap-1.5" >
126- { settings . customVocabulary . map ( ( term ) => (
127- < Badge
128- key = { term }
129- variant = "secondary"
130- className = "gap-1 pr-1"
131- >
132- { term }
133- < Button
134- variant = "ghost"
135- size = "sm"
136- className = "h-4 w-4 p-0 hover:bg-transparent"
137- onClick = { ( ) => handleRemoveTerm ( term ) }
138- >
139- < X className = "h-3 w-3" />
140- </ Button >
141- </ Badge >
142- ) ) }
143- </ div >
144- ) }
145- </ div >
14686 </ div >
14787 ) ;
14888}
0 commit comments