ACTIONS
//crear un servicio ADMIN
export const newService=(serviceData)=>async(dispatch)=>{
try {
dispatch({type: CREATE_SERVICE_REQUEST})
const config={
header:{'Content-Type':'application/json'}
}
const {data}=await axios.post('/api/services/nuevo',serviceData,config)
dispatch({
type: CREATE_SERVICE_SUCCESS,
payload:data,
})
return data
} catch (error) {
dispatch({
type: CREATE_SERVICE_FAIL,
payload: error.response.data.message
})
}
}
CONSTANTS
export const CREATE_SERVICE_REQUEST="CREATE_SERVICE_REQUEST"
export const CREATE_SERVICE_SUCCESS="CREATE_SERVICE_SUCCESS"
export const CREATE_SERVICE_RESET="CREATE_SERVICE_RESET"
export const CREATE_SERVICE_FAIL="CREATE_SERVICE_SUCCESS"