Last active
June 30, 2021 19:08
-
-
Save Etheonor/11f7d804d0a8304f25ee11d6adda4214 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
import axios from "axios"; | |
import { toast } from "react-toastify"; | |
import { useState } from "react"; | |
const MailingList = () => { | |
const [mail, setMail] = useState(null); | |
const [loading, setLoading] = useState(false); | |
const subscribe = () => { | |
setLoading(true); | |
axios | |
.put("api/mailingList", { | |
mail, | |
}) | |
.then((result) => { | |
if (result.status === 200) { | |
toast.success(result.data.message); | |
setLoading(false); | |
} | |
}) | |
.catch((err) => { | |
console.log(err); | |
setLoading(false); | |
}); | |
}; | |
return ( | |
<div className='my-10'> | |
<hr className='my-5' /> | |
<h2 className='text-3xl md:text-3xl font-semibold font-title'> | |
Stay Tuned! | |
</h2> | |
<label className='label'> | |
<p className='text-lg max-w-xl text-center m-auto leading-9'> | |
Want to be the first to know when SupaNexTail launches and get an | |
exclusive discount? Sign up for the newsletter! | |
</p> | |
</label> | |
<div className='mt-5'> | |
<input | |
onChange={(e) => { | |
setMail(e.target.value); | |
}} | |
type='email' | |
placeholder='Your email' | |
className='input input-primary input-bordered'></input> | |
<button | |
onClick={subscribe} | |
className={`btn ml-3 ${ | |
loading ? "btn-disabled loading" : "btn-primary" | |
}`}> | |
I'm in! | |
</button> | |
</div> | |
<hr className='my-5' /> | |
</div> | |
); | |
}; | |
export default MailingList; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment