1- import { useState } from "react" ;
1+ import { Fragment , useState } from "react" ;
22import { Icon } from "@iconify/react" ;
33import { Modal } from "../../../components/modal" ;
44import { SettingsSectionContainer , SettingsSectionTitle } from "./components" ;
@@ -10,15 +10,15 @@ export const ApiKeySettings = () => {
1010
1111 const [ isShowModal , setIsShowModal ] = useState < boolean > ( false ) ;
1212
13- const handleCustomModelChange = ( newModel : CustomModel , isDelete : boolean ) => {
13+ const handleCustomModelChange = async ( newModel : CustomModel , isDelete : boolean ) => {
1414 const otherCustomModels = Array . from ( settings ?. customModels || [ ] ) . filter ( ( model ) => model . id != newModel . id ) ;
1515
1616 if ( isDelete ) {
17- updateSettings ( {
17+ await updateSettings ( {
1818 customModels : otherCustomModels ,
1919 } ) ;
2020 } else {
21- updateSettings ( {
21+ await updateSettings ( {
2222 customModels : [
2323 ...otherCustomModels ,
2424 {
@@ -50,12 +50,11 @@ export const ApiKeySettings = () => {
5050 < div className = "flex flex-col h-[80vh] gap-4 p-4 overflow-y-auto" >
5151 < CustomModelSection key = { "new_custom_model" } isNew onChange = { handleCustomModelChange } />
5252 { Array . from ( settings ?. customModels || [ ] ) . map ( ( m ) => (
53- < >
53+ < Fragment key = { m . id } >
5454 < hr > </ hr >
5555 < CustomModelSection
5656 isNew = { false }
5757 onChange = { handleCustomModelChange }
58- key = { m . id }
5958 model = { {
6059 id : m . id ,
6160 name : m . name ,
@@ -68,7 +67,7 @@ export const ApiKeySettings = () => {
6867 outputPrice : m . outputPrice ,
6968 } }
7069 />
71- </ >
70+ </ Fragment >
7271 ) ) }
7372 </ div >
7473 }
@@ -126,7 +125,7 @@ const CustomModelSection = ({ isNew, onChange, model: customModel }: CustomModel
126125 const detailInputClassName = `${ baseClassName } ${ isEditing || isNew ? borderedInputClassName : "" } flex-1 noselect focus:outline-none text-xs text-default-700 placeholder:text-default-400` ;
127126 const errorInputClassName = "!border-red-500 focus:!border-red-500" ;
128127
129- const handleOnChange = ( isDelete : boolean ) => {
128+ const handleOnChange = async ( isDelete : boolean ) => {
130129 if (
131130 modelName . trim ( ) . length < 1 ||
132131 slug . trim ( ) . length < 1 ||
@@ -140,7 +139,7 @@ const CustomModelSection = ({ isNew, onChange, model: customModel }: CustomModel
140139 return ;
141140 }
142141
143- onChange (
142+ await onChange (
144143 {
145144 id : id ,
146145 name : modelName . trim ( ) ,
0 commit comments