fix invalid mail form
This commit is contained in:
parent
08b5aee7af
commit
82ed5cbf9a
2 changed files with 12 additions and 4 deletions
|
|
@ -23,13 +23,21 @@ export default function SendMailController() {
|
|||
}, []);
|
||||
|
||||
const sendMail = async (fields) => {
|
||||
const { error } = await postMail(fields);
|
||||
if (!error) window.location.reload(false);
|
||||
const { error, status } = await postMail(fields);
|
||||
console.log(error, status, 12313);
|
||||
if (error) {
|
||||
if (status === 500)
|
||||
return { receiver: 'Error' };
|
||||
else if (status === 404)
|
||||
return { receiver: 'User not found' };
|
||||
} else {
|
||||
window.location.reload(false);
|
||||
}
|
||||
};
|
||||
|
||||
return Form({
|
||||
fields: composeMailFields,
|
||||
onSubmit: sendMail,
|
||||
validate: sendMail,
|
||||
validationSchema: mailSchema,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ async function Send(req, res) {
|
|||
return res.status(400).send(config.errorIncomplete);
|
||||
}
|
||||
|
||||
const cachedReciever = await User.findOne({ username: reciever });
|
||||
const cachedReciever = await User.findOne({ username: receiver });
|
||||
|
||||
if (!cachedReciever) {
|
||||
return res.status(404).send(config.errorNotFound);
|
||||
|
|
|
|||
Reference in a new issue