Changeset 7944fab for client_app
- Timestamp:
- 01/13/21 03:56:56 (4 years ago)
- Branches:
- master
- Children:
- df3a395
- Parents:
- 19ad843
- Location:
- client_app/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
client_app/src/components/login/login.js
r19ad843 r7944fab 29 29 return( 30 30 <Container> 31 <h1 style={{color: "green"}}>{props.success}</h1> 31 32 <h1 style={{color: "red"}}>{props.error}</h1> 32 33 <Form onSubmit={onFormSubmit}> -
client_app/src/components/main/App.js
r19ad843 r7944fab 42 42 <Route path={"/company/jobs"} render={() => <CompanyJobs userProfile={this.state.currentUser}/>}/> 43 43 <Route path={"/company/internships"} render={() => <CompanyInternships userProfile={this.state.currentUser}/>}/> 44 <Route path={"/register/user"} render={() => <RegisterUser error={null} />}/>44 <Route path={"/register/user"} render={() => <RegisterUser error={null} success={null}/>}/> 45 45 <Route path={"/logout"} render={() => <Redirect to={"/login"}/>}/> 46 46 <Route path={"/"} render={() => <Redirect to={"/login"}/>}/> -
client_app/src/components/register/register_user_form.js
r19ad843 r7944fab 1 1 import React from 'react'; 2 2 import 'semantic-ui-react'; 3 import {Button, Container, Form} from "semantic-ui-react";3 import {Button, Container, Dropdown, Form, Label} from "semantic-ui-react"; 4 4 import { Redirect } from 'react-router-dom'; 5 5 import SkillFetch from "../../repository/skill_repo"; … … 18 18 retainedSkills: [], 19 19 skillsToLearn: [], 20 allSkills: [], 21 error: props.error 20 error: props.error, 21 success: props.success, 22 sortedOptions:[] 22 23 } 24 this.attemptRegister = this.attemptRegister.bind(this); 23 25 } 24 26 … … 30 32 } 31 33 34 setKnown = (e, {value}) =>{ 35 this.setState({ 36 retainedSkills: value 37 }) 38 } 39 40 setToKnow = (e, {value}) =>{ 41 this.setState({ 42 skillsToLearn: value 43 }) 44 } 45 46 attemptRegister(){ 47 UserRegister.userRegister( 48 this.state.email, 49 this.state.password, 50 this.state.name, 51 this.state.surname, 52 this.state.retainedSkills, 53 this.state.skillsToLearn 54 ).then(res => { 55 if(res.data.success!=null){ 56 this.setState({ 57 success: res.data.success, 58 error: null 59 }) 60 }else{ 61 this.setState({ 62 error: res.data.error, 63 success: null 64 }) 65 } 66 }).catch(err => { 67 this.setState({ 68 error: "User already exists!", 69 success: null 70 }) 71 }); 72 } 73 32 74 render() { 75 console.log(this.state.success); 76 77 if(this.state.success!=null){ 78 return( 79 <Redirect to={"/login"} success={this.state.success}/> 80 ); 81 } 82 33 83 return ( 34 84 <Container> … … 43 93 <Form.Input id="surname" name="surname" type='text' required fluid label='Surname' 44 94 placeholder='Enter surname.' onChange={this.handleCheck}/> 45 < label>Skills you know:</label>46 < select multiple="" class="ui dropdown">47 {this.state.allSkills.map(item => {48 return <option value={item.id}>{item.name}</option>49 })}50 < /select>95 <Label>Select skills you know:</Label> 96 <Dropdown placeholder="Skills you know..." fluid multiple selection options={this.state.sortedOptions} onChange={this.setKnown}/> 97 <br/> 98 <Label>Select skills you want to know:</Label> 99 <Dropdown placeholder="Skills you want to learn..." fluid multiple selection options={this.state.sortedOptions} onChange={this.setToKnow}/> 100 <br/> 51 101 <Button type="submit">Register</Button> 52 102 </Form> … … 57 107 componentDidMount(){ 58 108 SkillFetch.fetchAll().then((data) =>{ 109 var sorted = []; 110 data.data.forEach(item => { 111 var obj = { 112 key: item.id, 113 text: item.name, 114 value: item.id 115 } 116 sorted.push(obj); 117 }); 118 59 119 this.setState({ 60 allSkills: data.data120 sortedOptions: sorted 61 121 }) 62 })63 }64 65 attemptRegister(){66 UserRegister.userRegister(67 this.state.email,68 this.state.password,69 this.state.name,70 this.state.surname,71 this.state.retainedSkills,72 this.state.skillsToLearn73 ).then(data => {74 if(data.success){75 return <Redirect to={"/login"}/>76 }else{77 return <Redirect to={"/user/register"} error={data.error}/>78 }79 122 }) 80 123 } -
client_app/src/repository/register_repo.js
r19ad843 r7944fab 2 2 3 3 const UserRegister = { 4 userRegister: (email, password, name, surname, skillsRetained, skillsToLearn) => {4 userRegister: (email, password, name, surname, retainedSkills, skillsToLearn) => { 5 5 return axios.post("/register/user", { 6 6 "email": email, … … 8 8 "name": name, 9 9 "surname": surname, 10 " skillsRetained": skillsRetained,10 "retainedSkills": retainedSkills, 11 11 "skillsToLearn": skillsToLearn 12 12 });
Note:
See TracChangeset
for help on using the changeset viewer.