Skip to content

Commit

Permalink
make add review #26
Browse files Browse the repository at this point in the history
  • Loading branch information
SajaLahaleeh committed Sep 11, 2019
2 parents ce97ab8 + cf0385b commit b61c0e1
Show file tree
Hide file tree
Showing 20 changed files with 584 additions and 105 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Hebron-must-see
[Hebron must see](https://hebron-must-see.herokuapp.com)

# Description
Our website is a tourist guide for Hebron. It provides some services for Hebron new visitors. These services include showing the must-see places in hebron and their ratings. in addition to provide them with a list of most famous tourist guides for hebron tours. Moreover, the tourist can see a list of most common used words in arabic and their pronounciation to help tourists to communicate in the places they go.
Expand Down
4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"react-dom": "^16.9.0",
"react-router-dom": "^5.0.1",
"react-scripts": "3.1.1",
"yup": "^0.27.0"
"yup": "^0.27.0",
"babel-eslint": "^9.0.0"
},
"scripts": {
"start": "react-scripts start",
Expand All @@ -35,7 +36,6 @@
},
"proxy": "http://localhost:4000",
"devDependencies": {
"babel-eslint": "^9.0.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.1",
"eslint-config-prettier": "^4.3.0",
Expand Down
4 changes: 0 additions & 4 deletions client/src/App.css
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
* {
margin: 0;
padding: 0;
}
6 changes: 4 additions & 2 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Home from './components/Home'
import Places from './components/Places'
import Guides from './components/Guides'
import OnePlace from './components/OnePlace'
import Signup from './components/SharedComponents/Signup'
import Login from './components/SharedComponents/Login'
import NavBar from './components/SharedComponents/navbar'
import arabicListWords from './components/arabicListWords'
Expand Down Expand Up @@ -53,11 +54,12 @@ class App extends Component {
render={props => (
<OnePlace
title={`Props through render`}
place={this.state.listOfPlaces[props.match.params.id]}
place={this.state.listOfPlaces[props.match.params.id - 1]}
/>
)}
/>
<Route exact path="/login" component={Login} />
<Route exact path="/signup" component={Signup} />
<Route exact path="/Login" component={Login} />
<Route
exact
path="/arabic-words"
Expand Down
54 changes: 54 additions & 0 deletions client/src/assets/speaker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 32 additions & 2 deletions client/src/components/OnePlace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,31 @@ import './style.css'

class OnePlace extends Component {
state = {
token: ''
token: '',
loggedIn: false,
review: ''
}

handelChange = event => {
const value = event.target.value
this.setState({ [event.target.name]: value })
}

addReview = () => {
axios.post('')
}

loginClick = () => {
this.props.history.push('/login')
axios
.get('/api/auth')
.catch(() => this.props.history.push('/login'))
.then(() => {
if (!this.state.loggedIn) {
this.setState({ loggedIn: true })
} else {
alert('feature is still in progress')
}
})
}

render() {
Expand All @@ -32,6 +52,16 @@ class OnePlace extends Component {
</div>
</div>
<div>
{this.state.loggedIn && (
<input
className="writeReview"
value={this.state.review}
placeholder="Write a review here please"
name="review"
onChange={this.handelChange}
onClick={this.addReview}
></input>
)}
<button className="addReview" onClick={this.loginClick}>
Add Review
</button>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/SharedComponents/Login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Login extends Component {
handleChange = event => {
const { value } = event.target
this.setState({ [event.target.name]: value })
console.log(this.state)
}

submit = event => {
Expand All @@ -22,14 +23,13 @@ class Login extends Component {
password
})
.then(res => {
console.log('the result', res)
if (res.data.status === 'failed') {
alert(res.data.message)
} else {
this.props.history.goBack()
}
})
.catch(err => console.log(err))
.catch(err => console.log(err.status))
}

render() {
Expand Down
205 changes: 205 additions & 0 deletions client/src/components/SharedComponents/Signup/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
import React, { Component } from 'react'
import './signup.css'
import axios from 'axios'

class Signup extends Component {
state = {
name: '',
email: '',
password: '',
confirmPassword: '',
displayBio: false,
type: '',
availability: '',
photo: '',
age: '',
description: '',
phone: '',
userType: 'user'
}
onChange = event => {
this.setState({
[event.target.name]: event.target.value
})
}

ShowDisplayBio = () => {
this.setState({ displayBio: true, userType: 'guide' })
}

displayShorterBio = () => {
this.setState({ displayBio: false })
}

validatePassword = () => {
return (
this.state.password.length > 6 &&
this.state.password === this.state.confirmPassword
)
}

pressButton = event => {
const {
email,
name,
password,
type,
availability,
photo,
age,
phone,
description,
userType
} = this.state
axios
.post('/api/signup', {
name,
email,
password,
type,
photo,
description,
availability,
phone,
age,
userType
})
.then(result => console.log(result.data, 'ax'))
}

render() {
return (
<>
<h1>Signup</h1>

<form>
<input
type="text"
name="name"
onChange={this.onChange}
placeholder="Name..."
value={this.state.name}
required
/>

<input
type="email"
name="email"
onChange={this.onChange}
placeholder="Email..."
value={this.state.email}
required
/>

<input
type="password"
name="password"
onChange={this.onChange}
placeholder="Password..."
value={this.state.password}
required
/>

<input
type="password"
name="confirmPassword"
onChange={this.onChange}
placeholder="Confirm your password..."
value={this.state.confirmPassword}
required
/>
{!this.validatePassword() ? (
<div>
<p className="validate">
{' '}
your password must be than 7 character an be same of your
confirm password
</p>
</div>
) : (
<div>
<p className="TrueValidate">
{' '}
your password equal confirm password
</p>
</div>
)}

<div className="container">
<fieldset>
<p>If you signup as a guide</p>
<p> please press guide button and fill the other section</p>
<button onClick={this.ShowDisplayBio}>Guide</button>
<button onClick={this.displayShorterBio}>Tourist</button>
</fieldset>
</div>

{this.state.displayBio ? (
<div className="extra">
<input
type="text"
name="type"
onChange={this.onChange}
value={this.state.type}
placeholder="Language..."
required
/>

<input
type="text"
name="photo"
onChange={this.onChange}
value={this.state.photo}
placeholder="Add your photo..."
required
/>

<input
type="text"
name="description"
onChange={this.onChange}
value={this.state.description}
placeholder="Description about yourself..."
required
/>

<input
type="text"
name="availability"
onChange={this.onChange}
value={this.state.availability}
placeholder="Availability time..."
required
/>
<input
type="text"
name="phone"
onChange={this.onChange}
value={this.state.phone}
placeholder="Phone number..."
required
/>

<input
type="text"
name="age"
onChange={this.onChange}
value={this.state.age}
placeholder="Age..."
required
/>
</div>
) : (
<div></div>
)}
<br />
<button className="signup" type="submit" onClick={this.pressButton}>
Signup
</button>
</form>
</>
)
}
}

export default Signup
Loading

0 comments on commit b61c0e1

Please sign in to comment.