@@ -13,6 +13,7 @@ import {
1313 OutlinedInput ,
1414 Typography
1515} from '@mui/material'
16+ import { useTheme } from '@mui/material/styles'
1617import { IconAlertTriangle , IconArrowsMaximize } from '@tabler/icons-react'
1718import parser from 'html-react-parser'
1819
@@ -37,6 +38,7 @@ export interface CreateCredentialDialogProps {
3738 */
3839export function CreateCredentialDialog ( { open, credentialNames, onClose, onCreated } : CreateCredentialDialogProps ) {
3940 const { credentialsApi, apiBaseUrl } = useApiContext ( )
41+ const theme = useTheme ( )
4042
4143 const [ schemas , setSchemas ] = useState < ComponentCredentialSchema [ ] > ( [ ] )
4244 const [ selectedSchema , setSelectedSchema ] = useState < ComponentCredentialSchema | null > ( null )
@@ -122,10 +124,21 @@ export function CreateCredentialDialog({ open, credentialNames, onClose, onCreat
122124 setError ( null )
123125
124126 try {
127+ const plainDataObj : Record < string , unknown > = { }
128+ for ( const key of Object . keys ( formValues ) ) {
129+ const input = selectedSchema . inputs ?. find ( ( i ) => i . name === key )
130+ const val = formValues [ key ]
131+ if ( input ?. type === 'number' && typeof val === 'string' && val ) {
132+ plainDataObj [ key ] = Number ( val )
133+ } else {
134+ plainDataObj [ key ] = val
135+ }
136+ }
137+
125138 const result = await credentialsApi . createCredential ( {
126139 name : credentialName . trim ( ) ,
127140 credentialName : selectedSchema . name ,
128- plainDataObj : formValues
141+ plainDataObj
129142 } )
130143 onCreated ( result . id )
131144 } catch ( err ) {
@@ -153,7 +166,7 @@ export function CreateCredentialDialog({ open, credentialNames, onClose, onCreat
153166 height : 50 ,
154167 marginRight : 10 ,
155168 borderRadius : '50%' ,
156- backgroundColor : ' white'
169+ backgroundColor : theme . palette . common . white
157170 } }
158171 >
159172 < img
@@ -211,21 +224,21 @@ export function CreateCredentialDialog({ open, credentialNames, onClose, onCreat
211224 display : 'flex' ,
212225 flexDirection : 'row' ,
213226 borderRadius : 10 ,
214- background : 'rgb(254,252,191)' ,
227+ background : theme . palette . warning . light ,
215228 padding : 10 ,
216229 marginTop : 10 ,
217230 marginBottom : 10
218231 } }
219232 >
220- < span style = { { color : 'rgb(116,66,16)' } } > { parser ( selectedSchema . description ) } </ span >
233+ < span style = { { color : theme . palette . warning . dark } } > { parser ( selectedSchema . description ) } </ span >
221234 </ div >
222235 </ Box >
223236 ) }
224237
225238 < Box sx = { { p : 2 } } >
226239 < Typography variant = 'overline' >
227240 Credential Name
228- < span style = { { color : 'red' } } > *</ span >
241+ < span style = { { color : theme . palette . error . main } } > *</ span >
229242 </ Typography >
230243 < OutlinedInput
231244 fullWidth
@@ -276,6 +289,7 @@ interface CredentialFieldProps {
276289}
277290
278291function CredentialField ( { input, value, onChange, disabled = false } : CredentialFieldProps ) {
292+ const theme = useTheme ( )
279293 const [ expandOpen , setExpandOpen ] = useState ( false )
280294 const showExpand = input . type === 'string' && ! ! input . rows
281295
@@ -285,7 +299,7 @@ function CredentialField({ input, value, onChange, disabled = false }: Credentia
285299 < div style = { { display : 'flex' , flexDirection : 'row' } } >
286300 < Typography >
287301 { input . label }
288- { ! input . optional && < span style = { { color : 'red' } } > *</ span > }
302+ { ! input . optional && < span style = { { color : theme . palette . error . main } } > *</ span > }
289303 { input . description && < TooltipWithParser title = { input . description } /> }
290304 </ Typography >
291305 < div style = { { flexGrow : 1 } } />
@@ -309,14 +323,14 @@ function CredentialField({ input, value, onChange, disabled = false }: Credentia
309323 display : 'flex' ,
310324 flexDirection : 'row' ,
311325 borderRadius : 10 ,
312- background : 'rgb(254,252,191)' ,
326+ background : theme . palette . warning . light ,
313327 padding : 10 ,
314328 marginTop : 10 ,
315329 marginBottom : 10
316330 } }
317331 >
318- < IconAlertTriangle size = { 36 } color = 'orange' />
319- < span style = { { color : 'rgb(116,66,16)' , marginLeft : 10 } } > { input . warning } </ span >
332+ < IconAlertTriangle size = { 36 } color = { theme . palette . warning . main } />
333+ < span style = { { color : theme . palette . warning . dark , marginLeft : 10 } } > { input . warning } </ span >
320334 </ div >
321335 ) }
322336
0 commit comments