From d407f8087f406b089533eb137e9118bac21bd2c3 Mon Sep 17 00:00:00 2001 From: avsomers25 <67980093+avsomers25@users.noreply.github.com> Date: Wed, 4 Oct 2023 01:01:26 -0400 Subject: [PATCH] 587 changes to the form section (#593) * removed question about virtual hackathons * frontend country of residence * fixing lint errors --- package.json | 1 + .../UserProfileForm/ProfileCards/About.jsx | 47 ++++++++++++++----- .../ProfileCards/Questions.jsx | 13 +---- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index ecc04c31..43d98ed8 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/Dashboard/Forms/UserProfileForm/ProfileCards/About.jsx b/src/components/Dashboard/Forms/UserProfileForm/ProfileCards/About.jsx index e2da9103..837fdf11 100644 --- a/src/components/Dashboard/Forms/UserProfileForm/ProfileCards/About.jsx +++ b/src/components/Dashboard/Forms/UserProfileForm/ProfileCards/About.jsx @@ -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); // } @@ -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({ @@ -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" } + }} /> + maxLength: { value: 100, errorMessage: "Invalid length" } + }} /> @@ -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" } + }} /> + } + }} /> + validate={{ required: { value: true, errorMessage: "Invalid input" } }}>
+ + +
+ { user.country_of_residence = e.value; this.updateUser(user); }} + options={countryList().getData()} /> +
+
+
{ 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" } + }} /> {message}
+ type="submit"> {this.state.loading ? : "Update"}
); @@ -205,7 +226,7 @@ class About extends Component { color: theme.disabled[0], padding: 5, minHeight: 35 }; let field = (text) => { - return

{(text) ? text : unanswered }

; + return

{(text) ? text : unanswered}

; }; return (
@@ -250,6 +271,10 @@ class About extends Component { {field(user.ethnicity)} + + + {field(user.country_of_residence)} + {field(user.hackathon_count)} diff --git a/src/components/Dashboard/Forms/UserProfileForm/ProfileCards/Questions.jsx b/src/components/Dashboard/Forms/UserProfileForm/ProfileCards/Questions.jsx index 8b9bd7e1..17618017 100644 --- a/src/components/Dashboard/Forms/UserProfileForm/ProfileCards/Questions.jsx +++ b/src/components/Dashboard/Forms/UserProfileForm/ProfileCards/Questions.jsx @@ -123,14 +123,7 @@ class Questions extends Component { value={user.short_answer} onChange={(e) => { user.short_answer = e.target.value; this.updateUser(user); }} /> - - - { user.virtual_short_answer = e.target.value; this.updateUser(user); }} /> - + What are you hoping to experience at HackRU? {field(user.short_answer)} - - - {field(user.virtual_short_answer)} - {field(user.special_needs)}