generated from codersforcauses/django-nextjs-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Issue 70 add projects to member pages #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
belledw
wants to merge
18
commits into
main
Choose a base branch
from
issue-70-Add_projects_to_member_pages
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+175
−31
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b8b75dd
Adding backend support for fetching games by their contributors (WIP)
894a048
Added backend support for fetching games by their contributors
5867c23
Added hook to fetch game data from backend by contributor id
5eb4f83
Project section in Member Profile Page now fetches data from backend
9025848
Added links to the game detail page for each game on the member profile
8ced90a
Separated sections for games and artwork on Member Profile page.
a33202f
Merge remote-tracking branch 'origin/main' into issue-70-Add_projects…
cc8148e
Removed 'line too long' error from game_dev urls.py
8fced48
Fix link to member pages in IndividualGamePage component
phillipnguyenn 3374f54
Re-positioned member initials to be exactly in the centre of the frame
47aed70
Added documentation to backend
f9b6cc0
Removed duplicate GameShowcase path in urls.py
cd2451c
Prettified error messages in MemberProjectSection
8dd2a5b
Games link now opens in a new tab
0d04c12
Merge branch 'main' into issue-70-Add_projects_to_member_pages
e24bd1e
Removed unused commented code in MemberProfile.tsx
6e549a1
Merge branch 'main' into issue-70-Add_projects_to_member_pages
belledw 59af88c
Fixing flake8 issue
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { ArrowUpRight } from "lucide-react"; | ||
| import Image from "next/image"; | ||
| import Link from "next/link"; | ||
| import React from "react"; | ||
|
|
||
| import { useContributor } from "@/hooks/useContributor"; | ||
|
|
||
| type MemberProjectSectionProps = { | ||
| id: string; | ||
| }; | ||
|
|
||
| // From useGamesShowcase | ||
| function getGameCoverUrl( | ||
| game_cover_thumbnail: string | null | undefined, | ||
| ): string { | ||
| if (!game_cover_thumbnail) return "/game_dev_club_logo.svg"; | ||
| if (game_cover_thumbnail.startsWith("http")) return game_cover_thumbnail; | ||
| // Use environment variable for Django backend base URL | ||
| const apiBaseUrl = | ||
| process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"; | ||
| return `${apiBaseUrl}${game_cover_thumbnail}`; | ||
| } | ||
|
|
||
| export default function MemberProjectSection(props: MemberProjectSectionProps) { | ||
| const { data: games, isError, error } = useContributor(props.id); | ||
|
|
||
| { | ||
| /* Error handling from Games Showcase page */ | ||
| } | ||
| if (isError) { | ||
| const errorMessage = | ||
| error?.response?.status === 404 | ||
| ? "Games not found." | ||
| : "Failed to Load Games"; | ||
| return ( | ||
| <div className="mx-auto min-h-screen max-w-7xl px-6 py-16"> | ||
| <p | ||
| className="my-10 text-center font-firaCode text-lg text-red-500" | ||
| role="alert" | ||
| > | ||
| {errorMessage} | ||
| </p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <div className="mb-12"> | ||
| {!games || games.length === 0 ? ( | ||
| <p className="my-10 text-center font-firaCode text-lg text-[--light-3]"> | ||
| No games available. | ||
| </p> | ||
| ) : ( | ||
| <div className="m-auto my-5 flex flex-wrap justify-center gap-8"> | ||
| {games.map((game) => ( | ||
| <React.Fragment key={game.game_id}> | ||
| <div className="w-fit rounded-md p-5"> | ||
| <div className="group mb-2 grid h-44 w-96 grid-cols-1 grid-rows-1 overflow-clip rounded-md"> | ||
| <Image | ||
| src={getGameCoverUrl(game.game_data.thumbnail)} | ||
| alt={`${game.game_data.name} cover image`} | ||
| width={384} | ||
| height={176} | ||
| className="group-hover:brightness-75 group-hover:duration-200" | ||
| /> | ||
| <Link | ||
| className="mt-[-165px] hidden place-self-center rounded-md bg-accent p-3 font-firaCode text-light_1 drop-shadow-md hover:underline group-hover:flex group-hover:blur-0 group-hover:duration-200" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please don't use pixel units for css. The standard tailwind units are much more consistent and responsive. |
||
| href="#" | ||
| onClick={() => window.open(`/games/${game.game_id}`)} | ||
| > | ||
| Visit Game <ArrowUpRight className="ml-1" /> | ||
| </Link> | ||
| </div> | ||
| <p className="max-w-96 font-firaCode text-xl font-semibold"> | ||
| {game.game_data.name} | ||
| </p> | ||
| <p className="line-clamp-1 max-w-96 font-firaCode text-[--light-3]"> | ||
| {game.game_data.description} | ||
| </p> | ||
| </div> | ||
| </React.Fragment> | ||
| ))} | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { useQuery } from "@tanstack/react-query"; | ||
| import { AxiosError } from "axios"; | ||
|
|
||
| import api from "@/lib/api"; | ||
|
|
||
| type ApiContributorGameData = { | ||
| name: string; | ||
| thumbnail: string; | ||
| description: string; | ||
| }; | ||
|
|
||
| type ApiContributorGamesList = { | ||
| game_id: number; | ||
| role: string; | ||
| game_data: ApiContributorGameData; | ||
| }; | ||
|
|
||
| export const useContributor = (member: string | string[] | undefined) => { | ||
| return useQuery<ApiContributorGamesList[], AxiosError>({ | ||
| queryKey: ["contributor", member], | ||
| queryFn: async () => { | ||
| const response = await api.get(`/games/contributor/${member}/`); | ||
| return response.data; | ||
| }, | ||
| enabled: !!member, | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,16 @@ | ||
| from django.urls import path | ||
| from .views import EventListAPIView, EventDetailAPIView, GamesDetailAPIView, GameshowcaseAPIView, MemberAPIView, CommitteeAPIView | ||
| from .views import ContributorGamesListAPIView, EventListAPIView, EventDetailAPIView | ||
| from .views import GamesDetailAPIView, GameshowcaseAPIView, MemberAPIView, CommitteeAPIView | ||
|
|
||
| urlpatterns = [ | ||
| path("events/", EventListAPIView.as_view(), name="events-list"), | ||
| path("events/<int:id>/", EventDetailAPIView.as_view()), | ||
| path("games/<int:id>/", GamesDetailAPIView.as_view()), | ||
| path("gameshowcase/", GameshowcaseAPIView.as_view(), name="gameshowcase-api"), # Updated line for GameShowcase endpoint | ||
| path("games/contributor/<int:member>/", | ||
| ContributorGamesListAPIView.as_view()), | ||
| # Updated line for GameShowcase endpoint | ||
| path("gameshowcase/", GameshowcaseAPIView.as_view(), name="gameshowcase-api"), | ||
| path('members/<int:id>/', MemberAPIView.as_view()), | ||
| path("about/", CommitteeAPIView.as_view()) | ||
| path("about/", CommitteeAPIView.as_view()), | ||
| path('members/<int:id>/', MemberAPIView.as_view()) | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is unnecessary. We can just use the URL sent by the backend, and not display an image if necessary.
We definitely shouldn't be hard coding URLs like
"http://localhost:8000".