Skip to content

Commit cc91203

Browse files
committed
homepage binding done
1 parent 830fcb4 commit cc91203

File tree

83 files changed

+803
-357
lines changed

Some content is hidden

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

83 files changed

+803
-357
lines changed

backend/controllers/deleteJackpot.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// JackpotDeleting
2+
const JackpotDB = require('../models/jackpotDB'); // Assuming the ProductDB model
3+
4+
const deleteJackpot = async (req, res) => {
5+
try {
6+
const JackpotIdToDelete = req.params.JackpotIdToDelete; // Get productId from route parameters
7+
8+
// Find the product by ID and delete it from the database
9+
const deletedJackpot = await JackpotDB.findByIdAndDelete(JackpotIdToDelete);
10+
11+
if (!deletedJackpot) {
12+
return res.status(404).json({ message: 'Jackpot not found' });
13+
}
14+
15+
return res.status(200).json({ message: 'Jackpot deleted successfully' });
16+
} catch (error) {
17+
console.error('Error deleting product:', error);
18+
return res.status(500).json({ error: 'Internal server error' });
19+
}
20+
};
21+
22+
module.exports = {
23+
deleteJackpot,
24+
};

backend/controllers/deleteNews.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// NewsDeleting
2+
const NewsDB = require('../models/newsDB'); // Assuming the ProductDB model
3+
4+
const deleteNews = async (req, res) => {
5+
try {
6+
const NewsIdToDelete = req.params.NewsIdToDelete; // Get productId from route parameters
7+
8+
// Find the product by ID and delete it from the database
9+
const deletedNews = await NewsDB.findByIdAndDelete(NewsIdToDelete);
10+
11+
if (!deletedNews) {
12+
return res.status(404).json({ message: 'News not found' });
13+
}
14+
15+
return res.status(200).json({ message: 'News deleted successfully' });
16+
} catch (error) {
17+
console.error('Error deleting News:', error);
18+
return res.status(500).json({ error: 'Internal server error' });
19+
}
20+
};
21+
22+
module.exports = {
23+
deleteNews,
24+
};

backend/controllers/deleteWinner.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// WinnerDeleting
2+
const WinnerDB = require('../models/winnerDB'); // Assuming the ProductDB model
3+
4+
const deleteWinner = async (req, res) => {
5+
try {
6+
const WinnerIdToDelete = req.params.WinnerIdToDelete; // Get productId from route parameters
7+
8+
// Find the product by ID and delete it from the database
9+
const WinnerNews = await WinnerDB.findByIdAndDelete(WinnerIdToDelete);
10+
11+
if (!WinnerNews) {
12+
return res.status(404).json({ message: 'Winner not found' });
13+
}
14+
15+
return res.status(200).json({ message: 'Winner deleted successfully' });
16+
} catch (error) {
17+
console.error('Error deleting Winner:', error);
18+
return res.status(500).json({ error: 'Internal server error' });
19+
}
20+
};
21+
22+
module.exports = {
23+
deleteWinner,
24+
};

backend/controllers/displayJackpot.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const JackpotDB = require('../models/jackpotDB');
2+
3+
// Function to handle '/admin/view' route
4+
const viewJackpot = async (req, res) => {
5+
try {
6+
const RenderData = await JackpotDB.find({});
7+
// Send the retrieved products as a response
8+
res.json(RenderData);
9+
} catch (error) {
10+
console.log("Error in Server");
11+
res.status(500).send("Internal Server Error");
12+
}
13+
};
14+
15+
module.exports = {
16+
viewJackpot
17+
};

backend/controllers/displayNews.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const NewsDB = require('../models/newsDB');
2+
3+
// Function to handle '/admin/view' route
4+
const viewNews = async (req, res) => {
5+
try {
6+
const RenderData = await NewsDB.find({});
7+
// Send the retrieved products as a response
8+
res.json(RenderData);
9+
} catch (error) {
10+
console.log("Error in Server");
11+
res.status(500).send("Internal Server Error");
12+
}
13+
};
14+
15+
module.exports = {
16+
viewNews
17+
};

backend/controllers/displaySlotData.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Import the ProductDB model
2-
const Slot = require('../models/usersDB');
2+
const Slot = require('../models/jackpotDB');
33

