@@ -45,7 +45,7 @@ import { Label } from "./ui/label";
4545import { Input } from "./ui/input" ;
4646import { SetAPIsTemplate } from "./setAPIsTemplate" ;
4747import { isVailedJSON } from "@/utils/isVailedJSON" ;
48- import { toast } from ' sonner' ;
48+ import { toast } from " sonner" ;
4949import { ConfirmationDialog } from "./ui/confirmation-dialog" ;
5050
5151interface APITemplateDropdownProps {
@@ -61,7 +61,11 @@ interface EditTemplateDialogProps {
6161 onClose : ( ) => void ;
6262}
6363
64- function EditTemplateDialog ( { template, onSave, onClose } : EditTemplateDialogProps ) {
64+ function EditTemplateDialog ( {
65+ template,
66+ onSave,
67+ onClose,
68+ } : EditTemplateDialogProps ) {
6569 const [ name , setName ] = useState ( template . name ) ;
6670 const [ endpoint , setEndpoint ] = useState ( template . endpoint ) ;
6771 const [ key , setKey ] = useState ( template . key ) ;
@@ -151,9 +155,13 @@ function APIsDropdownList({
151155 } = useContext ( AppContext ) ;
152156 const { toast } = useToast ( ) ;
153157 const [ open , setOpen ] = React . useState ( false ) ;
154- const [ editingTemplate , setEditingTemplate ] = useState < TemplateAPI | null > ( null ) ;
158+ const [ editingTemplate , setEditingTemplate ] = useState < TemplateAPI | null > (
159+ null
160+ ) ;
155161 const [ deleteDialogOpen , setDeleteDialogOpen ] = useState ( false ) ;
156- const [ templateToDelete , setTemplateToDelete ] = useState < TemplateAPI | null > ( null ) ;
162+ const [ templateToDelete , setTemplateToDelete ] = useState < TemplateAPI | null > (
163+ null
164+ ) ;
157165
158166 let API = templateAPIs ;
159167 let setAPI = setTemplateAPIs ;
@@ -176,7 +184,7 @@ function APIsDropdownList({
176184 } ;
177185
178186 const handleSave = ( updatedTemplate : TemplateAPI ) => {
179- const index = API . findIndex ( t => t . name === updatedTemplate . name ) ;
187+ const index = API . findIndex ( ( t ) => t . name === updatedTemplate . name ) ;
180188 if ( index !== - 1 ) {
181189 const newAPI = [ ...API ] ;
182190 newAPI [ index ] = updatedTemplate ;
@@ -195,7 +203,7 @@ function APIsDropdownList({
195203
196204 const confirmDelete = ( ) => {
197205 if ( templateToDelete ) {
198- const newAPI = API . filter ( t => t . name !== templateToDelete . name ) ;
206+ const newAPI = API . filter ( ( t ) => t . name !== templateToDelete . name ) ;
199207 setAPI ( newAPI ) ;
200208 toast ( {
201209 title : "Success" ,
@@ -375,7 +383,11 @@ interface EditChatTemplateDialogProps {
375383 onClose : ( ) => void ;
376384}
377385
378- function EditChatTemplateDialog ( { template, onSave, onClose } : EditChatTemplateDialogProps ) {
386+ function EditChatTemplateDialog ( {
387+ template,
388+ onSave,
389+ onClose,
390+ } : EditChatTemplateDialogProps ) {
379391 const [ name , setName ] = useState ( template . name ) ;
380392 const [ jsonContent , setJsonContent ] = useState ( ( ) => {
381393 const { name : _ , ...rest } = template ;
@@ -389,26 +401,26 @@ function EditChatTemplateDialog({ template, onSave, onClose }: EditChatTemplateD
389401
390402 const handleFormat = ( ) => {
391403 if ( editor ) {
392- editor . getAction ( ' editor.action.formatDocument' ) . run ( ) ;
404+ editor . getAction ( " editor.action.formatDocument" ) . run ( ) ;
393405 }
394406 } ;
395407
396408 const handleSave = ( ) => {
397409 if ( ! name . trim ( ) ) {
398- toast . error ( ' Template name cannot be empty' ) ;
410+ toast . error ( " Template name cannot be empty" ) ;
399411 return ;
400412 }
401413
402414 try {
403415 const parsedJson = JSON . parse ( jsonContent ) ;
404416 const updatedTemplate : TemplateChatStore = {
405417 name : name . trim ( ) ,
406- ...parsedJson
418+ ...parsedJson ,
407419 } ;
408420 onSave ( updatedTemplate ) ;
409- toast . success ( ' Template updated successfully' ) ;
421+ toast . success ( " Template updated successfully" ) ;
410422 } catch ( error ) {
411- toast . error ( ' Invalid JSON format' ) ;
423+ toast . error ( " Invalid JSON format" ) ;
412424 }
413425 } ;
414426
@@ -444,16 +456,16 @@ function EditChatTemplateDialog({ template, onSave, onClose }: EditChatTemplateD
444456 height = "400px"
445457 defaultLanguage = "json"
446458 value = { jsonContent }
447- onChange = { ( value ) => setJsonContent ( value || '' ) }
459+ onChange = { ( value ) => setJsonContent ( value || "" ) }
448460 onMount = { handleEditorDidMount }
449461 options = { {
450462 minimap : { enabled : false } ,
451463 fontSize : 14 ,
452- lineNumbers : 'on' ,
464+ lineNumbers : "on" ,
453465 scrollBeyondLastLine : false ,
454466 automaticLayout : true ,
455467 tabSize : 2 ,
456- wordWrap : 'on'
468+ wordWrap : "on" ,
457469 } }
458470 />
459471 </ div >
@@ -476,19 +488,22 @@ function ChatTemplateDropdownList() {
476488 const { chatStore, setChatStore } = useContext ( AppChatStoreContext ) ;
477489 const { templates, setTemplates } = useContext ( AppContext ) ;
478490 const [ open , setOpen ] = React . useState ( false ) ;
479- const [ editingTemplate , setEditingTemplate ] = useState < TemplateChatStore | null > ( null ) ;
491+ const [ editingTemplate , setEditingTemplate ] =
492+ useState < TemplateChatStore | null > ( null ) ;
480493 const { toast } = useToast ( ) ;
481494 const [ confirmDialogOpen , setConfirmDialogOpen ] = useState ( false ) ;
482- const [ templateToApply , setTemplateToApply ] = useState < TemplateChatStore | null > ( null ) ;
495+ const [ templateToApply , setTemplateToApply ] =
496+ useState < TemplateChatStore | null > ( null ) ;
483497 const [ deleteDialogOpen , setDeleteDialogOpen ] = useState ( false ) ;
484- const [ templateToDelete , setTemplateToDelete ] = useState < TemplateChatStore | null > ( null ) ;
498+ const [ templateToDelete , setTemplateToDelete ] =
499+ useState < TemplateChatStore | null > ( null ) ;
485500
486501 const handleEdit = ( template : TemplateChatStore ) => {
487502 setEditingTemplate ( template ) ;
488503 } ;
489504
490505 const handleSave = ( updatedTemplate : TemplateChatStore ) => {
491- const index = templates . findIndex ( t => t . name === updatedTemplate . name ) ;
506+ const index = templates . findIndex ( ( t ) => t . name === updatedTemplate . name ) ;
492507 if ( index !== - 1 ) {
493508 const newTemplates = [ ...templates ] ;
494509 newTemplates [ index ] = updatedTemplate ;
@@ -507,7 +522,9 @@ function ChatTemplateDropdownList() {
507522
508523 const confirmDelete = ( ) => {
509524 if ( templateToDelete ) {
510- const newTemplates = templates . filter ( t => t . name !== templateToDelete . name ) ;
525+ const newTemplates = templates . filter (
526+ ( t ) => t . name !== templateToDelete . name
527+ ) ;
511528 setTemplates ( newTemplates ) ;
512529 toast ( {
513530 title : "Success" ,
0 commit comments