diff --git a/web/app/components/base/form/components/field/select.tsx b/web/app/components/base/form/components/field/select.tsx index 60f9f21943..289fceb928 100644 --- a/web/app/components/base/form/components/field/select.tsx +++ b/web/app/components/base/form/components/field/select.tsx @@ -1,18 +1,13 @@ import cn from '@/utils/classnames' import { useFieldContext } from '../..' -import type { PureSelectProps } from '../../../select/pure' +import type { Option, PureSelectProps } from '../../../select/pure' import PureSelect from '../../../select/pure' import Label from '../label' import { useCallback } from 'react' -type SelectOption = { - value: string - label: string -} - type SelectFieldProps = { label: string - options: SelectOption[] + options: Option[] onChange?: (value: string) => void isRequired?: boolean showOptional?: boolean diff --git a/web/app/components/base/form/components/form/actions.tsx b/web/app/components/base/form/components/form/actions.tsx new file mode 100644 index 0000000000..4e22350c90 --- /dev/null +++ b/web/app/components/base/form/components/form/actions.tsx @@ -0,0 +1,39 @@ +import { useStore } from '@tanstack/react-form' +import type { FormType } from '../..' +import { useFormContext } from '../..' +import Button from '../../../button' +import { useTranslation } from 'react-i18next' + +type ActionsProps = { + CustomActions?: (form: FormType) => React.ReactNode +} + +const Actions = ({ + CustomActions, +}: ActionsProps) => { + const { t } = useTranslation() + const form = useFormContext() + + const [isSubmitting, canSubmit] = useStore(form.store, state => [ + state.isSubmitting, + state.canSubmit, + ]) + + if (CustomActions) + return CustomActions(form) + + return ( +