Skip to content

Commit

Permalink
587 changes to the form section (#593)
Browse files Browse the repository at this point in the history
* removed question about virtual hackathons

* frontend country of residence

* fixing lint errors
  • Loading branch information
avsomers25 committed Oct 4, 2023
1 parent 3657e4c commit d407f80
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"react-scroll-parallax": "^1.3.5",
"react-scrollable-anchor": "^0.6.1",
"react-select": "^2.1.2",
"react-select-country-list": "^2.2.3",
"react-spinners": "^0.9.0",
"react-toggle": "^4.1.1",
"react-window": "^1.8.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import { ProfileType } from "../../../../Profile";
import PropTypes from "prop-types";
import { PulseLoader } from "react-spinners";

import countryList from "react-select-country-list";


class About extends Component {
// constructor(props) {
// constructor(props) {npm
// super(props);
// this.updateUser = this.updateUser.bind(this);
// }
Expand Down Expand Up @@ -50,7 +52,8 @@ class About extends Component {
update_user.gender = this.state.user.gender;
update_user.ethnicity = this.state.user.ethnicity;
update_user.hackathon_count = this.state.user.hackathon_count;

update_user.country_of_residence = this.state.user.country_of_residence;

this.props.profile.Set(update_user)
.then(res => {
this.setState({
Expand Down Expand Up @@ -90,7 +93,8 @@ class About extends Component {
required: { value: true, errorMessage: "Invalid first name" },
pattern: { value: "^[A-Za-z0-9]+$", errorMessage: "Invalid character" },
minLength: { value: 1, errorMessage: "Invalid length" },
maxLength: { value: 100, errorMessage: "Invalid length" } }} />
maxLength: { value: 100, errorMessage: "Invalid length" }
}} />
</Col>
<Col xs={(mobile) ? 12 : 6}>
<AvField name="last"
Expand All @@ -103,7 +107,8 @@ class About extends Component {
required: { value: true, errorMessage: "Invalid last name" },
pattern: { value: "^[A-Za-z0-9]+$", errorMessage: "Invalid character" },
minLength: { value: 1, errorMessage: "Invalid length" },
maxLength: { value: 100, errorMessage: "Invalid length" } }} />
maxLength: { value: 100, errorMessage: "Invalid length" }
}} />
</Col>
</FormGroup>
<FormGroup row>
Expand All @@ -115,8 +120,9 @@ class About extends Component {
value={user.phone_number}
onChange={(e) => { user.phone_number = e.target.value; this.updateUser(user); }}
validate={{
required: { value: true, errorMessage: "Invalid number"},
pattern: { value: "^[\\+]?[0-9]{0,3}?[-\\s\\.]?[(]?[0-9]{3}[)]?[-\\s\\.]?[0-9]{3}[-\\s\\.]?[0-9]{4,6}$", errorMessage: "Invalid number" } }} />
required: { value: true, errorMessage: "Invalid number" },
pattern: { value: "^[\\+]?[0-9]{0,3}?[-\\s\\.]?[(]?[0-9]{3}[)]?[-\\s\\.]?[0-9]{3}[-\\s\\.]?[0-9]{4,6}$", errorMessage: "Invalid number" }
}} />
</Col>
<Col xs={(mobile) ? 12 : 4}>
<AvField name="dob"
Expand All @@ -135,7 +141,8 @@ class About extends Component {
end: {
value: "02/25/2005"
}
} }} />
}
}} />
</Col>
<Col xs={(mobile) ? 12 : 4}>
<CustomAVInput name="size"
Expand All @@ -157,7 +164,7 @@ class About extends Component {
<CustomAVInput name="gender"
label="Gender *"
value={user.gender}
validate={{ required: { value: true, errorMessage: "Invalid input"} }}>
validate={{ required: { value: true, errorMessage: "Invalid input" } }}>
<div className="forcestyle">
<Creatable id="gender"
value={{ value: user.gender, label: user.gender }}
Expand All @@ -180,6 +187,19 @@ class About extends Component {
</CustomAVInput>
</Col>
</FormGroup>
<FormGroup >
<CustomAVInput name="country_of_residence"
label="Country of Residence*"
value={user.country_of_residence}
validate={{ required: { value: true, errorMessage: "Invalid input" } }}>
<div className="forcestyle">
<Creatable id="country_of_residence"
value={{ value: user.country_of_residence, label: user.country_of_residence }}
onChange={(e) => { user.country_of_residence = e.value; this.updateUser(user); }}
options={countryList().getData()} />
</div>
</CustomAVInput>
</FormGroup>
<FormGroup>
<AvField name="hackathon_count"
label="How many hackathons have you attended? *"
Expand All @@ -189,14 +209,15 @@ class About extends Component {
onChange={(e) => { user.hackathon_count = e.target.value; this.updateUser(user); }}
validate={{
required: { value: true, errorMessage: "Invalid hackathon count" },
min: { value: 0, errorMessage: "Hackathon count must be non-negative" } }} />
min: { value: 0, errorMessage: "Hackathon count must be non-negative" }
}} />
</FormGroup>
{message}
<div style={{ width: "100%" }}
align="right">
<Button color="info"
className="pill-btn"
type="submit"> { this.state.loading ? <PulseLoader color={theme.accent[0]} /> : "Update" } </Button>
type="submit"> {this.state.loading ? <PulseLoader color={theme.accent[0]} /> : "Update"} </Button>
</div>
</AvForm>
);
Expand All @@ -205,7 +226,7 @@ class About extends Component {
color: theme.disabled[0], padding: 5, minHeight: 35
};
let field = (text) => {
return <p style={pStyle}>{(text) ? text : <i>unanswered</i> }</p>;
return <p style={pStyle}>{(text) ? text : <i>unanswered</i>}</p>;
};
return (
<div>
Expand Down Expand Up @@ -250,6 +271,10 @@ class About extends Component {
{field(user.ethnicity)}
</Col>
</FormGroup>
<FormGroup>
<Label>Country of Residence</Label>
{field(user.country_of_residence)}
</FormGroup>
<FormGroup>
<Label>How many hackathons have you attended?</Label>
{field(user.hackathon_count)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,7 @@ class Questions extends Component {
value={user.short_answer}
onChange={(e) => { user.short_answer = e.target.value; this.updateUser(user); }} />
</FormGroup>
<FormGroup>
<Label for="sa">What are your initial thoughts on a virtual hackathon?</Label>
<Input id="sa"
type="textarea"
placeholder=""
value={user.virtual_short_answer}
onChange={(e) => { user.virtual_short_answer = e.target.value; this.updateUser(user); }} />
</FormGroup>

<FormGroup>
<Label for="sn">Anything we should account for?</Label>
<Input id="sn"
Expand Down Expand Up @@ -196,10 +189,6 @@ class Questions extends Component {
<Label>What are you hoping to experience at HackRU?</Label>
{field(user.short_answer)}
</FormGroup>
<FormGroup>
<Label>What are your initial thoughts on a virtual hackathon?</Label>
{field(user.virtual_short_answer)}
</FormGroup>
<FormGroup>
<Label>Anything we should account for?</Label>
{field(user.special_needs)}
Expand Down

0 comments on commit d407f80

Please sign in to comment.