|
|
|
@ -26,7 +26,7 @@ const errorReducer = (errors, action) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const formReducer = (state, action)=>{
|
|
|
|
|
const formReducer = errorDispatch => (state, action)=>{
|
|
|
|
|
let fields = {...state.fields}
|
|
|
|
|
const prevField = state.fields[action.name]
|
|
|
|
|
|
|
|
|
@ -91,8 +91,8 @@ export const FormController = function FormController({children, url, method =
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Create reducers
|
|
|
|
|
const [state, dispatch] = useReducer(formReducer, initialState)
|
|
|
|
|
const [errors, errorDispatch] = useReducer(errorReducer, {})
|
|
|
|
|
const [state, dispatch] = useReducer(formReducer(errorDispatch), initialState)
|
|
|
|
|
|
|
|
|
|
// Handle submitting form
|
|
|
|
|
const handleSubmit = async (ev) => {
|
|
|
|
|