Skip to content

Commit

Permalink
double check on platform formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartaithan committed Apr 1, 2024
1 parent 762798c commit 00c8ca0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/api/games/[id]/sync/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getTitleTrophies,
getUserTrophiesEarnedForTitle,
} from "psn-api";
import { type Game } from "@/models/GameModel";

interface GameParams {
id: string;
Expand Down Expand Up @@ -43,7 +44,7 @@ export const GET = async (
.from("games")
.select("*, position(*)")
.eq("id", id)
.single();
.single<Game>();
if (gameError !== null) {
console.error("unable to update game by id", id, gameError);
return Response.json(
Expand All @@ -55,7 +56,7 @@ export const GET = async (
const auth: AuthorizationPayload = { accessToken: access_token };
const code = game.code;
let options: Partial<TitleTrophiesOptions> = {};
if (game.platform !== "ps5") {
if (game.platform.toLowerCase() !== "ps5") {
options = { ...options, npServiceName: "trophy" };
}

Expand Down
5 changes: 3 additions & 2 deletions app/api/games/[id]/trophies/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
getUserTrophiesEarnedForTitle,
getUserTrophyGroupEarningsForTitle,
} from "psn-api";
import { type Game } from "@/models/GameModel";

interface TrophyParams {
id: string;
Expand Down Expand Up @@ -55,7 +56,7 @@ export const GET = async (

const [profile, game] = await Promise.all([
supabase.from("profiles").select("language").eq("id", user.id).single(),
supabase.from("games").select("*, position(*)").eq("id", id).single(),
supabase.from("games").select("*, position(*)").eq("id", id).single<Game>(),
]);
if (profile.error !== null || profile === null) {
console.error("unable to get profile", profile.error);
Expand All @@ -76,7 +77,7 @@ export const GET = async (
let options: Partial<TitleTrophiesOptions> = {
headerOverrides: { "Accept-Language": language },
};
if (game.data.platform !== "ps5") {
if (game.data.platform.toLowerCase() !== "ps5") {
options = { ...options, npServiceName: "trophy" };
}

Expand Down
2 changes: 1 addition & 1 deletion app/api/games/add/search/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const POST = async (req: Request): Promise<Response> => {
let listOptions: Partial<TitleTrophiesOptions> = {
headerOverrides: { "Accept-Language": language },
};
if (platform !== "ps5") {
if (platform.toLowerCase() !== "ps5") {
listOptions = { ...listOptions, npServiceName: "trophy" };
}

Expand Down

0 comments on commit 00c8ca0

Please sign in to comment.