feat: Update OptionsField to use correct Options type and enhance Zod schema generation for options and select input types

This commit is contained in:
twwu 2025-04-27 18:45:22 +08:00
parent fd8ee9f53e
commit 839fe12087
2 changed files with 8 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import cn from '@/utils/classnames'
import { useFieldContext } from '../..'
import type { LabelProps } from '../label'
import Label from '../label'
import type { Options } from '@/app/components/app/configuration/config-var/config-select'
import ConfigSelect from '@/app/components/app/configuration/config-var/config-select'
type OptionsFieldProps = {
@ -15,7 +16,7 @@ const OptionsField = ({
className,
labelOptions,
}: OptionsFieldProps) => {
const field = useFieldContext<string[]>()
const field = useFieldContext<Options>()
return (
<div className={cn('flex flex-col gap-y-0.5', className)}>

View File

@ -21,6 +21,12 @@ export const generateZodSchema = <T>(fields: InputFieldConfiguration<T>[]) => {
case InputFieldType.checkbox:
zodType = z.boolean()
break
case InputFieldType.options:
zodType = z.array(z.string())
break
case InputFieldType.select:
zodType = z.string()
break
case InputFieldType.fileTypes:
zodType = z.array(z.string())
break