From 892e90bff460e09c9f5a3538768e7ac8dbffcabe Mon Sep 17 00:00:00 2001 From: Tamojit Das Date: Fri, 22 Nov 2024 21:04:21 +0530 Subject: [PATCH] app micro-opti: 1 --- backend/controllers/events.controller.js | 12 +++--- backend/controllers/payment.controller.js | 4 +- .../controllers/registration.controller.js | 4 +- backend/data/clubs.data.js | 28 ++++++++++++++ backend/data/clubs.data.json | 28 -------------- backend/data/events.data.js | 37 +++++++++++++++++++ backend/data/events.data.json | 37 ------------------- 7 files changed, 75 insertions(+), 75 deletions(-) create mode 100644 backend/data/clubs.data.js delete mode 100644 backend/data/clubs.data.json create mode 100644 backend/data/events.data.js delete mode 100644 backend/data/events.data.json diff --git a/backend/controllers/events.controller.js b/backend/controllers/events.controller.js index a01eaad..2207016 100644 --- a/backend/controllers/events.controller.js +++ b/backend/controllers/events.controller.js @@ -1,5 +1,5 @@ -import clubsData from "../data/clubs.data.json" assert { type: 'json' }; -import eventsData from "../data/events.data.json" assert { type: 'json' }; +import events from "../data/events.data.js"; +import clubs from "../data/clubs.data.js"; import Event from "../models/event.model.js"; import Membership from "../models/order.model.js"; import Payment from "../models/payment.model.js"; @@ -7,7 +7,7 @@ import Registration from "../models/registration.model.js"; export const getClubs = (req, res) => { try { - const data = clubsData.clubs; + const data = clubs; return res.status(200).json(data); } catch (error) { console.log(error.message); @@ -18,7 +18,7 @@ export const getClubs = (req, res) => { export const getClubById = (req, res) => { try { const id = req.params.id; - const data = clubsData.clubs.find(club => club.id === id); + const data = clubs.find(club => club.id === id); if (data) { res.status(200).json(data); } else { @@ -53,7 +53,7 @@ export const getMyClubs = async (req, res) => { export const getEvents = (req, res) => { try { - const data = eventsData.events; + const data = events; return res.status(200).json(data); } catch (error) { console.log(error.message); @@ -64,7 +64,7 @@ export const getEvents = (req, res) => { export const getEventById = (req, res) => { try { const id = req.params.id; - const data = eventsData.events.find(event => event.id === id); + const data = events.find(event => event.id === id); if (data) { res.status(200).json(data); } else { diff --git a/backend/controllers/payment.controller.js b/backend/controllers/payment.controller.js index 086c3b3..b0b9edb 100644 --- a/backend/controllers/payment.controller.js +++ b/backend/controllers/payment.controller.js @@ -1,5 +1,5 @@ import stripe from "../stripe/stripeInit.js"; -import clubsData from "../data/clubs.data.json" assert { type: 'json' }; +import clubs from "../data/clubs.data.js"; import Payment from "../models/payment.model.js"; import Membership from "../models/order.model.js"; @@ -47,7 +47,7 @@ export const confirmMembership = async (req, res) => { const { order_id, session_id, user_id } = req.body; console.log({ order_id, session_id, user_id }); - const product = clubsData.clubs.find(club => club.id === order_id); + const product = clubs.find(club => club.id === order_id); const session = await stripe.checkout.sessions.retrieve(session_id, { expand: ['payment_intent.payment_method'] }); diff --git a/backend/controllers/registration.controller.js b/backend/controllers/registration.controller.js index e4a067a..6c50ddb 100644 --- a/backend/controllers/registration.controller.js +++ b/backend/controllers/registration.controller.js @@ -1,5 +1,5 @@ import stripe from "../stripe/stripeInit.js"; -import eventsData from "../data/events.data.json" assert { type: 'json' }; +import events from "../data/events.data.js"; import Event from "../models/event.model.js"; import Registration from "../models/registration.model.js"; @@ -51,7 +51,7 @@ export const confirmRegistration = async (req, res) => { try { const { order_id, session_id, user_id } = req.body; - const product = eventsData.events.find(event => event.id === order_id); + const product = events.find(event => event.id === order_id); const session = await stripe.checkout.sessions.retrieve(session_id, { expand: ['payment_intent.payment_method'] }); diff --git a/backend/data/clubs.data.js b/backend/data/clubs.data.js new file mode 100644 index 0000000..f389e45 --- /dev/null +++ b/backend/data/clubs.data.js @@ -0,0 +1,28 @@ +const clubs = [ + { + "id": "CL_ENSY1234.CR", + "name": "Synergy", + "sport": "Cricket", + "institute": "Techno Main Saltlake", + "img": "https://cdn.magicdecor.in/com/2023/10/09151326/Cricket-Player-wallpaper-for-Walls.jpg", + "fees": 250 + }, + { + "id": "CL_ENCH4567.FB", + "name": "Charisma", + "sport": "Football", + "institute": "Techno Main Saltlake", + "img": "https://as2.ftcdn.net/v2/jpg/05/50/42/95/1000_F_550429570_g75wUkVM9XtiZLdTIudBA3B7Sf5OcNTm.jpg", + "fees": 250 + }, + { + "id": "CL_ENFI7890.BB", + "name": "Finnesse", + "sport": "Basketball", + "institute": "Techno Main Saltlake", + "img": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQkut0zReYFybNf2x1tv7BK1cXtCh1TnLiPxg&s", + "fees": 200 + } +]; + +export default clubs; \ No newline at end of file diff --git a/backend/data/clubs.data.json b/backend/data/clubs.data.json deleted file mode 100644 index 504ec06..0000000 --- a/backend/data/clubs.data.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "clubs": [ - { - "id": "CL_ENSY1234.CR", - "name": "Synergy", - "sport": "Cricket", - "institute": "Techno Main Saltlake", - "img": "https://cdn.magicdecor.in/com/2023/10/09151326/Cricket-Player-wallpaper-for-Walls.jpg", - "fees": 250 - }, - { - "id": "CL_ENCH4567.FB", - "name": "Charisma", - "sport": "Football", - "institute": "Techno Main Saltlake", - "img": "https://as2.ftcdn.net/v2/jpg/05/50/42/95/1000_F_550429570_g75wUkVM9XtiZLdTIudBA3B7Sf5OcNTm.jpg", - "fees": 250 - }, - { - "id": "CL_ENFI7890.BB", - "name": "Finnesse", - "sport": "Basketball", - "institute": "Techno Main Saltlake", - "img": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQkut0zReYFybNf2x1tv7BK1cXtCh1TnLiPxg&s", - "fees": 200 - } - ] -} \ No newline at end of file diff --git a/backend/data/events.data.js b/backend/data/events.data.js new file mode 100644 index 0000000..aff9f12 --- /dev/null +++ b/backend/data/events.data.js @@ -0,0 +1,37 @@ +const events = [ + { + "id": "EV_ENSY1234.CR", + "name": "JOSH", + "club": "Synergy", + "desc": "Inter College Cricket Tournament", + "institute": "Techno Main Saltlake", + "img": "https://wallpapercave.com/wp/wp13117884.jpg", + "price_pool": "Winner: ₹10K, Runners-up: ₹5K", + "fees": 300, + "date": "20/11/24" + }, + { + "id": "EV_ENCH4567.FB", + "name": "The Beautiful Game", + "club": "Charisma", + "desc": "Inter College Football Tournament", + "institute": "Techno Main Saltlake", + "img": "https://i.pinimg.com/736x/33/31/0a/33310a6aa68f2d817ce0cc094dca86b0.jpg", + "price_pool": "Winner: ₹10K, Runners-up: ₹5K", + "fees": 300, + "date": "21/11/24" + }, + { + "id": "EV_ENFI7890.BB", + "name": "Ballers", + "club": "Finnesse", + "desc": "Inter College Basketball Tournament", + "institute": "Techno Main Saltlake", + "img": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRVTuplO4f9UQv3vsxUYgno6CfHrf7DzfQAZw&s", + "price_pool": "Winner: ₹10K, Runners-up: ₹5K", + "fees": 300, + "date": "22/11/24" + } +]; + +export default events; \ No newline at end of file diff --git a/backend/data/events.data.json b/backend/data/events.data.json deleted file mode 100644 index 6dcde51..0000000 --- a/backend/data/events.data.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "events": [ - { - "id": "EV_ENSY1234.CR", - "name": "JOSH", - "club": "Synergy", - "desc": "Inter College Cricket Tournament", - "institute": "Techno Main Saltlake", - "img": "https://wallpapercave.com/wp/wp13117884.jpg", - "price_pool": "Winner: ₹10K, Runners-up: ₹5K", - "fees": 300, - "date": "20/11/24" - }, - { - "id": "EV_ENCH4567.FB", - "name": "The Beautiful Game", - "club": "Charisma", - "desc": "Inter College Football Tournament", - "institute": "Techno Main Saltlake", - "img": "https://i.pinimg.com/736x/33/31/0a/33310a6aa68f2d817ce0cc094dca86b0.jpg", - "price_pool": "Winner: ₹10K, Runners-up: ₹5K", - "fees": 300, - "date": "21/11/24" - }, - { - "id": "EV_ENFI7890.BB", - "name": "Ballers", - "club": "Finnesse", - "desc": "Inter College Basketball Tournament", - "institute": "Techno Main Saltlake", - "img": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRVTuplO4f9UQv3vsxUYgno6CfHrf7DzfQAZw&s", - "price_pool": "Winner: ₹10K, Runners-up: ₹5K", - "fees": 300, - "date": "22/11/24" - } - ] -} \ No newline at end of file