-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Notification): added notifications on globalstate on contact form
- Loading branch information
1 parent
3d270ca
commit 156be48
Showing
2 changed files
with
64 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,42 @@ | ||
import React from 'react' | ||
import React, {useRef} from 'react' | ||
import { StyledFormSubmit } from '../../Layout/Form/styledInput'; | ||
import {useNotification} from "../../GlobalState"; | ||
import './Contact.css' | ||
|
||
const ContactForm = () => { | ||
return (<> | ||
const dispatch = useNotification(); | ||
const form = useRef(); | ||
|
||
const handleConfirm = () => { | ||
form.current.submit(); | ||
}; | ||
|
||
const formNotification = () => { | ||
dispatch({ | ||
type: "SUCCESS", | ||
message: "Processing Your Request...Please Wait", | ||
title: "Successful Request" | ||
}) | ||
} | ||
|
||
const handleNotification = async () => { | ||
await formNotification(); | ||
await handleConfirm(); | ||
} | ||
|
||
return (<> | ||
<div className='contact-container'> | ||
<p>Have a question? I am available for hire and open to any ideas of cooperation.</p> | ||
<form action="https://getform.io/f/7efda21f-ca67-48f6-8a1e-723776d4ae3b" method='POST'> | ||
<form ref={form} onSubmit={handleNotification} action="https://getform.io/f/7efda21f-ca67-48f6-8a1e-723776d4ae3b" method='POST'> | ||
<input className='contact-input' type="text" name="name" placeholder="Name" /> | ||
<input className='contact-input' type="email" name="email" placeholder="Enter Email" /> | ||
<textarea className='area' name="message" placeholder='Your Message' /> | ||
<StyledFormSubmit type="submit" value="Submit"/> | ||
<div style={{color: 'white', fontSize: '2rem'}} onClick={handleNotification}>Test</div> | ||
<StyledFormSubmit onClick={handleNotification} type="submit" value="Submit"/> | ||
</form> | ||
</div> | ||
</> | ||
) | ||
) | ||
} | ||
|
||
export default ContactForm; |
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