Skip to content

Commit f94d600

Browse files
committedDec 19, 2023
Update API and adapt new values
1 parent b43c834 commit f94d600

File tree

7 files changed

+40
-29
lines changed

7 files changed

+40
-29
lines changed
 

‎app/api/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ class API {
1212
}
1313
}
1414

15+
// https://proxy.boxscores.site/?apiUrl=stats.nba.com/stats/scoreboardv3&GameDate=2023-12-18&LeagueID=00
1516
static async getGamesByDate(date: string | undefined) {
16-
const response = await fetch(`${API_URL.base}v2/${date}/scoreboard.json`)
17+
const response = await fetch(
18+
`${API_URL.base}/stats/scoreboardv3&GameDate=${date}&LeagueID=00`,
19+
)
1720
const data = await response.json()
1821
return {
1922
data,

‎app/components/GamesList/index.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,30 @@ export function GamesList({ games }: GamesListProps) {
1818
) : (
1919
games.map(
2020
({
21-
seasonYear,
2221
gameId,
23-
startTimeUTC,
24-
statusNum,
22+
gameCode,
23+
gameTimeUTC,
24+
gameStatus,
2525
period,
26-
clock,
27-
vTeam,
28-
hTeam,
26+
gameClock,
27+
awayTeam,
28+
homeTeam,
2929
playoffs,
3030
}) => (
3131
<Link
3232
prefetch="intent"
33-
to={`/game/${seasonYear}/${gameId}`}
33+
to={`/game/${gameCode.slice(0, 4)}/${gameId}`}
3434
key={gameId}
3535
>
3636
<GameCard
37-
startTime={startTimeUTC}
38-
status={statusNum}
37+
startTime={gameTimeUTC}
38+
status={gameStatus}
3939
period={period.current}
4040
isEndOfPeriod={period.isEndOfPeriod}
4141
isHalftime={period.isHalftime}
42-
clock={clock}
43-
vTeam={vTeam}
44-
hTeam={hTeam}
42+
clock={gameClock}
43+
vTeam={awayTeam}
44+
hTeam={homeTeam}
4545
playoffs={playoffs}
4646
/>
4747
</Link>

‎app/components/TeamInfo/index.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ export type TeamInfoProps = {
1010
}
1111

1212
export function TeamInfo({ team, isPlayoffs = false }: TeamInfoProps) {
13+
const teamCode = team.teamTricode || team.triCode
14+
1315
return (
1416
<div className="flex w-1/4 flex-col items-center text-center">
15-
<TeamLogo team={team.triCode} size={48} />
17+
<TeamLogo team={teamCode!} size={48} />
1618
<p className="mt-1 whitespace-nowrap text-sm font-semibold">
17-
{TEAM_NAME[team.triCode as keyof typeof TEAM_NAME]}
19+
{TEAM_NAME[teamCode as keyof typeof TEAM_NAME]}
1820
</p>
19-
{!isPlayoffs && team.win && team.loss && (
20-
<p className="text-xs text-gray-400">{`${team.win}-${team.loss}`}</p>
21+
{!isPlayoffs && team.wins && team.losses && (
22+
<p className="text-xs text-gray-400">{`${team.wins}-${team.losses}`}</p>
2123
)}
2224
</div>
2325
)

‎app/constants.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const DEFAULT_DOMAIN = 'https://nba-remix.vercel.app'
22

33
export const API_URL = {
4-
base: 'http://data.nba.net/prod/',
4+
base: 'https://proxy.boxscores.site/?apiUrl=stats.nba.com',
55
details: 'https://data.nba.com/',
66
}
77

@@ -113,7 +113,7 @@ export const REGULAR_MONTH_END = 5
113113
export const REGULAR_PERIOD_COUNT = 4
114114

115115
export const DATE_DISPLAY_FORMAT = 'dd MMMM yyyy'
116-
export const DATE_LINK_FORMAT = 'yyyyMMdd'
116+
export const DATE_LINK_FORMAT = 'yyyy-MM-dd'
117117
export const EST_IANA_ZONE_ID = 'America/New_York'
118118
export const ONE_YEAR_IN_SECONDS = 365 * 24 * 60 * 60
119119

‎app/routes/$date.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ export const loader: LoaderFunction = async ({ params, request }) => {
5656
}
5757

5858
const {
59-
data: { games },
59+
data: {
60+
scoreboard: { games },
61+
},
6062
} = await API.getGamesByDate(params.date)
6163

6264
return json<LoaderData>({ games, requestInfo })

‎app/routes/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ export const loader: LoaderFunction = async ({ request }) => {
4646
}
4747

4848
const {
49-
data: { games },
49+
data: {
50+
scoreboard: { games },
51+
},
5052
} = await API.getGamesByDate(date)
5153

5254
return json<LoaderData>({ games, requestInfo })

‎app/types.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ export type RequestInfo = {
66
export type Team = {
77
tn?: string
88
score?: string
9-
triCode: string
10-
win?: string
11-
loss?: string
9+
triCode?: string
10+
teamTricode?: string
11+
wins?: string
12+
losses?: string
1213
}
1314

1415
export type TeamScore = {
@@ -123,9 +124,10 @@ export type Game = {
123124

124125
export type GameList = {
125126
gameId: string
127+
gameCode: string
126128
seasonYear: string
127-
startTimeUTC: string
128-
statusNum: number
129+
gameTimeUTC: string
130+
gameStatus: number
129131
period: {
130132
current: number
131133
isHalftime: boolean
@@ -134,9 +136,9 @@ export type GameList = {
134136
playoffs?: {
135137
seriesSummaryText: string
136138
}
137-
clock?: string
138-
vTeam: Team
139-
hTeam: Team
139+
gameClock?: string
140+
awayTeam: Team
141+
homeTeam: Team
140142
}
141143

142144
export type SocialMetas = {

0 commit comments

Comments
 (0)
Please sign in to comment.