Skip to content

Commit a8bfc95

Browse files
authored
Merge pull request #142 from codersforcauses/issue-141-remove_start_of_URL_generation_function
Issue 141 remove URL generation fn
2 parents e1527ba + cfa0991 commit a8bfc95

2 files changed

Lines changed: 2 additions & 13 deletions

File tree

client/src/hooks/useGameshowcase.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,10 @@ type UiShowcaseGame = Omit<ApiShowcaseGame, "game_cover_thumbnail"> & {
2626
gameCover: string;
2727
};
2828

29-
function getGameCoverUrl(
30-
game_cover_thumbnail: string | null | undefined,
31-
): string {
32-
if (!game_cover_thumbnail) return "/game_dev_club_logo.svg";
33-
if (game_cover_thumbnail.startsWith("http")) return game_cover_thumbnail;
34-
// Use environment variable for Django backend base URL
35-
const apiBaseUrl =
36-
process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000";
37-
return `${apiBaseUrl}${game_cover_thumbnail}`;
38-
}
39-
4029
function transformApiShowcaseGameToUi(data: ApiShowcaseGame): UiShowcaseGame {
4130
return {
4231
...data,
43-
gameCover: getGameCoverUrl(data.game_cover_thumbnail),
32+
gameCover: data.game_cover_thumbnail ?? "/game_dev_club_logo.svg",
4433
};
4534
}
4635

server/game_dev/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def get_queryset(self):
6666
class GameshowcaseAPIView(APIView):
6767
def get(self, request):
6868
showcases = GameShowcase.objects.all()
69-
serializer = GameshowcaseSerializer(showcases, many=True)
69+
serializer = GameshowcaseSerializer(showcases, many=True, context={'request': request})
7070
return Response(serializer.data)
7171

7272

0 commit comments

Comments
 (0)