Created
August 20, 2020 18:53
-
-
Save JAMesserman/adf98004adad342612b03f85b797e17b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const validate = async (visitDetails: VirtualVisitDetailsI) => { | |
const valid = await validateOnSubmit(visitDetails); // YUP.js form validation | |
if (!valid) { | |
setSubmitError(intl.formatMessage(messages.hostAndGuestRequired)); //react state | |
return false; | |
} | |
setSubmitError(undefined); //react state | |
return true; | |
}; | |
const handleSubmit = async (visitDetails: VirtualVisitDetailsI) => { | |
// tslint:disable-next-line:no-unused-expression | |
const validationResult = await validate(visitDetails); | |
if (!validationResult) { | |
return; | |
} | |
toggleMeetingModal(true); | |
const { errors } = await initiateVisit({ //a gql mutation | |
variables: { | |
visitDetails, | |
}, | |
}); | |
if (errors) { | |
errorLoggingHelper("[src/components/VirtualVisit/Form/index.tsx]", `Error initiating visit: ${errors}`); | |
} | |
return; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment