Skip to content

Commit 39434a8

Browse files
committed
Merge remote-tracking branch 'origin/backend' into input
2 parents 78c867b + f521db9 commit 39434a8

7 files changed

Lines changed: 320 additions & 62 deletions

File tree

client/dist/bundle.js.LICENSE.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*! https://mths.be/utf8js v2.1.2 by @mathias */
2+
3+
/**
4+
* @license React
5+
* react-dom.production.min.js
6+
*
7+
* Copyright (c) Facebook, Inc. and its affiliates.
8+
*
9+
* This source code is licensed under the MIT license found in the
10+
* LICENSE file in the root directory of this source tree.
11+
*/
12+
13+
/**
14+
* @license React
15+
* react.production.min.js
16+
*
17+
* Copyright (c) Facebook, Inc. and its affiliates.
18+
*
19+
* This source code is licensed under the MIT license found in the
20+
* LICENSE file in the root directory of this source tree.
21+
*/
22+
23+
/**
24+
* @license React
25+
* scheduler.production.min.js
26+
*
27+
* Copyright (c) Facebook, Inc. and its affiliates.
28+
*
29+
* This source code is licensed under the MIT license found in the
30+
* LICENSE file in the root directory of this source tree.
31+
*/
32+
33+
/**
34+
* @remix-run/router v1.14.0
35+
*
36+
* Copyright (c) Remix Software Inc.
37+
*
38+
* This source code is licensed under the MIT license found in the
39+
* LICENSE.md file in the root directory of this source tree.
40+
*
41+
* @license MIT
42+
*/
43+
44+
/**
45+
* React Router v6.21.0
46+
*
47+
* Copyright (c) Remix Software Inc.
48+
*
49+
* This source code is licensed under the MIT license found in the
50+
* LICENSE.md file in the root directory of this source tree.
51+
*
52+
* @license MIT
53+
*/

client/src/components/pages/Skeleton.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ import { GoogleOAuthProvider, GoogleLogin, googleLogout } from "@react-oauth/goo
44
import "../../utilities.css";
55
import "./Skeleton.css";
66
import Input from "../modules/input";
7+
import { getBets, getRandomGame } from "../../sports_bet_util";
78

89
//TODO: REPLACE WITH YOUR OWN CLIENT_ID
910
const GOOGLE_CLIENT_ID = "575558179875-rgo4ik0dami2mu3mb48gh9s761gpf0s6.apps.googleusercontent.com";
1011

1112
const Skeleton = ({ userId, handleLogin, handleLogout }) => {
13+
getRandomGame()
14+
.then((id) => {
15+
// console.log(id);
16+
getBets(id)
17+
.then((bets) => console.log(bets))
18+
})
19+
1220
return (
1321
<div>
1422
<div className="NavBar-container">

client/src/sports_bet_util.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
export function getRandomGame() {
2+
const year = 2023 // Math.floor(Math.random() * 7 + 2015);
3+
const url = `https://v1.basketball.api-sports.io/odds?league=12&season=${year + "-" + (year+1)}`
4+
return fetch(url, {
5+
method: "GET",
6+
headers: {
7+
"x-rapidapi-key": "8097ad8b9eb665d99d8e442839cce0cc"
8+
}
9+
})
10+
.then((response) => response.json())
11+
.then((json) => {
12+
const response = json["response"];
13+
// console.log(response);
14+
const random = Math.floor(Math.random() * response.length);
15+
const game = response[random]["game"];
16+
// console.log(game["teams"]["home"]["name"] + " vs " + game["teams"]["away"]["name"]);
17+
return game["id"]
18+
})
19+
.catch((error) => {
20+
throw `GET request to "${url}" failed with error:\n${error}`
21+
})
22+
}
23+
24+
export function getBets(gameId) {
25+
const url = `https://v1.basketball.api-sports.io/odds?game=${gameId}`
26+
return fetch(url, {
27+
method: "GET",
28+
headers: {
29+
"x-rapidapi-key": "8097ad8b9eb665d99d8e442839cce0cc"
30+
}
31+
})
32+
.then((response) => response.json())
33+
.then((json) => {
34+
console.log(json);
35+
const bookmakers = json["response"][0]["bookmakers"];
36+
for (let i = 0; i < bookmakers.length; i ++) {
37+
if (bookmakers[i]["name"] === "Marathon Bet") {
38+
console.log("Found Marathon bet")
39+
const bets = bookmakers[i]["bets"];
40+
let targetBetNames = [
41+
"Home/Away",
42+
"Highest Scoring Quarter"
43+
]
44+
let targetBets = {}
45+
for (let j = 0; j < bets.length; j ++) {
46+
if (targetBetNames.includes(bets[j]["name"])) {
47+
targetBets[bets[j]["name"]] = bets[j];
48+
}
49+
}
50+
return targetBets
51+
}
52+
}
53+
return {}
54+
})
55+
}

client/src/utilities.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ export function post(endpoint, params = {}) {
6161
throw `POST request to ${endpoint} failed with error:\n${error}`;
6262
});
6363
}
64+
65+

0 commit comments

Comments
 (0)