import { ContactAction , ContactActionTypes , ContactState , } from '../../types/redux/contact-reducer-types' ; const initialState = { isEmailSending : false , isEmailSent : false , error : null , } ; function param { ContactState } state param { object } action returns { object } export const contactReducer = ( state = initialState , action ) : ContactState => { switch ( action . type ) { case ContactActionTypes . SEND_EMAIL : return { ... state , isEmailSending : true } ; case ContactActionTypes . EMAIL_WAS_SENT : return { ... state , isEmailSending : false , isEmailSent : true } ; case ContactActionTypes . EMAIL_SEND_ERROR : return { ... state , isEmailSending : false , error : action . payload } ; case ContactActionTypes . CLEAR_EMAIL_STATE : return { ... initialState } ; default : return state ; } } ;