You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
656 B
18 lines
656 B
import { AppState, FormValue } from '../types'
|
|
|
|
export const getForm = (state: AppState) => state.forms.form
|
|
|
|
export function getFieldValue<T extends FormValue>(state: AppState, name: string, defaultValue: T): T
|
|
export function getFieldValue<T extends FormValue>(state: AppState, name: string, defaultValue?: T): T | undefined {
|
|
const field = getForm(state)[name]
|
|
|
|
if (!field) return defaultValue
|
|
if (field.value === undefined) return defaultValue
|
|
|
|
return field.value as T
|
|
}
|
|
|
|
export const getFieldNotification = (state: AppState, name: string) => {
|
|
const field = getForm(state)[name]
|
|
return field ? field.notification : undefined
|
|
}
|