Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made Newsletter Functional #66

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@
},
"dependencies": {
"@vercel/speed-insights": "^1.0.12",
"axios": "^1.7.7",
"next": "14.2.5",
"nodemailer": "^6.9.15",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@types/node": "^20",
"@types/nodemailer": "^6.4.16",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
Expand Down
4 changes: 2 additions & 2 deletions src/components/ui/Footer.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
outline: none;
}

.newsletter-right-container > .newsletter-email-container > form > p{
.newsletter-right-container > .newsletter-email-container > form > button{
color: white;
height: 3rem;
font-size: 1rem;
Expand All @@ -86,7 +86,7 @@

box-shadow: 0 .7065919983928324px .7065919983928324px -.625px #00000026,0 1.8065619053231785px 1.8065619053231785px -1.25px #00000025,0 3.6217592146567767px 3.6217592146567767px -1.875px #00000023,0 6.8655999097303715px 6.8655999097303715px -2.5px #00000020,0 13.646761411524492px 13.646761411524492px -3.125px #0000001b,0 30px 30px -3.75px #0000000d;
}
.newsletter-right-container > .newsletter-email-container > form > p:hover{
.newsletter-right-container > .newsletter-email-container > form > button:hover{
background-color: var(--slate-black);
cursor: pointer;
}
Expand Down
146 changes: 96 additions & 50 deletions src/components/ui/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,54 +1,100 @@
import styles from "./Footer.module.css"
"use client";

import { useState } from 'react';
import styles from "./Footer.module.css";
import Link from "next/link";

export default function Footer() {
return (
<footer className={styles["footer-container"]}>

<div className={styles["newsletter-container"]}>
<div className={styles["newsletter-left-container"]}>
<h3>Join the newsletter</h3>
<p>Get the latest insights and updates straight to your inbox.</p>
</div>
<div className={styles["newsletter-right-container"]}>

<div className={styles["newsletter-email-container"]}>
<form action="">
<input id={"email-input"} type="email" placeholder="Enter Your email" required={true} disabled={true}/>
<p>Subscribe</p>
</form>
</div>
<div><p>Your privacy is important. I never share your email.</p></div>

</div>
</div>

<div className={styles["footer"]}>
<div className={styles["footer-left-container"]}>
{/*<h2>Uttarakhand Culture </h2>*/}
<h2>UTTARAKHAND CULTURE</h2>
<p>Our aim is to ensure that this invaluable heritage is passed down to future generations.</p>
</div>

<div className={styles["footer-right-container"]}>
<div className={styles["footer-right-link-container"]} >
<p>Socials</p>
<Link href={"https://www.linkedin.com/company/uttarakhandculture?trk=public_post_follow-view-profile"}>LinkedIn</Link>
<Link href={"https://github.com/Uttarakhand-Culture"}>Github</Link>
<Link href={"https://ukculture.netlify.app/contact"}>Contact us</Link>
</div>
<div className={styles["footer-right-link-container"]} >
<p>Contribution</p>
<Link href={""}>Issues</Link>
<Link href={"https://github.com/Uttarakhand-Culture/Frontend/blob/main/README.md"}>About us</Link>
<Link href={""}>Contribution</Link>
</div>
</div>
</div>

<div className={styles["copyright-container"]}>
<p>© 2024 Uttarakhand Culture. All rights reserved.</p>
</div>
</footer>
);
const [email, setEmail] = useState('');
const [message, setMessage] = useState('');
const [loading, setLoading] = useState(false);

const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
setMessage('');
setLoading(true);

try {
const res = await fetch('/api/subscribe', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email }),
});

const data = await res.json();

if (res.status === 200) {
setMessage('Thank you for subscribing! A welcome email has been sent.');
} else {
setMessage(data.error || 'Something went wrong');
}
} catch (error) {
console.error(error);
setMessage('Something went wrong');
} finally {
setLoading(false);
}
};

return (
<footer className={styles["footer-container"]}>
<div className={styles["newsletter-container"]}>
<div className={styles["newsletter-left-container"]}>
<h3>Join the newsletter</h3>
<p>Get the latest insights and updates straight to your inbox.</p>
</div>
<div className={styles["newsletter-right-container"]}>
<div className={styles["newsletter-email-container"]}>
<form onSubmit={handleSubmit}>
<input
id="email-input"
type="email"
placeholder="Enter Your email"
value={email}
onChange={(e) => setEmail(e.target.value)}
required
/>
<button type="submit" id='subscribe-btn'>
{loading ? 'Submitting...' : 'Subscribe'}
</button>
</form>
{message && <p>{message}</p>}
</div>
<div><p>Your privacy is important. We never share your email.</p></div>
</div>
</div>

{/* Footer bottom section */}
<div className={styles["footer"]}>
{/* Left part of the footer */}
<div className={styles["footer-left-container"]}>
<h2>UTTARAKHAND CULTURE</h2>
<p>Our aim is to ensure that this invaluable heritage is passed down to future generations.</p>
</div>

{/* Right part of the footer */}
<div className={styles["footer-right-container"]}>
<div className={styles["footer-right-link-container"]}>
<p>Socials</p>
<Link href="https://www.linkedin.com/company/uttarakhandculture?trk=public_post_follow-view-profile">LinkedIn</Link>
<Link href="https://github.com/Uttarakhand-Culture">Github</Link>
<Link href="https://ukculture.netlify.app/contact">Contact us</Link>
</div>
<div className={styles["footer-right-link-container"]}>
<p>Contribution</p>
<Link href="">Issues</Link>
<Link href="https://github.com/Uttarakhand-Culture/Frontend/blob/main/README.md">About us</Link>
<Link href="">Contribution</Link>
</div>
</div>
</div>

{/* Copyright section */}
<div className={styles["copyright-container"]}>
<p>© 2024 Uttarakhand Culture. All rights reserved.</p>
</div>
</footer>
);
}
Loading