Skip to content

Commit

Permalink
Merge branch 'main' into add-newsletter-form
Browse files Browse the repository at this point in the history
  • Loading branch information
meghanakn473 authored Oct 26, 2024
2 parents 03dd97a + 7d2c7ec commit fb3a21e
Show file tree
Hide file tree
Showing 27 changed files with 391 additions and 193 deletions.
167 changes: 120 additions & 47 deletions README.md

Large diffs are not rendered by default.

61 changes: 47 additions & 14 deletions backend/controller/feedback.controller.js
Original file line number Diff line number Diff line change
@@ -1,54 +1,87 @@
const { z } = require("zod");
const { Feedback } = require("../models/feedback.model");
const logger = require("../config/logger"); // Import your logger
const logger = require("../config/logger");
const nodemailer = require("nodemailer");


// Define the Zod schema for feedback validation
const feedbackSchema = z.object({
name: z.string().min(2).max(100),
email: z.string().email(),
feedback: z.string().min(10),
rating: z.number().min(1).max(5),
});


const transporter = nodemailer.createTransport({
service: "gmail",
auth: {
user: process.env.EMAIL_USER,
pass: process.env.EMAIL_PASS,
},
});

async function createFeedback(req, res) {
try {
const validationResult = feedbackSchema.safeParse(req.body);

if (!validationResult.success) {
logger.error("Validation error:", {
errors: validationResult.error.errors, // Log the detailed validation errors
body: req.body, // Optionally log the request body for context
}); // Use logger for validation errors
errors: validationResult.error.errors,
body: req.body,
});
return res.status(400).json({
success: false,
message: "Validation failed",
errors: validationResult.error.errors,
});
}


const feedback = await Feedback.create(validationResult.data);

await sendThankYouEmail(feedback);

res.status(201).json({
success: true,
message: "Feedback created successfully",
message: "Feedback created successfully and email sent",
data: feedback,
});
} catch (error) {
logger.error("Error creating feedback:", error); // Log the error using Winston
logger.error("Error creating feedback:", error);
res.status(500).json({
success: false,
message: "An error occurred while creating the feedback",
});
}
}


async function sendThankYouEmail(feedback) {
const mailOptions = {
from: process.env.EMAIL_USER, // Sender email
to: feedback.email, // Receiver email
subject: "Thank you for your feedback!",
text: `Hi ${feedback.name},
Thank you for your valuable feedback. Here are the details:
- Feedback: ${feedback.feedback}
- Rating: ${feedback.rating}/5
We appreciate you taking the time to share your thoughts with us!
Best regards,
Play Cafe`,
};

try {
await transporter.sendMail(mailOptions);
logger.info(`Thank-you email sent to ${feedback.email}`);
} catch (error) {
logger.error("Error sending email:", error);
}
}

module.exports = {
createFeedback,
};

// Dummy API call for feedback
// {
// "name": "John Doe",
// "email": "[email protected]",
// "feedback": "This is a dummy feedback"
// }
3 changes: 3 additions & 0 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Outlet } from 'react-router-dom';
import BackToTopButton from './components/Shared/BackToTopButton';
import Preloader from './components/Preloader';


