Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reset form button #36

Merged
merged 1 commit into from
Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions modules/main/components/CheckBox/CheckBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class Checkbox extends PureComponent {
)
}

handleToggleChecked = () => {
handleToggleChecked = () => {
const { label } = this.props
const categoryArr = this.props.categoryArr
const checked = this.state.checked;
Expand All @@ -89,20 +89,18 @@ export default class Checkbox extends PureComponent {
const catArr = this.state.categories
const categories = categoryArr[i];
this.setState({categories})
console.log(this.state, 'line 101 checkbox')
}
});

return this.state
}

else if (checked===true) {
let categories = this.state.categories;
let categories = this.state.categories;
this.setState({categories: categories.label});
this.setState({ checked: false});
this.setState({label: ''})
this.setState({label: ''})
return this.state
console.log(this.state, 'line 125 checkbox')
}
}
}
Expand Down
34 changes: 10 additions & 24 deletions modules/main/components/DecisionSection/DecisionSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class DecisionSection extends Component{
// this.setState({counter: this.props.counter});
// console.log(this.props.counter);
// }

componentDidMount(){
this.handleRandomizeButton()
// const counter = this.props.counter
Expand All @@ -41,18 +41,9 @@ export default class DecisionSection extends Component{
}


handleSwipeRight(){
Alert.alert(
"You are Buridian's Ass!!!",
'Pay $1,000,000 to unlock feature',
[
{text: 'I am sorry', onPress: () => console.log('Ask me later pressed')},
{text: 'I Know', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
// {text: 'OK', onPress: () => console.log('OK Pressed')},
],
{ cancelable: false }
)
// alert("You are Buridian's Ass\n Pay $1,000,000")
handleSwipeRight = () => {
Alert.alert("Enjoy your meal");
Linking.openURL(this.state.fourSquarePage).catch(err => console.error('An error occurred', err));
}


Expand All @@ -63,7 +54,7 @@ export default class DecisionSection extends Component{
})
console.log(categories, 'map category')

if(counter > 0){
if(counter > 0){
// console.log(this.props.categoryObj[0].categoryID, this.props.location)
API.getRestaurant(categories.join(), this.props.location)
.then((response)=> response.json())
Expand All @@ -87,17 +78,12 @@ export default class DecisionSection extends Component{
this.handlePhoto();

})

// console.log('line 68 ===================', this.state, 'end ==========')
// console.log(this.props);
// alert('fuck dude')
// let counter = this.state.counter
// this.setState({counter: counter --});

counter --
}
else{
Alert.alert(
"Go on Yelp",
"Just go to Yelp",
"You're defeating the purpose of the App!",
[
// {text: 'I am sorry', onPress: () => console.log('Ask me later pressed')},
Expand All @@ -122,7 +108,7 @@ export default class DecisionSection extends Component{
// console.log("responseJson: " + responseJson.response.photos.items[0]);
const photoObject = responseJson.response.photos.items[0];
let imageUrl = photoObject.prefix + '300x500' + photoObject.suffix;

// responseJson.response.photos.items[0] ? this.setState({imageUrl}) : this.setState({imageUrl: 'http://lorempicsum.com/futurama/350/200/1'})
this.setState({imageUrl: imageUrl === '' || imageUrl === this.state.imageUrl || imageUrl===undefined ? 'http://lorempicsum.com/futurama/350/200/1' : imageUrl})
})
Expand All @@ -147,9 +133,9 @@ export default class DecisionSection extends Component{
<Container>
<View style={styles.image}>
<DeckSwiper
dataSource={[this.state]}
dataSource={[this.state]}
onSwipeLeft={this.handleRandomizeButton}
onSwipeRight={this.handleSwipeRight}
onSwipeRight={this.handleSwipeRight}
renderItem={item =>
<Card style={{ elevation: 3 }} style={{justifyContent: 'center', alignItems: 'center'}}>
<CardItem style={{justifyContent: 'center', alignItems: 'center'}}
Expand Down
15 changes: 8 additions & 7 deletions modules/main/components/Picker/Picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import API from '../../../../Utils/API'
import {Actions} from 'react-native-router-flux';
import Checkbox from "../CheckBox/CheckBox";


const categories = [
{
"id": 1,
Expand Down Expand Up @@ -117,14 +118,16 @@ export default class PickerExample extends Component {
}

handleResetForm = event => {
Actions.Main();
this.setState({location: ""});
this.setState({numOptions: 1 });
this.setState({counter: 1});
Actions.refresh();
}

handleFormSubmit = event => {
event.preventDefault();
console.log("Submit button pressed"); console.log(this.state.numOptions);
// console.log(this.state.numOptions);
// console.log(this.state.location);

if(this.state.location.trim() === ''){
alert('Location is a required field')
}
Expand All @@ -137,8 +140,6 @@ export default class PickerExample extends Component {
});
}

// this.props.API('4bf58dd8d48988d10f941735', 'Fairfax')

};

onAddCategory = obj =>{
Expand Down Expand Up @@ -239,12 +240,12 @@ export default class PickerExample extends Component {
Submit
</Text>
</Button>
{/*<Button style={{backgroundColor: 'lightgrey'}}
<Button style={{backgroundColor: 'lightgrey'}}
onPress={this.handleResetForm}>
<Text style={{color: 'black'}}>
Reset Form
</Text>
</Button>*/}
</Button>
</FormItem>
</ScrollView>
</Form>
Expand Down
1 change: 0 additions & 1 deletion modules/main/scenes/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Home extends React.Component {
restaurantId: '',
fourSquarePage: "",
numOptions: "",
asian: false
}

componentDidMount(){
Expand Down