Skip to content

Commit f51e441

Browse files
authored
Merge pull request #110 from codersforcauses/issue-107-committee_page_frontend_fixes
Issue 107 committee page frontend fixes
2 parents 934c5f3 + a46e89f commit f51e441

6 files changed

Lines changed: 70 additions & 83 deletions

File tree

client/src/components/main/MemberProfile.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export type MemberProfileData = {
2020
link: string;
2121
socialMediaUserName: string;
2222
}[];
23+
pk: number;
2324
};
2425

2526
type MemberProfileProps = {

client/src/hooks/useCommittee.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ export type ApiMember = {
88
profile_picture: string;
99
pronouns: string;
1010
about: string;
11+
social_media?: {
12+
link: string;
13+
socialMediaUserName: string;
14+
}[];
15+
pk: number;
1116
};
1217

1318
export function useCommittee() {

client/src/hooks/useMember.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type ApiMember = {
1111
link: string;
1212
socialMediaUserName: string;
1313
}[];
14+
pk: number;
1415
};
1516

1617
// return api member, import id number from router, is not enabled if not a number type

client/src/pages/about.tsx

Lines changed: 61 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import Image from "next/image";
2+
import Link from "next/link";
23

34
import { ApiMember, useCommittee } from "@/hooks/useCommittee";
45

56
export default function AboutPage() {
67
const { data: committee, isPending, error, isError } = useCommittee();
78

8-
const topRow: ApiMember[] = [];
9-
const bottomRow: ApiMember[] = [];
10-
//lists that will be populated with member objects in the committee
9+
const committeeList: ApiMember[] = [];
10+
//List that will be populated with member objects in the committee
1111
const roleOrder = [
1212
"President",
1313
"Vice President",
@@ -44,9 +44,7 @@ export default function AboutPage() {
4444
<Image
4545
src="/landing_placeholder.png"
4646
alt="/landing_placeholder.png"
47-
width={128}
48-
height={128}
49-
className="h-[90%] w-[90%]"
47+
fill={true}
5048
/>
5149
</div>
5250
</div>
@@ -61,23 +59,61 @@ export default function AboutPage() {
6159
</>
6260
);
6361

62+
function committeeImage(profilePic: string) {
63+
return (
64+
<div className="relative h-[8.75rem] w-[8.25rem] overflow-hidden">
65+
<Image
66+
src={profilePic === null ? "/landing_placeholder.png" : profilePic}
67+
alt="/landing_placeholder.png"
68+
fill
69+
className="object-cover object-center"
70+
/>
71+
</div>
72+
);
73+
}
74+
75+
function committeePortrait(committeeMember: ApiMember, id: number) {
76+
return (
77+
<>
78+
<div className="relative flex h-56 w-56 items-center justify-center bg-[url('/pixel-art-frame.svg')] bg-contain bg-center bg-no-repeat">
79+
{committeeMember.pk === 0 ? (
80+
committeeImage(committeeMember.profile_picture)
81+
) : (
82+
<Link href={`/members/${committeeMember.pk}`}>
83+
{committeeImage(committeeMember.profile_picture)}
84+
</Link>
85+
)}
86+
</div>
87+
<div className="text-md pl-3 text-left font-firaCode leading-tight">
88+
<p className="inline-block max-w-56 bg-card px-2 py-1 text-white">
89+
<text className="pr-2">
90+
{committeeMember.pk === 0 ? (
91+
<>{committeeMember.name}</>
92+
) : (
93+
<Link href={`/members/${committeeMember.pk}`}>
94+
{committeeMember.name}
95+
</Link>
96+
)}
97+
</text>
98+
<text className="text-left">{committeeMember.pronouns}</text>
99+
</p>
100+
<p className="w-full bg-card px-2 py-1 text-primary">
101+
{roleOrder[id]}
102+
</p>
103+
</div>
104+
</>
105+
);
106+
}
107+
64108
if (isPending) {
65109
for (let i = 0; i < 8; i++) {
66-
if (i < 4) {
67-
topRow.push({
68-
name: "Loading...",
69-
pronouns: "",
70-
profile_picture: "/landing_placeholder.png",
71-
about: "",
72-
});
73-
} else {
74-
bottomRow.push({
75-
name: "Loading...",
76-
pronouns: "",
77-
profile_picture: "/landing_placeholder.png",
78-
about: "",
79-
});
80-
}
110+
committeeList.push({
111+
name: "Loading...",
112+
pronouns: "",
113+
profile_picture: "/landing_placeholder.png",
114+
about: "",
115+
pk: 0,
116+
});
81117
}
82118
} else if (isError) {
83119
const errorMessage =
@@ -97,80 +133,23 @@ export default function AboutPage() {
97133
);
98134
} else {
99135
for (let i = 0; i < 8; i++) {
100-
if (i < 4) {
101-
topRow.push(committee[i]);
102-
} else {
103-
bottomRow.push(committee[i]);
104-
}
136+
committeeList.push(committee[i]);
105137
}
106138
}
107139

108140
return (
109141
<main className="min-h-screen bg-background">
110142
{about}
111143
{/* Portraits Section - DARK - Full Width */}
112-
<section className="w-full bg-background px-6 py-10 pt-16 md:px-10">
144+
<section className="w-full bg-background px-6 py-10 pb-20 pt-16 md:px-10">
113145
<div className="mx-auto max-w-6xl">
114-
{/* Top row - 4 Presidents */}
115146
<div className="flex flex-wrap justify-center gap-6 md:gap-10">
116-
{topRow.map((member, idx) => (
147+
{committeeList.map((member, idx) => (
117148
<div
118149
key={`top-${idx}`}
119150
className="flex flex-col items-start gap-0"
120151
>
121-
<div className="relative flex h-[11.25rem] w-[11.25rem] items-center justify-center bg-[url('/pixel-art-frame.svg')] bg-contain bg-center bg-no-repeat">
122-
<Image
123-
src={
124-
member.profile_picture === null
125-
? "/landing_placeholder.png"
126-
: member.profile_picture
127-
}
128-
alt="/landing_placeholder.png"
129-
width={108}
130-
height={108}
131-
className="h-[7.25rem] w-[6.75rem]"
132-
/>
133-
</div>
134-
<div className="w-[11.25rem] pl-3 text-left font-firaCode text-[0.5rem] leading-tight">
135-
<p className="inline-block bg-card px-2 py-1 text-white">
136-
{member.name} {member.pronouns}
137-
</p>
138-
<p className="inline-block bg-card px-2 py-1 text-primary">
139-
{roleOrder[idx]}
140-
</p>
141-
</div>
142-
</div>
143-
))}
144-
</div>
145-
146-
{/* Bottom row - 4 other roles */}
147-
<div className="mt-10 flex flex-wrap justify-center gap-6 md:gap-10">
148-
{bottomRow.map((member, idx) => (
149-
<div
150-
key={`bottom-${idx}`}
151-
className="flex flex-col items-start gap-0"
152-
>
153-
<div className="relative flex h-[11.25rem] w-[11.25rem] items-center justify-center bg-[url('/pixel-art-frame.svg')] bg-contain bg-center bg-no-repeat">
154-
<Image
155-
src={
156-
member.profile_picture === null
157-
? "/landing_placeholder.png"
158-
: member.profile_picture
159-
}
160-
alt="/landing_placeholder.png"
161-
width={108}
162-
height={108}
163-
className="h-[7.25rem] w-[6.75rem]"
164-
/>
165-
</div>
166-
<div className="w-[11.25rem] pl-3 text-left font-firaCode text-[0.5rem] leading-tight">
167-
<p className="inline-block bg-card px-2 py-1 text-white">
168-
{member.name} {member.pronouns}
169-
</p>
170-
<p className="inline-block bg-card px-2 py-1 text-primary">
171-
{roleOrder[4 + idx]}
172-
</p>
173-
</div>
152+
{committeePortrait(member, idx)}
174153
</div>
175154
))}
176155
</div>

server/game_dev/serializers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,5 @@ class Meta:
103103
"about",
104104
"pronouns",
105105
"social_media",
106+
"pk"
106107
]

server/game_dev/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def get_queryset(self):
8585
outputList = []
8686
roleOrder = ("P", "VP", "SEC", "TRE", "MARK", "EVE", "PRO", "FRE")
8787
placeholderMember = {"name": "Position not filled", "profile_picture": "url('/landing_placeholder.png')",
88-
"about": "", "pronouns": ""}
88+
"about": "", "pronouns": "", "pk": 0}
8989
for i in roleOrder:
9090
try:
9191
cur = Committee.objects.get(role=i).id

0 commit comments

Comments
 (0)