Skip to content

Commit

Permalink
app micro-opti: 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamoziit committed Nov 22, 2024
1 parent 6592f12 commit 892e90b
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 75 deletions.
12 changes: 6 additions & 6 deletions backend/controllers/events.controller.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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";
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);
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions backend/controllers/payment.controller.js
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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']
});
Expand Down
4 changes: 2 additions & 2 deletions backend/controllers/registration.controller.js
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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']
});
Expand Down
28 changes: 28 additions & 0 deletions backend/data/clubs.data.js
Original file line number Diff line number Diff line change
@@ -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;
28 changes: 0 additions & 28 deletions backend/data/clubs.data.json

This file was deleted.

37 changes: 37 additions & 0 deletions backend/data/events.data.js
Original file line number Diff line number Diff line change
@@ -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;
37 changes: 0 additions & 37 deletions backend/data/events.data.json

This file was deleted.

0 comments on commit 892e90b

Please sign in to comment.