diff --git a/.github/workflows/close-old-issue.yml b/.github/workflows/close-old-issue.yml deleted file mode 100644 index 67b04051..00000000 --- a/.github/workflows/close-old-issue.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Auto Close Inactive Issues - -on: - schedule: - # Run the job once a day at midnight - - cron: '0 0 * * *' - -jobs: - close_inactive_issues: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Close inactive issues - uses: actions/github-script@v6 - with: - script: | - const now = new Date(); - const daysToClose = 3; // Close issues after 3 days of inactivity - - const issues = await github.paginate(github.issues.listForRepo, { - owner: context.repo.owner, - repo: context.repo.repo, - state: "open", - }); - - for (const issue of issues) { - const lastUpdated = new Date(issue.updated_at); - const daysSinceUpdate = (now - lastUpdated) / (1000 * 60 * 60 * 24); - - if (daysSinceUpdate >= daysToClose) { - await github.issues.update({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issue.number, - state: "closed" - }); - console.log(`Closed inactive issue #${issue.number}, inactive for ${daysSinceUpdate.toFixed(1)} days.`); - } - } diff --git a/README.md b/README.md index ba9c6e34..f778546e 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,51 @@ The PlayCafe website communicates with a backend API to manage data. Here’s a | GET | `/api/bookings/:id` | Retrieves details of a specific booking by ID. | | DELETE | `/api/bookings/:id` | Cancels a specific booking by ID. | +## Troubleshooting + +If you encounter issues while setting up or using the PlayCafe website, here are some common problems and solutions: + +### 1. Issue: Unable to install dependencies +**Solution:** Make sure that you have Node.js installed. Run `npm install` again after confirming the Node.js installation. + +### 2. Issue: Website not starting +**Solution:** Run `npm start` and ensure that the correct port is open. If the error persists, check for any error logs in the terminal and ensure no other applications are using the same port. + +### 3. Issue: Database connection error +**Solution:** Verify that your database is running, and the connection details (host, username, password) are correct in the `.env` file. + +### 4. Issue: CSS/JavaScript not loading properly +**Solution:** Check if all static assets are being served correctly. Ensure that the paths to your CSS and JS files are correct and that they are being compiled if you're using a build tool like Webpack or Gulp. + +### 5. Issue: CORS (Cross-Origin Resource Sharing) error +**Solution:** Ensure the backend server has appropriate CORS policies configured to allow the frontend to communicate with it. If you're working with APIs, make sure that the necessary headers are included in server responses. + +### 6. Issue: Environment variables not working +**Solution:** Double-check the `.env` file configuration. Ensure that all required variables are defined and that the file is correctly loaded by your server or build system. + +### Debugging Tips +- Use `console.log` statements to track the flow of the code. +- Check browser developer tools for any front-end errors. +- Look into server logs for detailed error messages. +- **Use Logging Libraries:** Incorporate logging libraries like `winston` or `morgan` for better server-side error tracking. +- **Check Permissions:** If you're running the server on a remote machine, ensure that you have the necessary permissions (e.g., read/write access to necessary directories). +- **API Testing:** Use tools like Postman or Insomnia to test API endpoints individually if issues arise in data fetching. +- **Browser DevTools:** Use Chrome DevTools (F12) or Firefox Developer Tools (F12) for debugging. +- **React DevTools:** Install React Developer Tools browser extension for component debugging. +- **Network Tab:** Monitor API calls and responses in the Network tab. +- **Console Patterns:** Use `console.table()` for debugging arrays and objects. + +### Resources +- [Node.js Documentation](https://nodejs.org/en/docs/) +- [Express.js Guide](https://expressjs.com/en/starter/installing.html) +- [Common npm errors](https://docs.npmjs.com/common-errors) +- [How to Debug JavaScript Errors](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/What_went_wrong) +- [Troubleshooting Common CORS Issues](https://www.codecademy.com/articles/what-is-cors) +- [Webpack Documentation](https://webpack.js.org/concepts/) +- [React DevTools Guide](https://react.dev/learn/react-developer-tools) +- [React Error Boundaries](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) +- [React Performance Optimization](https://react.dev/learn/render-and-commit) + ## 🤝 Contributing We love contributions! 💙 Whether you're a participant in **GSSoC** or an open-source enthusiast, we welcome your input. Here's how you can contribute: @@ -215,10 +260,17 @@ We extend our heartfelt gratitude to all the amazing contributors who have made - - alo7lika + + jainaryan04
- alolika bhowmik + Aryan Ramesh Jain +
+ + + + haseebzaki-07 +
+ Haseeb Zaki
@@ -227,6 +279,15 @@ We extend our heartfelt gratitude to all the amazing contributors who have made
Ashwini_ab + + + + + + alo7lika +
+ alolika bhowmik +
@@ -235,8 +296,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Mahera Nayan - - tejasbenibagde @@ -251,6 +310,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Tyarla Shirisha + + + VinayLodhi1712 +
+ Vinay Anand Lodhi +
+ Amnyadav @@ -258,6 +324,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Aman Yadav + + NilanchalaPanda @@ -266,21 +334,19 @@ We extend our heartfelt gratitude to all the amazing contributors who have made - - haseebzaki-07 + + Sawan-Kushwah
- Haseeb Zaki + Sawan kushwah
- - Sawan-Kushwah + + Sumanbhadra
- Sawan kushwah + Suman Bhadra
- - Suhas-Koheda @@ -302,6 +368,9 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Vishnu Prasad Korada + + + sajalbatra @@ -332,13 +401,6 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Navneet Dadhich - - - VinayLodhi1712 -
- Vinay Anand Lodhi -
- lade6501 @@ -353,6 +415,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made MD REHAN + + T-Rahul-prabhu-38 @@ -369,6 +433,13 @@ We extend our heartfelt gratitude to all the amazing contributors who have made + + + vaishnavipal1869 +
+ vaishnavipal1869 +
+ tanishirai @@ -390,6 +461,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Sourabh Singh Rawat + + Shiva-Bajpai @@ -420,6 +493,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Ali Gates + + chikatlarakesh @@ -464,6 +539,8 @@ We extend our heartfelt gratitude to all the amazing contributors who have made Sapna Kul + + stutxi @@ -472,8 +549,10 @@ We extend our heartfelt gratitude to all the amazing contributors who have made + Syed-Farazuddin +
Syed Faraz
diff --git a/backend/controller/feedback.controller.js b/backend/controller/feedback.controller.js index b46eaddc..dc296335 100644 --- a/backend/controller/feedback.controller.js +++ b/backend/controller/feedback.controller.js @@ -1,8 +1,9 @@ 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(), @@ -10,15 +11,24 @@ const feedbackSchema = z.object({ 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", @@ -26,15 +36,18 @@ async function createFeedback(req, res) { }); } + 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", @@ -42,13 +55,33 @@ async function createFeedback(req, res) { } } + +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": "john@1212.com", -// "feedback": "This is a dummy feedback" -// } diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index c5a927fb..998c1300 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -6,6 +6,7 @@ import { Outlet } from 'react-router-dom'; import BackToTopButton from './components/Shared/BackToTopButton'; import Preloader from './components/Preloader'; + function App() { return ( <> @@ -14,6 +15,8 @@ function App() {