Skip to content

Commit

Permalink
Add error to contact form if submission fails
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljames-dj committed Jun 22, 2024
1 parent 060882f commit 82615eb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/webpacker/components/ContactsPage/ContactForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Wct from './SubForms/Wct';
import Wrt from './SubForms/Wrt';
import Wst from './SubForms/Wst';
import Competition from './SubForms/Competition';
import Errored from '../Requests/Errored';

const CONTACT_RECIPIENTS = [
'competition',
Expand All @@ -30,6 +31,7 @@ export default function ContactForm({ loggedInUserData }) {
const { save, saving } = useSaveAction();
const [captchaValue, setCaptchaValue] = useState();
const [captchaError, setCaptchaError] = useState(false);
const [saveError, setSaveError] = useState();
const [contactSuccess, setContactSuccess] = useState(false);
const contactFormState = useStore();
const dispatch = useDispatch();
Expand Down Expand Up @@ -66,6 +68,7 @@ export default function ContactForm({ loggedInUserData }) {
}, [selectedContactRecipient]);

if (saving) return <Loading />;
if (saveError) return <Errored error={saveError} />;

return (
<>
Expand All @@ -85,6 +88,7 @@ export default function ContactForm({ loggedInUserData }) {
formData,
contactSuccessHandler,
{ method: 'POST', headers: {}, body: formData },
setSaveError,
);
}
}}
Expand Down

0 comments on commit 82615eb

Please sign in to comment.