Skip to content

Commit 27ac47f

Browse files
committed
fix: refactor model input handling in AI settings form for improved validation and feedback
1 parent d91cddc commit 27ac47f

1 file changed

Lines changed: 14 additions & 40 deletions

File tree

ui/src/pages/Admin/AiSettings/index.tsx

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -427,35 +427,12 @@ const Index = () => {
427427
</InputGroup>
428428
</Form.Group>
429429

430-
<div className="mb-3">
431-
<label htmlFor="model" className="form-label">
432-
{t('model.label')}
433-
</label>
434-
{/* <Form.Select
435-
list="datalistOptions"
436-
isInvalid={formData.model.isInvalid}
437-
value={formData.model.value}
438-
onChange={(e) =>
439-
handleValueChange({
440-
model: {
441-
value: e.target.value,
442-
errorMsg: '',
443-
isInvalid: false,
444-
},
445-
})
446-
}>
447-
{modelsData?.map((model) => {
448-
return (
449-
<option key={model.id} value={model.id}>
450-
{model.id}
451-
</option>
452-
);
453-
})}
454-
</Form.Select> */}
455-
<input
456-
className="form-control"
457-
list="datalistOptions"
458-
id="model"
430+
<Form.Group className="mb-3" controlId="model">
431+
<Form.Label>{t('model.label')}</Form.Label>
432+
<Form.Control
433+
list="modelOptions"
434+
autoComplete="off"
435+
isInvalid={formData.model.isInvalid}
459436
value={formData.model.value}
460437
onChange={(e) =>
461438
handleValueChange({
@@ -467,18 +444,15 @@ const Index = () => {
467444
})
468445
}
469446
/>
470-
<datalist id="datalistOptions">
471-
{modelsData?.map((model) => {
472-
return (
473-
<option key={model.id} value={model.id}>
474-
{model.id}
475-
</option>
476-
);
477-
})}
447+
<datalist id="modelOptions">
448+
{modelsData?.map((model) => (
449+
<option key={model.id} value={model.id} />
450+
))}
478451
</datalist>
479-
480-
<div className="invalid-feedback">{formData.model.errorMsg}</div>
481-
</div>
452+
<Form.Control.Feedback type="invalid">
453+
{formData.model.errorMsg}
454+
</Form.Control.Feedback>
455+
</Form.Group>
482456

483457
<Button type="submit">{t('save', { keyPrefix: 'btns' })}</Button>
484458
</Form>

0 commit comments

Comments
 (0)