mirror of
https://github.com/langgenius/dify.git
synced 2026-06-23 12:31:13 +08:00
Co-authored-by: zhangx1n <zhangxin@dify.ai> Co-authored-by: yyh <yuanyouhuilyz@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
25 lines
708 B
TypeScript
25 lines
708 B
TypeScript
'use client'
|
|
|
|
import type { CreateReleaseFormValues } from './types'
|
|
import { useForm } from '@tanstack/react-form'
|
|
import { DEFAULT_CREATE_RELEASE_FORM_VALUES } from './types'
|
|
|
|
export const RELEASE_NAME_REQUIRED_ERROR = 'releaseNameRequired'
|
|
|
|
export function validateReleaseName({ value }: {
|
|
value: string
|
|
}) {
|
|
return value.trim() ? undefined : RELEASE_NAME_REQUIRED_ERROR
|
|
}
|
|
|
|
export function useCreateReleaseForm({ onSubmit }: {
|
|
onSubmit: (value: CreateReleaseFormValues) => Promise<void> | void
|
|
}) {
|
|
return useForm({
|
|
defaultValues: DEFAULT_CREATE_RELEASE_FORM_VALUES,
|
|
onSubmit: ({ value }) => onSubmit(value),
|
|
})
|
|
}
|
|
|
|
export type CreateReleaseForm = ReturnType<typeof useCreateReleaseForm>
|