function App() {
return (
<>
Expand All @@ -14,6 +15,8 @@ function App() {
<Navbar />
<Outlet />
<Footer />


</>
);
}
Expand Down
16 changes: 8 additions & 8 deletions frontend/src/components/Membership.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ const Membership = () => {

return (
<motion.div
className="w-full h-auto bg-[#f7e8c3] py-16"
className="w-full h-auto bg-[#f7e8c3] py-16 dark:bg-black "
initial="hidden"
animate="visible"
variants={containerVariants}
>
<div className="flex flex-col items-center mb-12">
<h1 className="text-5xl md:text-7xl font-bold text-black tracking-wide mb-6">Membership Plans</h1>
<p className="md:text-2xl text-xl font-sans text-gray-700 text-center max-w-3xl">
<div className="flex flex-col items-center mb-12 ">
<h1 className="text-5xl md:text-7xl font-bold text-black dark:text-white tracking-wide mb-6">Membership Plans</h1>
<p className="md:text-2xl text-xl font-sans text-gray-700 dark:text-gray-400 text-center max-w-3xl">
Choose the plan that suits your needs and start enjoying exclusive perks!
</p>
</div>
Expand All @@ -91,7 +91,7 @@ const Membership = () => {
{membershipData.map((plan, index) => (
<motion.div
key={index}
className="bg-black bg-opacity-70 shadow-2xl rounded-3xl p-8 max-w-sm w-full transform transition duration-500 hover:scale-105"
className="bg-black bg-opacity-70 dark:bg-amber-700 shadow-2xl rounded-3xl p-8 max-w-sm w-full transform transition duration-500 hover:scale-105"
whileHover={{ scale: 1.05 }}
variants={cardVariants}
>
Expand All @@ -106,14 +106,14 @@ const Membership = () => {
<div className="text-2xl font-semibold text-white mb-6">{plan.price}</div>
{plan.title === "Customizable Add-ons" ? (
<button
className="bg-gradient-to-r from-yellow-500 to-orange-500 text-white py-2 px-8 rounded-full hover:from-orange-500 hover:to-yellow-500 transition-all"
className="bg-gradient-to-r from-yellow-500 to-orange-500 dark:bg-gradient-to-r dark:from-gray-500 dark:to-gray-800 text-white py-2 px-8 rounded-full hover:from-orange-500 hover:to-yellow-500 transition-all"
onClick={() => setIsModalOpen(true)}
>
Customize Add-ons
</button>
) : (
<button
className="bg-gradient-to-r from-yellow-500 to-orange-500 text-white py-2 px-8 rounded-full hover:from-orange-500 hover:to-yellow-500 transition-all"
className="bg-gradient-to-r from-yellow-500 to-orange-500 dark:bg-gradient-to-r dark:from-gray-500 dark:to-gray-800 text-white py-2 px-8 rounded-full hover:from-orange-500 hover:to-yellow-500 transition-all"
onClick={() => navigate('/signup')}
>
Sign Up
Expand Down Expand Up @@ -141,7 +141,7 @@ const Membership = () => {
))}
</div>
<button
className="bg-gradient-to-r from-yellow-500 to-orange-500 text-white py-2 px-4 rounded-full hover:from-orange-500 hover:to-yellow-500 transition-all"
className="bg-gradient-to-r from-yellow-500 to-orange-500 dark:bg-gradient-to-r dark:from-gray-500 dark:to-gray-800 text-white py-2 px-4 rounded-full hover:from-orange-500 hover:to-yellow-500 transition-all"
onClick={handleNext}
>
Next
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Pages/About.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function About() {
window.scrollTo(0, 0);
}, []);
return (
<div id="about" className="relative w-full h-screen md:mt-28">
<div id="about" className="dark relative w-full h-screen md:mt-28 dark:mt-0">
<div
className="absolute inset-0 bg-center bg-cover"
style={{ backgroundImage: `url(${bgpic})` }}
Expand Down
16 changes: 8 additions & 8 deletions frontend/src/components/Pages/Boardgame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ function Boardgame() {

return (
<>
<div className="w-full mt-10 md:mt-0">
<div className="w-full mt-10 md:mt-0 dark:bg-black dark:text-white">
<section className="w-full pt-12 md:pt-24 lg:pt-32">
<div className="container mx-auto space-y-10 xl:space-y-16">
<div className="flex flex-col items-center space-y-4 text-center">
Expand Down Expand Up @@ -368,9 +368,9 @@ function Boardgame() {
{boards.map((board, index) => (
<div
key={index}
className="relative overflow-hidden transition-transform duration-300 ease-in-out rounded-lg shadow-lg group hover:shadow-xl hover:-translate-y-2 card border border-white bg-white"
className="relative overflow-hidden transition-transform duration-300 ease-in-out rounded-lg shadow-lg group hover:shadow-xl hover:-translate-y-2 card border border-white bg-amber-100 dark:bg-amber-800"
>
<div className="relative overflow-hidden">
<div className="relative overflow-hidden dark:bg-amber-800">
<img
src={board.src}
alt={board.title}
Expand All @@ -380,7 +380,7 @@ function Boardgame() {
className="object-cover w-full h-48 transition-all duration-300 ease-in-out group-hover:h-32"
style={{ aspectRatio: '500 / 400', objectFit: 'cover' }}
/>
<div className="p-4 bg-background transition-transform duration-300 ease-in-out transform translate-y-0 group-hover:translate-y-4">
<div className="p-4 bg-background transition-transform duration-300 ease-in-out transform translate-y-0 group-hover:translate-y-4 dark:bg-amber-800">
<h3 className="text-xl font-bold">{board.title}</h3>
<p className="text-sm text-muted-foreground">
{board.description}
Expand All @@ -405,7 +405,7 @@ function Boardgame() {
))}
</div>
</section>
<section className="w-full py-12 md:py-24 lg:py-32 bg-gray-100">
<section className="w-full py-12 md:py-24 lg:py-32 bg-gray-100 dark:bg-black">
<div className="container mx-auto px-4 md:px-6 text-center">
<h2 className="text-3xl font-bold tracking-tight sm:text-4xl md:text-5xl lg:text-6xl mb-4">
Subscribe to our Newsletter
Expand All @@ -420,7 +420,7 @@ function Boardgame() {
>
<input
type="email"
className="px-4 py-2 rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500"
className="px-4 py-2 rounded-lg dark:text-black border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="Enter your email"
value={email}
onChange={(e) => setEmail(e.target.value)} // Update email state on input change
Expand All @@ -440,7 +440,7 @@ function Boardgame() {
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50">
<div
id="modal-instructions"
className="bg-white p-8 rounded-lg max-w-md mx-auto shadow-lg relative overflow-y-auto max-h-[90vh]"
className="bg-amber-100 dark:bg-amber-600 p-8 rounded-lg max-w-md mx-auto shadow-lg relative overflow-y-auto max-h-[90vh]"
>
<h2 className="text-2xl font-bold mb-4">
{selectedBoard.title} Instructions
Expand All @@ -452,7 +452,7 @@ function Boardgame() {
</ul>
<button
onClick={handleCloseInstructions}
className="absolute top-2 right-2 text-gray-500 hover:text-gray-700"
className="absolute top-2 right-2 text-gray-500 hover:text-gray-700 dark:text-white dark:hover:text-gray-300"
>
Close
</button>
Expand Down
20 changes: 10 additions & 10 deletions frontend/src/components/Pages/Event.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function Event() {

return (
<>
<div id="event" className="w-full h-fit bg-amber-100 md:overflow-hidden ">
<div id="event" className="w-full h-fit bg-amber-100 dark:bg-black dark:text-white md:overflow-hidden ">
<section className="w-full h-full py-12 md:py-24 lg:py-32 bg-muted flex justify-center md:overflow-hidden ">
<div className="container relative items-center justify-center gap-4 px-4 text-center md:px-6">
<div className="space-y-4">
Expand All @@ -130,7 +130,7 @@ function Event() {
<h1 className="text-6xl md:text-9xl font-bold ml-4" ref={textRef}>
Upcoming Events and much more....
</h1>
<div className="flex w-full h-80 rounded-full items-center px-40 bg-yellow-100 justify-between shadow-md">
<div className="flex w-full h-80 rounded-full items-center px-40 bg-yellow-100 dark:bg-black justify-between shadow-md">
<img
src={game}
alt="game"
Expand All @@ -147,10 +147,10 @@ function Event() {
</div>
</div>
</section>
<div className="min-h-screen bg-amber-100 p-4">
<div className="min-h-screen bg-amber-100 dark:bg-black p-4">
<div className="container mx-auto flex flex-col flex-col-reverse lg:flex-row space-y-4 lg:space-y-0 lg:space-x-4">
{/* Calendar */}
<div className="bg-white shadow-md rounded-lg p-6 w-full lg:w-1/3">
<div className="bg-white dark:bg-amber-800 shadow-md rounded-lg p-6 w-full lg:w-1/3">
<h2 className="text-xl font-bold mb-4">Event Calendar</h2>
<div className="text-center mb-4">
<span className="text-2xl font-semibold">
Expand All @@ -175,26 +175,26 @@ function Event() {
className={`p-2 border rounded-md ${
day === currentDate
? 'bg-blue-500 text-white'
: 'bg-gray-100'
: 'bg-gray-100 dark:bg-black'
}`}
>
{day}
</div>
))}
</div>
<div className="text-center mt-4">
<button className="bg-[#FEF3C7] text-gray-700 px-4 py-2 rounded-md mt-4">
<button className="bg-[#FEF3C7] dark:bg-black text-gray-700 dark:text-white px-4 py-2 rounded-md mt-4">
Register for Event
</button>
</div>
<div className="text-center mt-4">
<button className="bg-white border border-green-500 px-4 py-2 rounded-md mt-2 text-green-500 hover:bg-green-500 hover:text-white">
<button className="bg-amber-100 dark:bg-yellow border border-green-500 px-4 py-2 rounded-md mt-2 text-green-500 dark:text-black hover:bg-green-500 hover:text-white">
Learn More
</button>
</div>
</div>
{/* Pictures */}
<div className="bg-white shadow-md rounded-lg p-6 w-full lg:w-2/3">
<div className="bg-white dark:bg-amber-800 shadow-md rounded-lg p-6 w-full lg:w-2/3">
<h2 className="text-xl font-bold mb-4">Event Pictures</h2>
<div className="splide w-full h-full">
<div className="splide__track w-full ">
Expand Down Expand Up @@ -253,7 +253,7 @@ function Event() {
{events.map((event) => (
<div
key={event._id}
className="grid grid-cols-1 md:grid-cols-2 gap-10 lg:grid-cols-1 xl:grid-cols-2 md:px-6 lg:px-4 xl:px-0"
className="grid grid-cols-1 md:grid-cols-2 gap-10 lg:grid-cols-1 xl:grid-cols-2 md:px-6 lg:px-4 xl:px-0 "
>
<div className="w-full m-10 mx-auto lg:mx-0 md:mx-0">
<img
Expand All @@ -263,7 +263,7 @@ function Event() {
className="h-[400px] w-full"
/>
</div>
<div className="w-full lg:m-10 md:m-10">
<div className="w-full lg:m-10 md:m-10 ">
<h1 className="text-4xl font-semibold">{event.title}</h1>
<h4 className="text-xl text-muted text-slate-700 italic mt-2 leading-8">
{event.description}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/Pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import FeedbackForm from '../ui/FeedbackForm';
import About from './About';
import React, { useEffect } from 'react';
import MainHOC from '../MainHOC';
import Google from '../Shared/footer/Google';

function Home() {
useEffect(() => {
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/components/Pages/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const Login = () => {
}, []);

return (
<div className="w-screen h-screen flex items-center justify-center lg:pt-10 px-4">
<div className="w-screen h-screen dark:bg-black flex items-center justify-center lg:pt-10 px-4">
{/* Background Image */}
<img
src={photo}
Expand All @@ -98,11 +98,11 @@ const Login = () => {
{/* Login Form */}
<form
onSubmit={handleSubmit}
className="z-10 p-8 lg:p-16 bg-[#f1e9dc] flex flex-col gap-6 rounded-lg border-2 border-black shadow-[4px_4px_0px_0px_black] w-full max-w-md lg:max-w-xl"
className="z-10 p-8 lg:p-16 bg-[#f1e9dc] dark:bg-amber-800 dark:text-white flex flex-col gap-6 rounded-lg border-2 border-black shadow-[4px_4px_0px_0px_black] w-full max-w-md lg:max-w-xl"
>
<div className="text-[#323232] font-black text-4xl lg:text-7xl mb-2">
<div className="text-[#323232] dark:text-white font-black text-4xl lg:text-7xl mb-2">
Welcome,
<span className="block text-[#666] font-semibold text-lg lg:text-2xl mt-1">
<span className="block text-[#666] dark:text-gray-400 font-semibold text-lg lg:text-2xl mt-1">
Log in to continue
</span>
</div>
Expand Down Expand Up @@ -136,7 +136,7 @@ const Login = () => {

<Link
to="/email-verify"
className="text-sm lg:text-base text-gray-500 hover:text-red-500 transition"
className="text-sm lg:text-base text-gray-500 dark:text-gray-200 hover:text-red-500 transition"
>
Forgot Password?
</Link>
Expand All @@ -157,7 +157,7 @@ const Login = () => {
>
<button
type="button"
className="w-full h-12 rounded-md border-2 border-black bg-beige shadow-[4px_4px_0px_0px_black] text-[17px] font-semibold text-[#323232] transition active:translate-x-[3px] active:translate-y-[3px]"
className="w-full h-12 rounded-md border-2 dark:text-white border-black bg-beige shadow-[4px_4px_0px_0px_black] text-[17px] font-semibold text-[#323232] transition active:translate-x-[3px] active:translate-y-[3px]"
>
Sign in with Google
</button>
Expand All @@ -167,7 +167,7 @@ const Login = () => {

<button
type="submit"
className="w-full h-12 rounded-md border-2 border-black bg-beige shadow-[4px_4px_0px_0px_black] text-[17px] font-semibold text-[#323232] transition active:translate-x-[3px] active:translate-y-[3px]"
className="w-full h-12 rounded-md dark:text-white border-2 border-black bg-beige shadow-[4px_4px_0px_0px_black] text-[17px] font-semibold text-[#323232] transition active:translate-x-[3px] active:translate-y-[3px]"
>
{isLoading ? 'Loading...' : 'Let’s Log you in →'}
</button>
Expand Down
Loading

0 comments on commit fb3a21e

Please sign in to comment.