🐞 fix: Handle Empty Model Error in Assistants Form (#2265)

This commit is contained in:
Danny Avila 2024-04-01 09:20:11 -04:00 committed by GitHub
parent cc92597f14
commit d07396d308
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 42 additions and 16 deletions

View file

@ -317,19 +317,28 @@ export default function AssistantPanel({
<Controller
name="model"
control={control}
render={({ field }) => (
<SelectDropDown
emptyTitle={true}
value={field.value}
setValue={field.onChange}
availableValues={modelsQuery.data?.[EModelEndpoint.assistants] ?? []}
showAbove={false}
showLabel={false}
className={cn(
cardStyle,
'flex h-[40px] w-full flex-none items-center justify-center px-4 hover:cursor-pointer',
rules={{ required: true, minLength: 1 }}
render={({ field, fieldState: { error } }) => (
<>
<SelectDropDown
emptyTitle={true}
value={field.value}
setValue={field.onChange}
availableValues={modelsQuery.data?.[EModelEndpoint.assistants] ?? []}
showAbove={false}
showLabel={false}
className={cn(
cardStyle,
'flex h-[40px] w-full flex-none items-center justify-center px-4 hover:cursor-pointer',
)}
containerClassName={cn('rounded-md', error ? 'border-red-500 border-2' : '')}
/>
{error && (
<span className="text-sm text-red-500 transition duration-300 ease-in-out">
{localize('com_ui_field_required')}
</span>
)}
/>
</>
)}
/>
</div>