Skip to content

Commit

Permalink
Fixed forms
Browse files Browse the repository at this point in the history
  • Loading branch information
DerCed committed Feb 14, 2024
1 parent 926e8a7 commit 71827e2
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 84 deletions.
19 changes: 9 additions & 10 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@ export default function RootLayout({children,}: { children: React.ReactNode }) {
<head>
<meta charSet="UTF-8"/>
<meta name="viewport" content="width=device-width"/>
<link rel="icon" type="image/svg" href="/HackHPI_white.svg"/>
<link rel="icon" type="image/svg" href="/HackHPI24_white.png"/>
<title>
HackHPI 2024 | tomorrow's reality, today's vision. smart cities edition.
</title>
<meta name={"description"}
content={"Explore the future of urban living at HPI in Potsdam. Join motivated students for two days of innovation, workshops, and collaboration with top-notch sponsors offering support and expertise. Tackle a challenge and dive into the world of smart cities."}/>

</head>
<body>
<AppRouterCacheProvider>
<div style={{position: "relative", minHeight: "100vh"}}>
<div style={{paddingBottom: "17rem"}}>
<HackHPIWrapper>
{children}
</HackHPIWrapper>
</div>
<div style={{position: "absolute", bottom: 0, width: "100%", height: "17rem"}}>
<Footer/>
</div>
<div style={{paddingBottom: "17rem"}}>
<HackHPIWrapper>
{children}
</HackHPIWrapper>
</div>
<div style={{position: "absolute", bottom: 0, width: "100%", height: "17rem"}}>
<Footer/>
</div>
</div>
</AppRouterCacheProvider>
</body>
Expand Down
Binary file modified public/HackHPI24_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 40 additions & 21 deletions src/components/Faq/Faq.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
'use client'
import {
Box,
Button,
Card,
CardActions,
CardContent,
Container,
Grid,
Link,
List,
ListItemButton,
ListItemIcon,
Stack,
Typography,
useMediaQuery,
useTheme
Expand Down Expand Up @@ -118,33 +122,48 @@ export function Faq() {
return (
<HackHPIWrapper>
<Container sx={{paddingTop: 10, paddingBottom: 10}}>
<Typography variant={"h2"} component={"h1"} sx={{marginBottom: "1rem"}}>Frequently asked questions</Typography>
<Typography variant={"h2"} component={"h1"} sx={{marginBottom: "1rem"}}>Frequently asked
questions</Typography>
<Typography variant={"body1"} sx={{marginBottom: "4rem"}}>Can't find the answer you're looking for? You
can
always <Link href={"mailto:[email protected]"} color={"inherit"}>send us an email</Link> with your
inquiry!</Typography>
<Grid container spacing={7}>
<Grid item xs={12} md={4}>
<Card sx={{width: '100%', bgcolor: 'background.paper'}}>
<List component="nav" aria-label="main mailbox folders">
{
faqs.map((faq, idx) => (
<ListItemButton
key={faq.name}
selected={selectedIndex === idx}
onClick={(event) => handleListItemClick(event, idx)}
sx={{padding: 1}}
>
<ListItemIcon sx={{justifyContent: "center"}}>
<KeyboardArrowRight
/>
</ListItemIcon>
<Typography sx={{fontSize: "1rem"}} noWrap>{faq.name}</Typography>
</ListItemButton>
))
}
</List>
</Card>
<Stack spacing={3}>
<Card sx={{width: '100%', bgcolor: 'background.paper'}}>
<List component="nav" aria-label="main mailbox folders">
{
faqs.map((faq, idx) => (
<ListItemButton
key={faq.name}
selected={selectedIndex === idx}
onClick={(event) => handleListItemClick(event, idx)}
sx={{padding: 1}}
>
<ListItemIcon sx={{justifyContent: "center"}}>
<KeyboardArrowRight
/>
</ListItemIcon>
<Typography sx={{fontSize: "1rem"}} noWrap>{faq.name}</Typography>
</ListItemButton>
))
}
</List>
</Card>
<Card>
<CardContent>

<Typography gutterBottom variant={"h6"}
fontWeight={"bold"}>Still have Questions?</Typography>
<Typography>If you didn't find what you are looking for, feel free to
ask!</Typography>
</CardContent>
<CardActions>
<Button size="small" color={"inherit"}>Contact us</Button>
</CardActions>
</Card>
</Stack>
</Grid>
<Grid item xs={12} md={8}>
<Masonry spacing={3} columns={matches ? 2 : 1}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useMediaQuery,
useTheme
} from "@mui/material";
import {Facebook, GitHub, Instagram, LinkedIn, Mail, Twitter} from "@mui/icons-material";
import {GitHub, Instagram, LinkedIn, Mail} from "@mui/icons-material";
import HackHPIWrapper from "../Theme/HackHPIWrapper.jsx";
import HackHpiLogo from "../../assets/svg/HackHPI_white.svg"

Expand Down
102 changes: 55 additions & 47 deletions src/components/Registration/Registration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Radio,
RadioGroup,
Select,
Stack,
Step,
StepContent,
StepLabel,
Expand All @@ -25,7 +26,6 @@ import HackHPIWrapper from "../Theme/HackHPIWrapper.jsx";
import {LoadingButton} from "@mui/lab";
import {RegistrationRest} from "../../rest/RegistrationRest.js";
import {Send} from "@mui/icons-material";
import Help from '@mui/icons-material/Help';

// types: 0 = empty, 1 = textfield, 2 = date, 3 = select, 4 = radio

Expand Down Expand Up @@ -116,11 +116,7 @@ const personalData = [
input: ['High School Diploma', 'Bachelor', 'Master', 'PhD'],
name: "intendedDegree",
required: true,
},
{
formLabel: '',
type: 0,
},
}
]

const motivation = [
Expand Down Expand Up @@ -161,7 +157,7 @@ const skills = [
required: false,
},
{
formLabel: 'Basic steps of work experiences/studies/projects/...',
formLabel: 'Previous experiences / studies / projects...',
type: 1,
input: ['e. g. working student at HPI, ...'],
helperText: 'Outline the most important steps of your CV like work experiences, studies and projects.',
Expand Down Expand Up @@ -265,24 +261,34 @@ function Registration() {
}

function enableNext(inputList, name) {
console.log("NEXT", name)
console.log("#######", name, "#########")
if (!inputList) {
return;
}
return !inputList.content.reduce((previous, current) => {
console.log(current)
const result = inputList.content.reduce((previous, current) => {
console.log("--------", current.name, "----------", values[current.name])
if (!current.required && (values[current.name] === undefined || values[current.name] === "")){
console.log("Skipping evaluation - not required and empty")
return true
}
if (current.required && ((!values[current.name] && values[current.name] !== 0 ) || values[current.name] === "")){
console.log("Declining - required not filled")
return false
}
const meetsMax = current.max ? values[current.name]?.length <= current.max : true;
console.log("max", meetsMax)
const meetsMin = current.min ? values[current.name]?.length >= current.min : true;
console.log(previous, meetsMax, meetsMin)
console.log("min", meetsMin)

const meetsAll = meetsMax && meetsMin
console.log(current.name, meetsAll, previous)
return previous && meetsMax && meetsMin

}, true)
console.log("results for ", name, result)
return result
}

function errorCheck(props) {
const values = props.values;

}

function contentForm(props) {
const type = props.type;
Expand All @@ -306,6 +312,7 @@ function Registration() {
type="date"
name={name}
value={values[name] ?? ""}
style={{color: "inherit"}}
onChange={(event) => handleChange(event.target.name, event.target.value)}
/>
case 3:
Expand All @@ -326,10 +333,6 @@ function Registration() {
onChange={(event, value) => handleChange(event.target.name, value)}
errorCheck
>
{errorCheck({
values: values[name],

})}
{input.map((item, i) => (
<FormControlLabel value={i} control={<Radio/>} label={item}/>
))}
Expand Down Expand Up @@ -367,16 +370,13 @@ function Registration() {

}

const handleReset = () => {
setActiveStep(0);
};

return (

<HackHPIWrapper>
<Container sx={{paddingTop: 10, paddingBottom: 10}} id={"signupForm"}>
<Typography variant={"h2"} component={"h1"}>Registration</Typography>
<Stepper activeStep={activeStep} orientation="vertical">
<Container sx={{paddingTop: 10, paddingBottom: 10}} id={"signupForm"}>
<Typography variant={"h2"} component={"h1"}>Registration</Typography>
<Typography variant={"subtitle1"} gutterBottom>Apply now before March 15th!</Typography>
<Stepper activeStep={activeStep} orientation="vertical" sx={{mt: 5}}>
{steps.map((step, index) => (
<Step key={index}>
<StepLabel
Expand All @@ -387,18 +387,17 @@ function Registration() {
}
>
<Box direction="row" spacing={1}
sx={{display: "flex", justifyContent: "space-between"}}>
>
<Typography>
{step.label}
</Typography>
<Help/>
</Box>

</StepLabel>
<StepContent>
<Grid container spacing={3} xs={8}>
<Grid container spacing={3} md={8} xs={12}>
{step.content.map((item, i) => (
<Grid item xs={gridItemSize({name: item.name})}>
<Grid item md={gridItemSize({name: item.name})} xs={12}>
<FormControl fullWidth>
<FormLabel>
{item.formLabel}{item.required ? "*" : ""}
Expand All @@ -413,25 +412,34 @@ function Registration() {
</FormControl>
</Grid>
))}
<Grid item xs={2}>
{index === steps.length - 1 ?
<LoadingButton variant={"contained"} startIcon={<Send/>} loading={isSending}
onClick={submitForm}>
Send
</LoadingButton>
:
<Button variant="contained" onClick={handleNext}
disabled={enableNext(steps[index], step.label)}>
Next
</Button>
}
<Grid item xs={12}>
<Stack direction={"row"} spacing={2}>
{index === steps.length - 1 ?
<LoadingButton variant={"contained"} startIcon={<Send/>}
loading={isSending}
onClick={submitForm}>
Send
</LoadingButton>
:
<Button
variant="contained"
onClick={handleNext}
disabled={!enableNext(steps[index], step.label)}
>
Next
</Button>
}
<Grid item xs={2}>
<Button disabled={index === 0} onClick={handleBack} color={"inherit"}>
Back
</Button>
</Grid>

</Stack>


</Grid>
<Grid item xs={2}>
<Button disabled={index === 0} onClick={handleBack}>
Back
</Button>
</Grid>

</Grid>
</StepContent>
</Step>
Expand Down
5 changes: 2 additions & 3 deletions src/components/Sponsors/Sponsors.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {Box, Container, Grid} from "@mui/material";
import Starwit from "../../assets/images/sponsors/cropped-logo-starwit-white.png"
import ESchool from "../../assets/images/sponsors/trpnt_e-school-standalone-white_high.png"
import React from "react";
import HackHPIWrapper from "../Theme/HackHPIWrapper.jsx";
Expand All @@ -11,9 +10,9 @@ function Sponsors() {
<Box sx={{ paddingBottom: 10}}>
<Container maxWidth={"xl"}>
<Grid container sx={{paddingTop: "5rem"}} justifyContent={"center"} spacing={10}>
<Grid item>
{/*<Grid item>
<img src={Starwit.src} alt={"Logo of starwit"} style={{height: "5rem"}}/>
</Grid>
</Grid>*/}
<Grid item>
<img src={ESchool.src} alt={"Logo of E-Scool"} style={{height: "5rem"}}/>
</Grid>
Expand Down
4 changes: 2 additions & 2 deletions src/rest/RegistrationRest.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios from "axios";

export class RegistrationRest{
//baseUrl = "https://api.hackhpi.org/v1";
baseUrl = "http://localhost:8080/v1";
baseUrl = "https://api.hackhpi.org/v1";
//baseUrl = "http://localhost:8080/v1";

addRegistration(data){
return axios.post(this.baseUrl+"/registration", data)
Expand Down

0 comments on commit 71827e2

Please sign in to comment.