[ABANDONED] React/Redux front end for the Flexor social network.
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.
 
 

15 lines
698 B

import { AppState, FormValue } from '../types'
import { valueFromForm } from '../utils'
export const getForm = (state: AppState) => state.forms.form
export function getFieldValue<T extends FormValue>(state: AppState, name: string): T | undefined
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 {
return valueFromForm<T>(getForm(state), name, defaultValue)
}
export const getFieldNotification = (state: AppState, name: string) => {
const field = getForm(state)[name]
return field ? field.notification : undefined
}