Skip to content

Commit 2e323bf

Browse files
Merge pull request #6 from uwcbc/cl-21-member-profile-component
Feature: CL-21: Member profile table and individual view
2 parents b8ecb2c + 8e6117b commit 2e323bf

File tree

8 files changed

+68
-216
lines changed

8 files changed

+68
-216
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2-
*.pyc
2+
*.pyc
3+
*env

backend/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import pymysql
2+
3+
pymysql.install_as_MySQLdb()

frontend/public/index.html

+19-20
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1" />
7-
<meta name="theme-color" content="#000000" />
8-
<meta
9-
name="description"
10-
content="Web site created using create-react-app"
11-
/>
12-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13-
<!--
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<meta name="theme-color" content="#000000" />
7+
<meta
8+
name="description"
9+
content="Web site created using create-react-app"
10+
/>
11+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
12+
<!--
1413
manifest.json provides metadata used when your web app is installed on a
1514
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
1615
-->
17-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18-
<!--
16+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
17+
<!--
1918
Notice the use of %PUBLIC_URL% in the tags above.
2019
It will be replaced with the URL of the `public` folder during the build.
2120
Only files inside the `public` folder can be referenced from the HTML.
@@ -24,12 +23,12 @@
2423
work correctly both with client-side routing and a non-root public URL.
2524
Learn how to configure a non-root public URL by running `npm run build`.
2625
-->
27-
<title>React App</title>
28-
</head>
29-
<body>
30-
<noscript>You need to enable JavaScript to run this app.</noscript>
31-
<div id="root"></div>
32-
<!--
26+
<title>Celesta by UWCBC</title>
27+
</head>
28+
<body>
29+
<noscript>You need to enable JavaScript to run this app.</noscript>
30+
<div id="root"></div>
31+
<!--
3332
This HTML file is a template.
3433
If you open it directly in the browser, you will see an empty page.
3534
@@ -39,5 +38,5 @@
3938
To begin the development, run `npm start` or `yarn start`.
4039
To create a production bundle, use `npm run build` or `yarn build`.
4140
-->
42-
</body>
41+
</body>
4342
</html>

frontend/src/App.tsx

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
import { AppShell, Navbar, Header } from '@mantine/core'
22
import Heading from './components/Heading'
33
import MemberTable from './components/MemberTable'
4-
import axios from 'axios'
5-
import { useEffect, useState } from 'react'
64

75
function App() {
8-
const [post, setPost] = useState(null);
9-
10-
useEffect(() => {
11-
axios.get('http://localhost:8000/api/students/').then((response) => {
12-
setPost(response.data);
13-
});
14-
}, []);
15-
16-
if (!post) return null;
17-
186
return (
197
<AppShell
208
padding='md'
@@ -29,7 +17,7 @@ function App() {
2917
</Header>
3018
}
3119
>
32-
<MemberTable member_list={post}/>
20+
<MemberTable />
3321
</AppShell>
3422
)
3523
}

frontend/src/components/MemberEntry.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface MemberEntryProps {
66
image?: string
77
}
88

