import { BasicUpdater, FormRunnerContext, FormRunnerForeignMutationsExpected, FormRunnerLoader, FormRunnerState, Sum, unit, } from "../../../../main"; import { Template } from "../../../template/state"; import { FormParsingResult } from "../parser/state"; export const FormRunnerErrorsTemplate = ( parsedFormsConfig: FormParsingResult, ) => ({ form: Template.Default< FormRunnerContext & FormRunnerState, FormRunnerState, FormRunnerForeignMutationsExpected >((props) => ( <> {JSON.stringify(parsedFormsConfig)}
{JSON.stringify(props)} )), // form: Template.Default(props => // props.context.showFormParsingErrors(parsedFormsConfig) // ), formFieldStates: unit, entity: unit, commonFormState: unit, customFormState: unit, globalConfiguration: unit, }); export const FormRunnerTemplate = Template.Default< FormRunnerContext & FormRunnerState, FormRunnerState, FormRunnerForeignMutationsExpected >((props) => { if (props.context.form.kind == "r") return <>; return ( <> ) => props.setState(FormRunnerState.Updaters.form(Sum.Updaters.left(_))) } view={unit} foreignMutations={{ apiHandlers: { onDefaultSuccess: (_: any) => { if (props.context.formRef.kind == "create") props.context.formRef.apiHandlers?.onDefaultSuccess?.(_); }, onDefaultError: (_: any) => { if (props.context.formRef.kind == "create") props.context.formRef.apiHandlers?.onDefaultError?.(_); }, onCreateSuccess: (_: any) => { if (props.context.formRef.kind === "create") props.context.formRef.apiHandlers?.onCreateSuccess?.(_); }, onCreateError: (_: any) => { if (props.context.formRef.kind === "create") props.context.formRef.apiHandlers?.onCreateError?.(_); }, onGetSuccess: (_: any) => { if (props.context.formRef.kind === "edit") props.context.formRef.apiHandlers?.onGetSuccess?.(_); }, onGetError: (_: any) => { if (props.context.formRef.kind === "edit") props.context.formRef.apiHandlers?.onGetError?.(_); }, onUpdateSuccess: (_: any) => { if (props.context.formRef.kind === "edit") props.context.formRef.apiHandlers?.onUpdateSuccess?.(_); }, onUpdateError: (_: any) => { if (props.context.formRef.kind === "edit") props.context.formRef.apiHandlers?.onUpdateError?.(_); }, }, }} /> ); }).any([FormRunnerLoader()]);