44
// Function to handle '/admin/view' route
55
const displaySlotData = async (req, res) => {

backend/controllers/displayWinner.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const WinnerDB = require('../models/winnerDB');
2+
3+
// Function to handle '/admin/view' route
4+
const viewWinner = async (req, res) => {
5+
try {
6+
const RenderData = await WinnerDB.find({});
7+
// Send the retrieved products as a response
8+
res.json(RenderData);
9+
} catch (error) {
10+
console.log("Error in Server");
11+
res.status(500).send("Internal Server Error");
12+
}
13+
};
14+
15+
module.exports = {
16+
viewWinner
17+
};

backend/controllers/jackpotData.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const JackpotDB = require("../models/jackpotDB");
2+
const multer = require("multer");
3+
4+
// Set up multer storage
5+
const storage = multer.diskStorage({
6+
destination: function (req, file, cb) {
7+
cb(null, "uploads/jackpot"); // Define the destination folder for uploaded files
8+
},
9+
filename: function (req, file, cb) {
10+
cb(null, Date.now() + "-" + file.originalname); // Set unique file name
11+
},
12+
});
13+
14+
const upload = multer({ storage: storage });
15+
16+
const createJackpot = async (req, res) => {
17+
const { title, description, date, image } = req.body;
18+
19+
const jackpotData = {
20+
name:title,
21+
description,
22+
date,
23+
image,
24+
};
25+
26+
try {
27+
if (req.file) {
28+
jackpotData.image = req.file.filename;
29+
}
30+
31+
await JackpotDB.create(jackpotData);
32+
res.status(200).send("Jackpot created successfully");
33+
} catch (error) {
34+
console.error(error);
35+
res.status(500).send("Error creating jackpot");
36+
}
37+
};
38+
39+
module.exports = {
40+
createJackpot,
41+
upload,
42+
};

backend/controllers/newsData.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const NewsDB = require("../models/newsDB");
2+
const multer = require("multer");
3+
4+
// Set up multer storage
5+
const storage = multer.diskStorage({
6+
destination: function (req, file, cb) {
7+
cb(null, "uploads/news"); // Define the destination folder for uploaded files
8+
},
9+
filename: function (req, file, cb) {
10+
cb(null, Date.now() + "-" + file.originalname); // Set unique file name
11+
},
12+
});
13+
14+
const upload = multer({ storage: storage });
15+
16+
const createNews = async (req, res) => {
17+
const { title, date, description, image } = req.body;
18+
19+
const newsData = {
20+
name:title,
21+
date,
22+
description,
23+
image,
24+
};
25+
26+
try {
27+
if (req.file) {
28+
newsData.image = req.file.filename;
29+
}
30+
31+
await NewsDB.create(newsData);
32+
res.status(200).send("News created successfully");
33+
} catch (error) {
34+
console.error(error);
35+
res.status(500).send("Error creating news");
36+
}
37+
};
38+
39+
module.exports = {
40+
createNews,
41+
upload,
42+
};

backend/controllers/winnerData.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const WinnerDB = require("../models/winnerDB");
2+
const multer = require("multer");
3+
4+
// Set up multer storage
5+
const storage = multer.diskStorage({
6+
destination: function (req, file, cb) {
7+
cb(null, "uploads/winner"); // Define the destination folder for uploaded files
8+
},
9+
filename: function (req, file, cb) {
10+
cb(null, Date.now() + "-" + file.originalname); // Set unique file name
11+
},
12+
});
13+
14+
const upload = multer({ storage: storage });
15+
16+
const createWinner = async (req, res) => {
17+
console.log('Damn', req.body); // Log the request body
18+
19+
const { title, description, date, image } = req.body;
20+
21+
const winnerData = {
22+
name:title,
23+
description,
24+
date,
25+
image,
26+
};
27+
28+
try {
29+
if (req.file) {
30+
winnerData.image = req.file.filename;
31+
}
32+
33+
await WinnerDB.create(winnerData);
34+
res.status(200).send("Winner created successfully");
35+
} catch (error) {
36+
console.error(error);
37+
res.status(500).send("Error creating winner");
38+
}
39+
};
40+
41+
module.exports = {
42+
createWinner,
43+
upload,
44+
};

backend/models/jackpotDB.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const mongoose = require('mongoose');
2+
3+
const jackpotSchema = new mongoose.Schema({
4+
name: { type: String, required: true },
5+
description: { type: String, required: true },
6+
date: { type: Date, default: Date.now },
7+
image: String, // Field for storing image filename
8+
});
9+
10+
const Jackpot = mongoose.model('Jackpot', jackpotSchema);
11+
12+
module.exports = Jackpot;

backend/models/newsDB.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const mongoose = require('mongoose');
2+
3+
const newsSchema = new mongoose.Schema({
4+
name: { type: String, required: true },
5+
date: { type: Date, default: Date.now },
6+
description: { type: String, required: true },
7+
image: String, // Field for storing image filename
8+
});
9+
10+
const News = mongoose.model('News', newsSchema);
11+
12+
module.exports = News;

backend/models/winnerDB.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const mongoose = require('mongoose');
2+
3+
const winnerSchema = new mongoose.Schema({
4+
name: { type: String, required: true },
5+
description: { type: String, required: true },
6+
date: { type: Date, default: Date.now },
7+
image: String, // Field for storing image filename
8+
});
9+
10+
const Winner = mongoose.model('Winner', winnerSchema);
11+
12+
module.exports = Winner;

backend/routes/admin.js

+54-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const router = express.Router();
44
const app = express();
55
const multer = require("multer");
66
connectionDB();
7-
const deleteExpiredProducts = require ("../controllers/deleteExpiredProducts")
7+
const deleteExpiredProducts = require("../controllers/deleteExpiredProducts")
88
deleteExpiredProducts();
99

1010
// Set up multer storage
@@ -119,9 +119,60 @@ router.post("/api/verify-otp", loginVerifyOtp.verifyOTP);
119119

120120
/*___________________________________________SMS_RESEND_API_______________________________________*/
121121

122-
const loginResendOtp = require ("../controllers/loginOtpApi");
122+
const loginResendOtp = require("../controllers/loginOtpApi");
123123

124-
router.post("api/resend-otp", loginResendOtp.resendOTP)
124+
router.post("/api/resend-otp", loginResendOtp.resendOTP)
125+
126+
/*___________________________________________JACKPOT_DATA______________________________________*/
127+
128+
const jackpotData = require("../controllers/jackpotData");
129+
130+
const displayJackpotData = require ("../controllers/displayJackpot");
131+
132+
const jackpotDelete = require("../controllers/deleteJackpot");
133+
134+
//jackpot Image
135+
router.post("/api/jackpot", upload.single("image"), jackpotData.createJackpot)
136+
137+
//jackpot Data
138+
router.get("/api/jackpot/view", displayJackpotData.viewJackpot)
139+
140+
//jackpot Delete
141+
router.delete("/api/jackpot/delete/:JackpotIdToDelete", jackpotDelete.deleteJackpot);
142+
143+
/*___________________________________________WINNER_DATA______________________________________*/
144+
145+
const winnerData = require("../controllers/winnerData");
146+
147+
const displayWinnerData = require ("../controllers/displayWinner");
148+
149+
const WinnerDelete = require("../controllers/deleteWinner");
150+
151+
//winner Image
152+
router.post("/api/winner", upload.single("image"), winnerData.createWinner)
153+
154+
//winner Data
155+
router.get("/api/winner/view", displayWinnerData.viewWinner)
156+
157+
//winner Delete
158+
router.delete("/api/winner/delete/:WinnerIdToDelete", WinnerDelete.deleteWinner);
159+
160+
/*___________________________________________NEWS_DATA______________________________________*/
161+
162+
const newsData = require("../controllers/newsData");
163+
164+
const displayNewsData = require ("../controllers/displayNews");
165+
166+
const NewsDelete = require("../controllers/deleteNews");
167+
168+
//winner Image
169+
router.post("/api/news", upload.single("image"), newsData.createNews)
170+
171+
//winner Data
172+
router.get("/api/news/view", displayNewsData.viewNews)
173+
174+
//news Delete
175+
router.delete("/api/news/delete/:NewsIdToDelete", NewsDelete.deleteNews);
125176

126177
/*__________________________________________________________________________________________________*/
127178

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-5.87 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-5.87 KB
Binary file not shown.
-5.87 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
-5.87 KB
Binary file not shown.
Binary file not shown.
-5.87 KB
Binary file not shown.
Binary file not shown.

backend/uploads/1710080040770-JBL.jpg

-38.2 KB
Binary file not shown.
-2.3 MB
Binary file not shown.
-36.5 KB
Binary file not shown.
-36.5 KB
Binary file not shown.
-36.5 KB
Binary file not shown.
-36.5 KB
Binary file not shown.
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.38 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
-2.3 MB
Binary file not shown.
4.75 KB
261 KB
4.75 KB
155 KB
261 KB
4.59 KB
4.59 KB
23.7 KB
26.5 KB
155 KB
1.18 MB
1.18 MB
172 KB
59.2 KB
59.2 KB

0 commit comments

Comments
 (0)