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

this req got created by mistake #64

Closed
wants to merge 2 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
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>
);
}
43 changes: 43 additions & 0 deletions src/pages/api/subscribe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import nodemailer from 'nodemailer';
import type { NextApiRequest, NextApiResponse } from 'next';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method === 'POST') {
const { email } = req.body;

if (!email) {
return res.status(400).json({ error: 'Missing email' });
}

try {
const transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 587,
secure: false,
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASSWORD,
},
});

const mailOptions = {
from: process.env.SMTP_USER,
to: email,
subject: 'Welcome to our Uttarakhand Culture Newsletter!',
text: 'Thank you for subscribing to our Uttarakhand Culture! Stay tuned for updates...',
html: '<p>Thank you for subscribing to our newsletter! Stay tuned for updates.</p>',
};


await transporter.sendMail(mailOptions);
res.status(200).json({ message: 'Email sent successfully' });

} catch (error) {
console.error('Error sending email:', error);
res.status(500).json({ error: 'Error sending email' });
}

} else {
res.status(405).json({ message: 'Method not allowed' });
}
}