generated from codersforcauses/django-nextjs-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Issue 10 member pages #61
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
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
4d61e54
Add MemberProfile component and MemberPage
KKatariah 0a8d588
u
KKatariah 06b7b19
configured routing to /members/{id}
3352c3d
merge main into issue-10-Member_Pages
phillipnguyenn a48d786
created basic profile outline
316a94f
Merge branch 'main' into issue-10-Member_pages
phillipnguyenn 2cb85a3
Merge branch 'main' for PR #50
phillipnguyenn 579dee3
added styling for profile outline
276f6f3
Added URL and API View for retrieval of a member
phillipnguyenn 3aad28a
improved styling for profile outline
509999e
created hook to fetch member onto member profile component
phillipnguyenn 5b6b406
Merge branch 'issue-10-Member_pages' of https://github.com/codersforc…
phillipnguyenn de23154
tried to get copilot to add some stuff so we can actually use the tem…
KKatariah c0ff440
idk bruh merge conflict
KKatariah 83355a8
restore working state from last good snapshot, kept additional files …
phillipnguyenn e254ef9
add blank option to profile_picture field in Member model
phillipnguyenn 9b8b4c9
refactor: memberpage loads data to pass -> memberprofile component. c…
phillipnguyenn a96e86c
updated member serializer to return active status
phillipnguyenn 8c78c98
added active status handling in MemberProfile and update useMember hook
phillipnguyenn 1f5f322
refactor: inactive member profile handling moved to api level, page h…
phillipnguyenn 9c0ecfb
updated error msg for inactive member to provide better clarity
phillipnguyenn 57120db
added frame to member profile image
1973bfd
added nifty improvement comment for inactive routing (issue #46)
phillipnguyenn c2329ff
Merge branch 'issue-10-Member_pages' of https://github.com/codersforc…
phillipnguyenn 2559d93
fixed frame image error
c18be58
Merge branch 'issue-10-Member_pages' of https://github.com/codersforc…
7dacb5f
added rough outline of projects section to member page, slightly modi…
7f34a91
Merge branch 'main' into issue-10-Member_pages
76ba876
modified styling for projects section
9ee1fc5
updated styling and spacing for member page
b10b225
changed text colour for profile header
5575d80
updated backend to expose and return only active member objects
phillipnguyenn 34a4193
changed page to sanitise router query before passing to hook
phillipnguyenn 1de20e3
updated component to match return of member hook
phillipnguyenn 27b6a3d
removed error handling on member hook and only enabled when receiving…
phillipnguyenn d0d0a93
added comments for member hook clarification
phillipnguyenn 94c362d
changed frame image to svg
3dbe102
changed styling to use colours defined in globals.css
5825df8
improved spacing for new svg image
f12a206
removed placeholder text in projects section
b7d1188
removed unnecessary divs
1a94d7b
restored projects section title
69ff26c
Merge branch 'main' into issue-10-Member_pages
belledw 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,94 @@ | ||
| "use client"; | ||
|
|
||
| import Image from "next/image"; | ||
|
|
||
| // unused atm, as the member isnt linked a project on the backend | ||
| /* export type MemberProfileProject = { | ||
| id: string; | ||
| name: string; | ||
| description?: string; | ||
| href?: string; | ||
| }; */ | ||
|
|
||
| export type MemberProfileData = { | ||
| name: string; | ||
| about: string; | ||
| pronouns?: string; | ||
| profile_picture?: string; | ||
| }; | ||
|
|
||
| type MemberProfileProps = { | ||
| member: MemberProfileData; | ||
| //projects?: MemberProfileProject[]; | ||
| }; | ||
|
|
||
| function initialsFromName(name: string) { | ||
| return name | ||
| .trim() | ||
| .split(/\s+/) | ||
| .slice(0, 2) | ||
| .map((part) => part[0]?.toUpperCase()) | ||
| .join(""); | ||
| } | ||
|
|
||
| export function MemberProfile({ member }: MemberProfileProps) { | ||
| const initials = initialsFromName(member.name); | ||
|
|
||
| return ( | ||
| <> | ||
| <div className="m-auto h-fit bg-card text-light_2"> | ||
| <div className="mx-2 flex flex-wrap items-center justify-center gap-y-5 py-7 lg:mx-10"> | ||
| <div className="grid grid-cols-1 grid-rows-1 items-center justify-items-center lg:mr-6"> | ||
| <div className="absolute size-32 overflow-clip bg-accent text-center"> | ||
| {member.profile_picture ? ( | ||
| <Image | ||
| src={member.profile_picture} | ||
| alt={`${member.name} profile picture`} | ||
| fill | ||
| className="object-cover" | ||
| /> | ||
| ) : ( | ||
| <div className="flex h-full w-full items-center justify-center font-jersey10 text-5xl text-muted-foreground"> | ||
| {initials} | ||
| </div> | ||
| )} | ||
| </div> | ||
| <Image | ||
| src="/frame.svg" | ||
| alt="golden pixel art frame around profile picture" | ||
| width={176} | ||
| height={192} | ||
| className="z-0 h-48 w-44" | ||
| /> | ||
| </div> | ||
| <div className="flex w-4/5 flex-col gap-2 rounded-md p-2.5 font-firaCode"> | ||
| <div className="flex"> | ||
| <p className="min-w-fit font-jersey10 text-4xl">{member.name}</p> | ||
| <hr className="ml-5 hidden w-full self-center border-light_2 lg:flex" /> | ||
| </div> | ||
| <p className="text-lg">{member.pronouns}</p> | ||
| <p>{member.about}</p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| {/* Template for Projects section */} | ||
| <div className="m-auto min-h-80 w-11/12"> | ||
| <h2 className="mt-7 text-center font-jersey10 text-5xl">Projects</h2> | ||
| <div className="m-auto my-5 flex flex-wrap justify-center gap-8"> | ||
| {/* Div below is a single project card */} | ||
| <div className="w-fit rounded-md p-5"> | ||
| <div className="mb-2 h-44 w-96 overflow-clip rounded-md p-5 text-neutral_1"> | ||
| {/* Image and/or Link to Project */} | ||
| </div> | ||
| <p className="max-w-96 font-firaCode text-xl font-semibold"> | ||
| {/* Project Title */} | ||
| </p> | ||
| <p className="line-clamp-1 max-w-96 font-firaCode text-[--light-3]"> | ||
| {/* Project description */} | ||
| </p> | ||
| </div> | ||
| </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,22 @@ | ||
| import { useQuery } from "@tanstack/react-query"; | ||
|
|
||
| import api from "@/lib/api"; | ||
|
|
||
| type ApiMember = { | ||
| name: string; | ||
| about: string; | ||
| pronouns?: string; | ||
| profile_picture?: string; | ||
| }; | ||
|
|
||
| // return api member, import id number from router, is not enabled if not a number type | ||
| export const useMember = (id?: number) => { | ||
| return useQuery<ApiMember>({ | ||
| queryKey: ["member", id], | ||
| queryFn: async () => { | ||
| const response = await api.get(`/members/${id}/`); | ||
| return response.data; | ||
| }, | ||
| enabled: Number.isFinite(id), | ||
| }); | ||
| }; |
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,40 @@ | ||
| import { useRouter } from "next/router"; | ||
|
|
||
| import { useMember } from "@/hooks/useMember"; | ||
|
|
||
| import { MemberProfile } from "../../components/main/MemberProfile"; | ||
|
|
||
| // hook assumes correct input, page sanitises to correct type | ||
| function normaliseId(id: string | string[] | number | undefined) { | ||
| if (typeof id === "number" && Number.isFinite(id)) { | ||
| return id; | ||
| } | ||
|
|
||
| if (typeof id === "string") { | ||
| const parsed = Number(id); | ||
| return Number.isFinite(parsed) ? parsed : undefined; | ||
| } | ||
|
|
||
| return undefined; | ||
| } | ||
|
|
||
| export default function MemberPage() { | ||
| const router = useRouter(); | ||
| const id = normaliseId(router.query.id); | ||
|
|
||
| const { | ||
| data: member, | ||
| isPending, | ||
| isError, | ||
| } = useMember(router.isReady ? id : undefined); | ||
|
|
||
| if (isPending) { | ||
| return null; | ||
| } | ||
|
|
||
| if (isError || !member) { | ||
| return <p>Member not found</p>; | ||
| } | ||
|
|
||
| return <MemberProfile member={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
18 changes: 18 additions & 0 deletions
18
server/game_dev/migrations/0005_alter_member_profile_picture.py
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,18 @@ | ||
| # Generated by Django 5.1.15 on 2026-01-18 15:01 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("game_dev", "0004_alter_event_date"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name="member", | ||
| name="profile_picture", | ||
| field=models.ImageField(blank=True, null=True, upload_to="profiles/"), | ||
| ), | ||
| ] |
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 |
|---|---|---|
|
|
@@ -23,5 +23,5 @@ class Meta: | |
| "name", | ||
| "profile_picture", | ||
| "about", | ||
| "pronouns" | ||
| "pronouns", | ||
| ] | ||
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,7 +1,8 @@ | ||
| from django.urls import path | ||
| from .views import EventListAPIView, EventDetailAPIView | ||
| from .views import EventListAPIView, EventDetailAPIView, MemberAPIView | ||
|
|
||
| urlpatterns = [ | ||
| path("events/", EventListAPIView.as_view(), name="events-list"), | ||
| path("events/<int:id>/", EventDetailAPIView.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.
Uh oh!
There was an error while loading. Please reload this page.