refactor: simplify validation for Command component

This commit is contained in:
sadeghbarati 2023-10-01 09:38:56 +03:30
parent 9881d9d1ec
commit 157b1f00df

View File

@ -77,11 +77,7 @@ async function onSubmit(values: any) {
</p> </p>
</div> </div>
<Separator /> <Separator />
<Form <Form :validation-schema="accountFormSchema" class="space-y-8" @submit="onSubmit">
v-slot="{
setValues,
}" :validation-schema="accountFormSchema" class="space-y-8" @submit="onSubmit"
>
<FormField v-slot="{ componentField }" name="name"> <FormField v-slot="{ componentField }" name="name">
<FormItem> <FormItem>
<FormLabel>Name</FormLabel> <FormLabel>Name</FormLabel>
@ -123,7 +119,7 @@ async function onSubmit(values: any) {
</FormItem> </FormItem>
</FormField> </FormField>
<FormField v-slot="{ value }" name="language"> <FormField v-slot="{ value, componentField }" name="language">
<FormItem> <FormItem>
<FormLabel>Language</FormLabel> <FormLabel>Language</FormLabel>
@ -145,13 +141,12 @@ async function onSubmit(values: any) {
</FormControl> </FormControl>
</PopoverTrigger> </PopoverTrigger>
<PopoverContent class="w-[200px] p-0"> <PopoverContent class="w-[200px] p-0">
<Command> <Command v-bind="componentField">
<CommandInput placeholder="Search language..." /> <CommandInput placeholder="Search language..." />
<CommandEmpty>No framework found.</CommandEmpty> <CommandEmpty>No framework found.</CommandEmpty>
<CommandGroup> <CommandGroup>
<CommandItem <CommandItem
v-for="language in languages" :key="language.value" :value="language.value" @select="(val) => { v-for="language in languages" :key="language.value" :value="language.value" @select="() => {
setValues({ language: val })
open = false open = false
}" }"
> >