As part of NTNU's increased focus on security, all users are now forced to enable and use Two-factor authentication.

Commit 4cf3cbf1 authored by Amalie Henni's avatar Amalie Henni
Browse files

'reset auther' -m

parents 953cf4eb 456ea9fa
<<<<<<< HEAD
export const changeSelected = (index, menuName) => {
return (dispatch, getState) => {
dispatch({
type: "CHANGE_SELECTED",
index,
menuName
=======
export const changeSelected = (menuName, index) => {
return (dispatch, getState) => {
console.log("inni CHANGE_SELECTED-----------------------");
dispatch({
type: "CHANGE_SELECTED",
action: {
menuName,
index
}
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
});
};
};
<<<<<<< HEAD
import axios from "axios";
=======
import Axios from "axios";
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
const createURL = input => {
const API_URL = "http://it2810-10.idi.ntnu.no:3001/api/";
......@@ -13,6 +17,7 @@ const createURL = input => {
}
};
<<<<<<< HEAD
export const GetData = async input => {
const url = createURL(input);
return await axios.get(url).catch(err => {
......@@ -26,3 +31,19 @@ export const UpdatePopulatiry = (destinationID, newPopularity) => {
update: { popularity: newPopularity }
});
};
=======
export const GetData = input => {
const url = createURL(input);
console.log("Her er url: ", url);
return Axios.get(url);
};
/*
const UpdatePopulatiry =(destinationID, newPopularity) => {
Axios.post(API_URL + "updateData", {
id: destinationID,
update: { popularity: newPopularity },
})
}
*/
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
......@@ -5,17 +5,25 @@ import {
View,
Alert,
TouchableHighlight,
<<<<<<< HEAD
Image,
Dimensions
} from "react-native";
import { connect } from "react-redux";
import { GetData, UpdatePopulatiry } from "../api/fetchers";
import { ScrollView } from "react-native-gesture-handler";
=======
Image
} from "react-native";
import { connect } from "react-redux";
import { GetData } from "../api/fetchers";
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
class Card extends Component {
state = {
data: []
};
<<<<<<< HEAD
componentWillMount() {
this.checkPage();
......@@ -23,10 +31,16 @@ class Card extends Component {
setData(input) {
GetData(input).then(res => this.setState({ data: res.data.data }));
=======
componentDidMount() {
this.checkPage();
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
}
checkPage() {
if (this.props.page === "Home") {
<<<<<<< HEAD
this.setData(5);
if (this.props.page === "Explore") {
if (this.props.word === "all") {
......@@ -41,6 +55,12 @@ class Card extends Component {
this.setData(this.props.continent + "/" + this.props.word);
}
}
=======
var locations = GetData(5);
locations.then(data => {
this.setState({ data: data });
});
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
}
}
......@@ -57,6 +77,7 @@ class Card extends Component {
backgroundColor: "white",
margin: 10,
padding: 10,
<<<<<<< HEAD
alignItems: "center",
height: 250
},
......@@ -87,6 +108,14 @@ class Card extends Component {
);
});
return <ScrollView>{dataCards}</ScrollView>;
=======
alignItems: "center"
}
});
const { data } = this.state;
return <View></View>;
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
}
}
......@@ -94,9 +123,13 @@ const mapStateToProps = state => {
//give us accsess to the data in store
return {
<<<<<<< HEAD
page: state.page.page,
word: state.filter.searchWord,
continent: state.filter.continent
=======
page: state.page.page
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
};
};
......
......@@ -8,11 +8,21 @@ class Dropdown extends React.PureComponent {
_menu = null;
setMenuRef = ref => {
<<<<<<< HEAD
=======
// console.log("This is ref::::: ", ref.state);
// ref.show();
// console.log("This is hide::::: ", ref.state);
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
this._menu = ref;
};
changeMenu = index => {
this.props.changeSelected(index, this.props.dropName);
<<<<<<< HEAD
=======
console.log("CHANGE_SELECTED");
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
this.hideMenu();
};
......@@ -26,6 +36,10 @@ class Dropdown extends React.PureComponent {
getUnselectedOptions = () => {
const selected = this.props.selected;
<<<<<<< HEAD
=======
console.log(selected);
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
const new_options = this.props.options.filter(function(v, i) {
return i !== selected;
});
......@@ -33,6 +47,7 @@ class Dropdown extends React.PureComponent {
};
render() {
<<<<<<< HEAD
const items = this.getUnselectedOptions().map((opt, i) => (
<MenuItem key={i} onPress={() => this.changeMenu(i + 1)} disable={false}>
{opt}
......@@ -44,10 +59,30 @@ class Dropdown extends React.PureComponent {
onPress={() => this.changeMenu(i)}
disable={parseInt(this.props.selected) === parseInt(i)}
>
=======
console.log("los returnos -----", this.getUnselectedOptions());
const items = this.getUnselectedOptions().map((opt, i) => (
<MenuItem key={i} onPress={i => this.changeMenu(i)}>
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
{opt}
</MenuItem>
));
return (
<<<<<<< HEAD
=======
// <View accessibilityRole="header">
// <Text> Header </Text>
// <View accessibilityRole="menu">
// <View accessibilityRole="menuitem">
// <Text> YI </Text>
// <Text> YI </Text>
// <Text> YI </Text>
// <Text> YI </Text>
// </View>
// </View>
// </View>
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Menu
ref={this.setMenuRef}
......@@ -55,11 +90,35 @@ class Dropdown extends React.PureComponent {
<Text onPress={this.showMenu}>Show {this.props.dropName}</Text>
}
>
<<<<<<< HEAD
{menuItems}
=======
<MenuItem
key={this.props.selected}
onPress={() => this.changeMenu(this.props.selected)}
>
{this.props.options[this.props.selected]}
</MenuItem>
<MenuDivider />
{items}
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
</Menu>
</View>
);
}
}
<<<<<<< HEAD
export default Dropdown;
=======
const mapDispatchToProps = dispatch => {
return {
changeSelected
};
};
export default connect(
null,
mapDispatchToProps
)(Dropdown);
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
......@@ -18,6 +18,7 @@ class SearchBox extends Component {
};
}
<<<<<<< HEAD
search = () => {
Keyboard.dismiss();
if (this.state.searchWord.length === 0) {
......@@ -25,6 +26,22 @@ class SearchBox extends Component {
word = "all";
} else {
word = this.state.searchWord;
=======
constructor(props){
super(props)
this.state = {
searchWord: ""
}
}
search = () => {
if (this.state.searchWord.length === 0){ //search blank, show all places
word = "all"
} else {
word = this.state.searchWord
}
this.props.changeSearchword(word.toLowerCase())
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
}
this.props.changeSearchword(word.toLowerCase());
};
......@@ -42,6 +59,7 @@ class SearchBox extends Component {
console.log(word);
};
<<<<<<< HEAD
render() {
this.search = this.search.bind(this);
this.handleSearchWord = this.handleSearchWord.bind(this);
......@@ -67,12 +85,43 @@ class SearchBox extends Component {
</View>
);
}
=======
render(){
this.search = this.search.bind(this)
this.handleSearchWord = this.handleSearchWord.bind(this)
const inputfield = {
backgroundColor: '#EEEEEE',
borderRadius: 10,
padding: 3,
flex: 1
}
return(
<View style = {{flexDirection: "row", margin: 20}}>
<TextInput
style = {inputfield}
autoCorrect = {false}
onKeyPress = {(e) => this.handleSearchWord(e)}
onSubmitEditing = {() => this.search()}
/>
<Icon
name = "search"
onPress = {() => this.search()}
/>
<Text>
{this.props.word}
</Text>
</View>
);
}
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
}
const mapDispatchToProps = dispatch => {
return {
changeSearchword: word => dispatch(changeSearchword(word))
};
<<<<<<< HEAD
};
const mapStateToProps = state => {
......@@ -87,3 +136,15 @@ export default connect(
mapStateToProps,
mapDispatchToProps
)(SearchBox);
=======
const mapStateToProps = (state) => { //give us accsess to the data in store
const filter = state.filter
return {
word: filter.searchWord
}
}
export default connect(mapStateToProps, mapDispatchToProps)(SearchBox);
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
import React, { Component } from 'react';
class SimpleDropdown extends Component {
render() {
return (
// <View accessibilityRole="header">
// <Text> Header </Text>
// <View accessibilityRole="menu">
// <View accessibilityRole="menuitem">
// <Text> YI </Text>
// <Text> YI </Text>
// <Text> YI </Text>
// <Text> YI </Text>
// </View>
// </View>
// </View>
);
}
}
export default SimpleDropdown;
......@@ -37,9 +37,17 @@ class SortBy extends React.PureComponent {
button={<Text onPress={this.showMenu}>Show menu</Text>}
>
<MenuItem onPress={this.hideMenu}>Menu item 1</MenuItem>
<<<<<<< HEAD
<MenuItem onPress={this.hideMenu} disabled>
Menu item 3
</MenuItem>
=======
<MenuItem onPress={this.hideMenu}>Menu item 2</MenuItem>
<MenuItem onPress={this.hideMenu} disabled>
Menu item 3
</MenuItem>
<MenuItem onPress={this.hideMenu}>Menu item 4</MenuItem>
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
</Menu>
</View>
</View>
......
......@@ -21,7 +21,6 @@ class ExplorePage extends Component {
dropName={this.props.dropdowns[0].menuName}
options={this.props.dropdowns[0].options}
changeSelected={this.props.changeSelected}
/>
<Text>hvorfor kommer ikke dropdown?</Text>
</View>
......
......@@ -2,7 +2,11 @@ const initState = [
{
index: 0,
menuName: "sort_by",
<<<<<<< HEAD
options: ["None", "Popularity", "A - Z"]
=======
options: ["Popularity", "A - Z"]
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
},
{
index: 2,
......@@ -13,6 +17,7 @@ const initState = [
const dropdownReducer = (state = initState, action) => {
const getMenuIndexByName = menuName =>
<<<<<<< HEAD
state.findIndex(menuItem => menuItem.menuName == menuName);
switch (action.type) {
case "CHANGE_SELECTED":
......@@ -20,6 +25,18 @@ const dropdownReducer = (state = initState, action) => {
state[getMenuIndexByName(action.menuName)].index = action.index;
return state;
=======
state.dropdowns.findIndex(menuItem => menuItem.menuName == menuName);
switch (action.type) {
case "CHANGE_SELECTED":
const dropdowns = state.dropdowns;
dropdowns[getMenuIndexByName(action.menuName)].index = action.index;
return {
...state,
dropdowns
};
>>>>>>> 456ea9fab033cf4a499117c9068a2ab9a90e3ac8
default:
return state;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment