-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApply.tsx
More file actions
369 lines (349 loc) · 10.9 KB
/
Apply.tsx
File metadata and controls
369 lines (349 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
import { useEffect, useRef, useState } from "react";
import {
Typography,
TextField,
Checkbox,
FormControlLabel,
Button,
Select,
MenuItem,
FormControl,
InputLabel,
List,
ListItem,
ListItemText,
Box,
Link,
createTheme,
SelectChangeEvent,
ThemeProvider,
FormLabel,
Stack,
} from '@mui/material';
import { grey, blue } from '@mui/material/colors';
import TitleHero from "../features/TitleHero/TitleHero";
import WebsiteQuestions from "./applicationQuestions/website";
import SponsorshipsQuestions from "./applicationQuestions/sponsorships";
import './Apply.css'
import applyBanner from '/img/applyBanner.jpg';
const theme = createTheme({
palette: {
mode: 'dark',
primary: blue,
},
typography: {
fontFamily: "'Poppins', sans-serif",
h1: {
fontWeight: "800",
},
h2: {
fontWeight: "600",
},
h3: {
fontWeight: "500",
},
h4: {
fontWeight: "400",
},
body1: {
fontFamily: "'Poppins', sans-serif",
margin: "0",
},
},
components: {
MuiTextField: {
defaultProps: {
margin: 'dense', // sets default margin
fullWidth: true, // optional
},
},
MuiSelect: {
defaultProps: {
margin: 'dense', // sets default margin
fullWidth: true, // optional
}
},
MuiInputBase: {
styleOverrides: {
input: {
'&:focus': {
color: 'primary.main', // or 'primary.main' for blue on focus
},
},
},
},
}
});
const mdxComponents = {
h1: (props: any) => <Typography variant="h1" {...props} />,
h2: (props: any) => <Typography variant="h2" {...props} />,
h3: (props: any) => <Typography variant="h3" {...props} />,
h4: (props: any) => <Typography variant="h4" {...props} />,
h5: (props: any) => <Typography variant="h5" {...props} />,
h6: (props: any) => <Typography variant="h6" {...props} />,
p: (props: any) => <Typography variant="body1" {...props} />,
a: (props: any) => <Link {...props} />,
ul: (props: any) => <List {...props} />,
ol: (props: any) => <List component="ol" {...props} />,
li: (props: any) => (
<ListItem>
<ListItemText primary={props.children} />
</ListItem>
),
};
interface FormData {
common: {
name: string,
email: string,
major: string,
availability: string,
confirm: boolean,
gradYear: string
role: string
},
website: {
experience: string,
ideas: string,
goodweb: string
},
sponsorships: {
collab: string,
attract: string,
engagement: string
}
}
function WebsiteOfficerForm() {
const [formData, setFormData] = useState<FormData>({
common: {
name: '',
email: '',
// Unsure how to implement atm
gradYear: '',
// Possibly move to dropdown?
major: '',
// Want to make this slider
availability: '',
confirm: false,
role: ''
},
website: {
experience: '',
ideas: '',
goodweb: '',
},
sponsorships: {
collab: '',
attract: '',
engagement: ''
}
});
const pageInfo = {
title: "Apply",
description: `Apply for HackMelbourne's officer intake for Semester 2, 2025!`,
};
const toolsOptions = ['HTML/CSS', 'JavaScript', 'WordPress', 'Git/GitHub', 'Figma/Canva'];
const handleChange = (
e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement> | SelectChangeEvent<string>
) => {
const [section, key] = e.target.name.split('.') as [keyof FormData, string];
// Handler specific to checkboxes
if ('type' in e.target && e.target.type === 'checkbox') {
const target = e.target as HTMLInputElement;
// if (target.name === 'tools') {
// setFormData((prev) => ({
// ...prev,
// tools: target.checked
// ? [...prev.tools, target.value]
// : prev.tools.filter((tool) => tool !== target.value),
// }));
// } else if (target.name === 'confirm') {
// if (target.name === 'confirm') {
// setFormData((prev) => ({
// ...prev,
// confirm: target.checked,
// }));
// }
} else {
// For selects and other inputs without type or non-checkbox types:
const target = e.target as EventTarget & { name: string; value: string };
setFormData((prev) => ({
...prev,
[section]: {
...prev[section],
[key]: target.value,
}
}));
}
console.log(formData)
};
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
if (!formData.common.confirm) {
alert("Please confirm your information before submitting.");
return;
}
console.log("Form submitted:", formData);
alert("Application submitted!");
// Reset form or send to backend here
};
return (
<>
<TitleHero pageTitle={pageInfo.title} pageDescription={pageInfo.description}></TitleHero>
<ThemeProvider theme={theme}>
<div className="apply-banner">
<div className="apply-banner-bg"></div>
<div className="apply-banner-content">
<Typography className="apply-banner-title" variant="h2">
Join<br/>HackMelbourne
</Typography>
<div className="apply-banner-grid">
<div className="apply-banner-col">
<div className="apply-banner-card">
<Typography variant="h4">
Inclusive Community
</Typography>
<Typography variant="body1">
Our mission is to make tech and hackathons accessible to everyone, regardless of background, experience level, or university.
</Typography>
</div>
<div className="apply-banner-card">
<Typography variant="h4">
Learning-Focused
</Typography>
<Typography variant="body1">
We help design and run educational workshops, panels, and resources that teach everything from software engineering fundamentals to advanced web, mobile, and AI development.
</Typography>
</div>
</div>
<div className="apply-banner-col">
<div className="apply-banner-card">
<Typography variant="h4">
Culture of Collaboration
</Typography>
<Typography variant="body1">
HackMelbourne is dedicated to creating a space where students can connect, share ideas, and grow together. It doesn't matter if you're a first-time coders or seasoned hackers!
</Typography>
</div>
<div className="apply-banner-card">
<Typography variant="h4">
Represent and Compete
</Typography>
<Typography variant="body1">
Passionate about hackathons yourself? Officers also have opportunities to compete in national and international hackathons representing HackMelbourne!
</Typography>
</div>
</div>
</div>
</div>
</div>
{/* <img className="apply-banner" src={applyBanner}/> */}
<Box sx={{ maxWidth: 600, mx: 'auto', p: 3 }}>
<Stack spacing={3}>
<FormControl fullWidth>
<FormLabel required>
Full Name
</FormLabel>
<TextField
placeholder="Elliot Guo"
name="common.name"
value={formData.common.name}
onChange={handleChange}
/>
</FormControl>
<FormControl fullWidth>
<FormLabel required>
Student email
</FormLabel>
<TextField
placeholder="elliotguo@student.unimelb.edu.au"
name="common.email"
value={formData.common.email}
onChange={handleChange}
/>
</FormControl>
<Box
sx={{
display: 'flex',
gap: 2, // space between fields (theme.spacing(2) = 16px)
mb: 3, // bottom margin after the row
}}
>
<FormControl fullWidth>
<FormLabel required>
Graduation Year
</FormLabel>
<TextField
placeholder="2027"
name="common.gradYear"
value={formData.common.gradYear}
onChange={handleChange}
/>
</FormControl>
<FormControl fullWidth>
<FormLabel required>
Major
</FormLabel>
<TextField
placeholder="BSci"
name="common.major"
value={formData.common.major}
onChange={handleChange}
/>
</FormControl>
</Box>
{/* Have to add manual margin because select acts funny */}
<FormControl fullWidth sx={{ mt: 2 }}>
<FormLabel required sx={{
mb: 1,
'&.Mui-focused': {
color: 'text.secondary',
},
}}>
Which role are you applying for?
</FormLabel>
<Select
displayEmpty
name="common.role"
value={formData.common.role}
onChange={handleChange}
sx={() => ({
color:
formData.common.role ? 'text.primary' : 'text.secondary'
})}
>
<MenuItem value="">
<em>Select a role</em>
</MenuItem>
<MenuItem value="Website Officer">Website Officer</MenuItem>
<MenuItem value="Sponsorships Officer">Sponsorships Officer</MenuItem>
</Select>
</FormControl>
{
(() => {
switch (formData.common.role) {
case "Website Officer":
return (
<WebsiteQuestions
formData={formData.website}
handleChange={handleChange}
/>
);
case "Sponsorships Officer":
return (
<SponsorshipsQuestions
formData={formData.sponsorships}
handleChange={handleChange}
/>
);
default:
return null;
}
})()
}
</Stack>
</Box>
</ThemeProvider>
</>
);
}
export default WebsiteOfficerForm;