From b7585b420d4211d840e4a212360f9f760808379d Mon Sep 17 00:00:00 2001 From: Jonas Simoen Date: Sun, 2 Jun 2024 02:10:24 +0200 Subject: [PATCH] v2024.06.01 --- prisma/schema.prisma | 2 +- src/controllers/Team.ts | 6 ++---- src/controllers/User.ts | 2 +- src/utils/Common.ts | 8 -------- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a236533..587eabc 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -12,7 +12,7 @@ enum PlayerBoosterType { HiddenGem GoalRush TripleCaptain - FanFavourit + FanFavourite } model User { diff --git a/src/controllers/Team.ts b/src/controllers/Team.ts index 5133339..9dd7e12 100644 --- a/src/controllers/Team.ts +++ b/src/controllers/Team.ts @@ -1,4 +1,4 @@ -import { SavePlayersToJson, finalWeekId, upcomingWeekId, validateStartingLineup } from '../utils/Common'; +import { finalWeekId, upcomingWeekId, validateStartingLineup } from '../utils/Common'; import { prisma } from "../db/client" import HttpError from "../utils/HttpError"; import { max } from "lodash"; @@ -50,6 +50,7 @@ const CheckValidTeam = async (allPlayerIds: number[], reqBody: any, weekId: numb throw new HttpError("Too much players of the same club", 403); } // 3. Within budget + console.log(allPlayers); const totalValue = allPlayers.reduce((prev, curr) => ({ id: 0, value: (prev.value || 0) + (curr.value || 0) }), { id: 0, value: 0 }).value || 0; const budget = 100 - totalValue; if (budget <= 0) { @@ -133,7 +134,6 @@ export const PostAddTeamHandler = async (req: any, rep: any) => { } }), ]) - SavePlayersToJson(); rep.send({ user: team.user, team: { @@ -503,7 +503,6 @@ export const PostEditTeamHandler = async (req: any, rep: any) => { } }) ]); - SavePlayersToJson(); rep.send({ message: "Team successfully updated." }); @@ -647,7 +646,6 @@ export const PostTransfersTeamHandler = async (req: any, rep: any) => { } }); }); - SavePlayersToJson(); rep.send({ msg: "Transfers toegekend" }); } else { rep.status(406).send({ msg: "No transfers included." }); diff --git a/src/controllers/User.ts b/src/controllers/User.ts index 4b6b983..7a4f1a8 100644 --- a/src/controllers/User.ts +++ b/src/controllers/User.ts @@ -28,7 +28,7 @@ export const PaymentIntentHandler = async (req: any, rep: any) => { }); await stripe.paymentIntents.create({ - amount: 500, + amount: 1040, currency: "eur", automatic_payment_methods: { enabled: true, diff --git a/src/utils/Common.ts b/src/utils/Common.ts index 5b78dcb..2aefc05 100644 --- a/src/utils/Common.ts +++ b/src/utils/Common.ts @@ -36,12 +36,4 @@ export const validateStartingLineup = (starting: number[]) => { ((starting[2] >= 3) && (starting[2] <= 5)) && // 3-5 DEF ((starting[3] >= 3) && (starting[3] <= 5)) && // 3-5 MID ((starting[4] >= 1) && (starting[4] <= 3)) // 1-3 FOR -} - -export const SavePlayersToJson = async () => { - const players = await prisma.player.findMany({}); - - await fs.writeFile('static/players.json', JSON.stringify(players), (err) => { - if (err) throw err; - }); } \ No newline at end of file