Skip to content

Commit 2842b3e

Browse files
Merge branch 'main' into footer
2 parents dbc7e8d + 0495e60 commit 2842b3e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+7315
-4910
lines changed

.env.sample

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
APPWRITE_ENDPOINT=https://your-appwrite-instance.appwrite.cloud
2-
APPWRITE_PROJECT_ID=your-appwrite-project-id
3-
APPWRITE_DATABASE_ID=your-appwrite-database-id
4-
APPWRITE_COLLECTION_ID=your-appwrite-collection-id
5-
APPWRITE_BUCKET_ID=your-appwrite-bucket-id
1+
VITE_APPWRITE_ENDPOINT=mega-blog-8587.vercel.app
2+
VITE_APPWRITE_PROJECT_ID=67114f7a001cd5164a4c
3+
VITE_APPWRITE_DATABASE_ID=67114fcd002c7e1d6607
4+
VITE_APPWRITE_COLLECTION_ID=67114ff2001b86d99ac6
5+
VITE_APPWRITE_BUCKET_ID=6711503b0015d2f08054

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="en">
2+
<html lang="en" class="dark">
33
<head>
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="./src/assets/favicon.png" />

package-lock.json

Lines changed: 3612 additions & 4207 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
"@radix-ui/react-select": "^2.1.2",
2626
"@radix-ui/react-slot": "^1.1.0",
2727
"@reduxjs/toolkit": "^2.0.1",
28-
"@tinymce/tinymce-react": "^5.1.1",
29-
"appwrite": "^13.0.2",
28+
"@tinymce/tinymce-react": "^4.3.2",
29+
"appwrite": "^16.0.2",
3030
"caniuse-lite": "^1.0.30001668",
3131
"class-variance-authority": "^0.7.0",
3232
"clsx": "^2.1.1",
3333
"cmdk": "^1.0.0",
3434
"embla-carousel-react": "^8.3.0",
35+
"esbuild": "^0.24.0",
3536
"framer-motion": "^11.11.7",
3637
"html-react-parser": "^5.1.1",
3738
"lucide-react": "^0.447.0",
@@ -44,7 +45,9 @@
4445
"react-responsive": "^10.0.0",
4546
"react-router-dom": "^6.21.2",
4647
"react-share": "^5.1.0",
47-
"react-simple-chatbot": "^0.5.0",
48+
"react-simple-chatbot": "^0.6.1",
49+
"react-toastify": "^10.0.6",
50+
"rollup": "^4.24.4",
4851
"styled-components": "^4.0.0",
4952
"tailwind-merge": "^2.5.3",
5053
"tailwindcss-animate": "^1.0.7"

server/.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
MONGO_URI=mongodb://localhost:27017/megaBlog
2+
JWT_SECRET=scijyasfy7dsvegdffvbfbfgg435tgrsnbgfgn
3+
PORT=5000
4+
EMAIL_ID=
5+
PASS_KEY=
6+
ADMIN_EMAIL_ID=

