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

pull/21398/head
twwu 1 year ago
parent fd8ee9f53e
commit 839fe12087

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

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

Loading…
Cancel
Save