9-
// TODO: link member.mainInstrument to instrument assets, and add created time
9+
// TODO: link member.mainInstrument to instrument assets, and add created time (CL-42)
1010
const MemberEntry = ({ member, image }: MemberEntryProps) => {
1111
return (
1212
<Group miw={300}>

frontend/src/components/MemberProfile.tsx

+17-48
Original file line numberDiff line numberDiff line change
@@ -18,52 +18,19 @@ interface MemberProfileProps {
1818
member: Member
1919
}
2020

21-
const types = [
22-
{ value: 'undergraduate', label: 'Undergraduate' },
23-
{ value: 'graduate', label: 'Graduate' },
24-
{ value: 'alumni', label: 'Alumni' },
25-
{ value: 'other', label: 'Other' }
26-
]
21+
const types = ['Undergraduate', 'Graduate', 'Alumni', 'Other']
2722

2823
const faculties = [
29-
{ value: 'arts', label: 'Arts' },
30-
{ value: 'engineering', label: 'Engineering' },
31-
{ value: 'environment', label: 'Environment' },
32-
{ value: 'health', label: 'Health' },
33-
{ value: 'math', label: 'Math' },
34-
{ value: 'science', label: 'Science' }
24+
'Arts',
25+
'Engineering',
26+
'Environment',
27+
'Health',
28+
'Math',
29+
'Science'
3530
]
3631

37-
const instruments = [
38-
{
39-
value: 'Crimson',
40-
label: 'Woodcock, american'
41-
},
42-
{
43-
value: 'Green',
44-
label: 'Goanna lizard'
45-
},
46-
{
47-
value: 'Aquamarine',
48-
label: 'Common wombat'
49-
},
50-
{
51-
value: 'Indigo',
52-
label: 'Ocelot'
53-
},
54-
{
55-
value: 'Pink',
56-
label: 'Banded mongoose'
57-
},
58-
{
59-
value: 'Orange',
60-
label: "Squirrel, smith's bush"
61-
},
62-
{
63-
value: 'Yellow',
64-
label: 'Lizard, collared'
65-
}
66-
]
32+
// TODO: fill with proper instruments (CL-42)
33+
const instruments: string[] = []
6734

6835
const sizes = [
6936
{ value: 'xs', label: 'XS' },
@@ -77,27 +44,29 @@ const MemberProfile = ({ opened, onClose, member }: MemberProfileProps) => {
7744
const [firstName, setFirstName] = useState<string>('')
7845
const [lastName, setLastName] = useState<string>('')
7946
const [email, setEmail] = useState<string>('')
80-
const [type, setType] = useState<string | null>()
47+
const [type, setType] = useState<string | null>('')
8148
const [mainInstrument, setMainInstrument] = useState<string | null>()
8249
const [instrument, setInstrument] = useState<string[]>([]) // TODO: disable "main instrument" option in secondary instrument list
8350

8451
useEffect(() => {
8552
setFirstName(member.first_name)
8653
setLastName(member.last_name)
8754
setEmail(member.email)
88-
setType(member.type)
55+
setType(types[member.member_type - 1])
8956
}, [member])
9057

9158
const UWStudentProfile = () => {
92-
const [faculty, setFaculty] = useState<string | null>()
59+
const [faculty, setFaculty] = useState<string | null>('')
9360
const [studentNumber, setStudentNumber] = useState<number>()
9461
const [watIAM, setWatIAM] = useState<string>()
9562

9663
useEffect(() => {
97-
setFaculty(member.faculty)
64+
if (member.faculty !== undefined && typeof member.faculty === 'number')
65+
setFaculty(faculties[member.faculty - 1])
9866
setStudentNumber(member.studentNumber ?? undefined)
9967
setWatIAM(member.watIAM ?? undefined)
10068
}, [])
69+
10170
return (
10271
<>
10372
<Select
@@ -158,9 +127,9 @@ const MemberProfile = ({ opened, onClose, member }: MemberProfileProps) => {
158127
data={types}
159128
withAsterisk
160129
value={type}
161-
onChange={setType}
130+
onChange={(value) => setType(value || null)}
162131
/>
163-
{(type === 'undergraduate' || type === 'graduate') && (
132+
{(type === 'Undergraduate' || type === 'Graduate') && (
164133
<UWStudentProfile />
165134
)}
166135
<Select

frontend/src/components/MemberTable.tsx

+12-120
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,30 @@
1-
import { useState } from 'react'
21
import { Box, Flex, Title } from '@mantine/core'
32
import { useDisclosure } from '@mantine/hooks'
43
import MemberProfile from './MemberProfile'
54
import { Member } from 'types'
5+
import axios from 'axios'
6+
import { useEffect, useState } from 'react'
67
import MemberEntry from './MemberEntry'
78

8-
const data = [
9-
{
10-
id: '8',
11-
first_name: 'Nester',
12-
last_name: 'Preddle',
13-
14-
type: 'undergraduate',
15-
studentNumber: 21783203,
16-
watIAM: 'Awaradam',
17-
mainInstrument: '',
18-
shirt_size: 'MW'
19-
},
20-
{
21-
id: '4',
22-
first_name: 'Edward',
23-
last_name: 'Duchenne',
24-
25-
type: 'undergraduate',
26-
studentNumber: 28213544,
27-
watIAM: 'Bentota',
28-
mainInstrument: '',
29-
shirt_size: 'RQ'
30-
},
31-
{
32-
id: '263',
33-
first_name: 'Cynthia',
34-
last_name: 'Cornthwaite',
35-
36-
type: 'undergraduate',
37-
studentNumber: 25405594,
38-
watIAM: 'Malmö',
39-
mainInstrument: '',
40-
shirt_size: 'UI'
41-
},
42-
{
43-
id: '21097',
44-
first_name: 'Bernita',
45-
last_name: 'Markwelley',
46-
47-
type: 'undergraduate',
48-
studentNumber: 27762875,
49-
watIAM: 'Liangping',
50-
mainInstrument: '',
51-
shirt_size: 'EA'
52-
},
53-
{
54-
id: '19',
55-
first_name: 'Rebecca',
56-
last_name: 'McNally',
57-
58-
type: 'graduate',
59-
studentNumber: 25796776,
60-
watIAM: 'Kekaha',
61-
mainInstrument: '',
62-
shirt_size: 'QE'
63-
},
64-
{
65-
id: '22',
66-
first_name: 'Ada',
67-
last_name: 'Lafflina',
68-
69-
type: 'graduate',
70-
studentNumber: 28382715,
71-
watIAM: 'Lehu',
72-
mainInstrument: '',
73-
shirt_size: 'KL'
74-
},
75-
{
76-
id: '29',
77-
first_name: 'Maxi',
78-
last_name: 'Shiel',
79-
80-
type: 'alumni',
81-
studentNumber: 23363880,
82-
watIAM: 'Ashley',
83-
mainInstrument: '',
84-
shirt_size: 'QE'
85-
},
86-
{
87-
id: '6',
88-
first_name: 'Buddie',
89-
last_name: 'Jewell',
90-
91-
type: 'alumni',
92-
studentNumber: 29634676,
93-
watIAM: 'Georgetown',
94-
mainInstrument: '',
95-
shirt_size: 'CS'
96-
},
97-
{
98-
id: '1',
99-
first_name: 'Caroljean',
100-
last_name: 'Menzies',
101-
102-
type: 'other',
103-
studentNumber: 23355570,
104-
watIAM: 'Terapo Mission',
105-
mainInstrument: '',
106-
shirt_size: 'KC'
107-
},
108-
{
109-
id: '203',
110-
first_name: 'Callida',
111-
last_name: 'Gabbot',
112-
113-
type: 'other',
114-
studentNumber: 20895476,
115-
watIAM: 'Ratanakiri',
116-
mainInstrument: '',
117-
shirt_size: 'HE'
118-
}
119-
]
120-
121-
interface MemberListProps {
122-
member_list : []
123-
}
124-
125-
const MemberTable = ({member_list}: MemberListProps) => {
9+
const MemberTable = () => {
12610
const [opened, { open, close }] = useDisclosure(false)
12711
const [openMember, setOpenMember] = useState<Member | null>(null)
12812

13+
const [memberList, setMemberList] = useState([])
14+
15+
useEffect(() => {
16+
axios.get('http://localhost:8000/api/students/').then((response) => {
17+
setMemberList(response.data)
18+
})
19+
}, [])
20+
12921
return (
13022
<>
13123
<Title order={3} mb={10}>
13224
Members
13325
</Title>
13426
<Flex justify='flex-start' gap='xs' wrap='wrap' direction='row'>
135-
{member_list.map((member: Member) => (
27+
{memberList.map((member: Member) => (
13628
<Box
13729
key={member.id}
13830
onClick={() => {

frontend/src/types.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
export interface Member {
2-
id: string
3-
first_name: string
4-
last_name: string
5-
email: string
6-
type: string
7-
faculty?: string
8-
studentNumber?: number
9-
watIAM?: string | null
10-
mainInstrument: string
11-
otherInstruments?: string
12-
shirt_size?: string
13-
other?: string
14-
}
2+
id: string
3+
first_name: string
4+
last_name: string
5+
email: string
6+
member_type: number
7+
faculty?: string
8+
studentNumber?: number
9+
watIAM?: string
10+
mainInstrument: string
11+
otherInstruments?: string
12+
shirt_size?: string
13+
other?: string
14+
}

0 commit comments

Comments
 (0)