server/app.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import express from "express";
2+
import dotenv from "dotenv";
3+
import connectDB from "./utils/db.js";
4+
import cors from "cors";
5+
import newsletterRoutes from "./routes/newsletterRoute.js";
6+
import feedbackRoutes from "./routes/feedbackRoute.js";
7+
import contactRoute from "./routes/contactRoute.js";
8+
import discussion from "./routes/discussionRoutes.js";
9+
10+
11+
dotenv.config();
12+
const app = express();
13+
connectDB();
14+
15+
app.use(express.json());
16+
17+
// To avoid cross-origin error
18+
app.use(cors());
19+
20+
// Use the imported routes
21+
app.use("/api/newsletter", newsletterRoutes);
22+
app.use("/api/feedback", feedbackRoutes);
23+
app.use("/api/contact", contactRoute);
24+
app.use("/api/discussion", discussion);
25+
26+
const PORT = process.env.PORT || 5000;
27+
app.listen(PORT, () => {
28+
console.log(`Server running on port ${PORT}`);
29+
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import Contact from "../models/contact.js";
2+
import { sendMailToAdmin } from "../sendContactDetailsToAdmin.js";
3+
4+
export async function saveContact(req, resp) {
5+
try {
6+
// Destructuring to get the fields from the request body
7+
const { name, phone, email, message } = req.body;
8+
9+
// Check if all fields are provided
10+
if (!name || !phone || !email || !message) {
11+
return resp.status(400).json({ message: "All fields are required." });
12+
}
13+
14+
// Create new contact document
15+
const newContact = new Contact({ name, phone, email, message });
16+
17+
// Save contact form data to the database
18+
await newContact.save();
19+
20+
sendMailToAdmin(newContact)
21+
22+
// Respond with success message
23+
resp
24+
.status(201)
25+
.json({ message: "Contact form submitted successfully!", newContact });
26+
} catch (error) {
27+
console.error("Error saving contact form:", error);
28+
resp.status(500).json({ message: "Failed to submit contact form.", error });
29+
}
30+
}
31+
32+
export async function getContact(req, resp) {
33+
resp.send('hello contact');
34+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import Question from '../models/discussion.js';
2+
3+
export const getQuestions = async (req, res) => {
4+
try {
5+
const questions = await Question.find();
6+
res.json(questions);
7+
} catch (error) {
8+
res.status(500).json({ error: 'Failed to retrieve questions' });
9+
}
10+
};
11+
12+
// Save a new question to MongoDB
13+
export const saveQuestion = async (req, res) => {
14+
try {
15+
const { content } = req.body;
16+
17+
const newQuestion = new Question({
18+
content,
19+
});
20+
21+
await newQuestion.save();
22+
23+
res.status(201).json(newQuestion);
24+
} catch (error) {
25+
res.status(500).json({ error: 'Failed to save question' });
26+
}
27+
};
28+
29+
export const addAnswerToQuestion = async (req, res) => {
30+
try {
31+
const questionId = req.params.id;
32+
const { answer } = req.body;
33+
console.log(questionId)
34+
console.log(answer)
35+
36+
const updatedQuestion = await Question.findByIdAndUpdate(
37+
questionId,
38+
{ answered: true, answer },
39+
{ new: true }
40+
);
41+
42+
if (updatedQuestion) {
43+
res.json(updatedQuestion);
44+
} else {
45+
res.status(404).json({ error: 'Question not found' });
46+
}
47+
} catch (error) {
48+
res.status(500).json({ error: 'Failed to update question' });
49+
}
50+
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import FeedbackForm from '../models/feedback.js';
2+
3+
const submitFeedback = async (req, res) => {
4+
const {
5+
Name,
6+
Email,
7+
Subject,
8+
Date,
9+
Device,
10+
Priority,
11+
Suggestions,
12+
Feedback,
13+
Rating
14+
} = req.body;
15+
16+
const feedbackData = {
17+
name: Name,
18+
email: Email,
19+
subject: Subject,
20+
dateOfVisit: Date,
21+
deviceUsed: Device,
22+
priorityLevel: Priority,
23+
suggestions: Suggestions,
24+
feedback: Feedback,
25+
rating: Rating,
26+
};
27+
28+
try {
29+
const feed = new FeedbackForm(feedbackData);
30+
await feed.save();
31+
res.status(200).json({ status: 200, message: 'feedback form submitted successfully.' });
32+
} catch (error) {
33+
console.error("Error in submitting feedback form:", error);
34+
res.status(500).json({ error: "Feedback form not submitted successfully." });
35+
}
36+
};
37+
38+
export { submitFeedback };
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import NewsLetter from "../models/Newsletter.js";
2+
import { sendMailToSubscriber } from "../sendSuscribedMail.js";
3+
4+
export async function saveNewsletter(req, res) {
5+
try {
6+
const { name, email } = req.body;
7+
8+
if (!name || !email) {
9+
return res.status(400).json({ message: "All fields are required." });
10+
}
11+
12+
// Create new contact document
13+
const newNewsLetter = new NewsLetter({ name, email });
14+
sendMailToSubscriber(newNewsLetter)
15+
await newNewsLetter.save();
16+
res
17+
.status(201)
18+
.json({ message: "Contact form submitted successfully!", newNewsLetter });
19+
} catch (error) {
20+
console.error("Error saving contact form:", error);
21+
res.status(500).json({ message: "Failed to submit contact form.", error });
22+
}
23+
}
24+
25+
export async function getNewsletter(req, res) {
26+
res.send('hello newsletter')
27+
}

0 commit comments

Comments
 (0)