Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
IT2810-H19
Teams
Team 10
Prosjekt 4
Commits
427e1e4f
Commit
427e1e4f
authored
Nov 11, 2019
by
Hedda Mathilde Sæther Langvik
Browse files
Merge branch 'backend' into 'master'
Backend See merge request
!10
parents
189ff1c4
48104cb5
Changes
6
Hide whitespace changes
Inline
Side-by-side
frontend/actions/SetPageAction.js
View file @
427e1e4f
export
const
setPage
=
(
page
)
=>
{
return
(
dispatch
,
getState
)
=>
{
console
.
log
(
"
INNI ACTION med page:
"
,
page
)
//
console.log("INNI ACTION med page: ", page)
dispatch
({
type
:
'
SET_PAGE
'
,
page
...
...
frontend/api/fetchers.js
View file @
427e1e4f
import
Axios
from
"
axios
"
import
axios
from
"
axios
"
const
createURL
=
(
input
)
=>
{
const
API_URL
=
"
http://it2810-10.idi.ntnu.no:3001/api/
"
...
...
@@ -12,22 +9,19 @@ const createURL = (input) => {
return
API_URL
+
"
search/
"
+
input
}
if
(
typeof
input
==
'
number
'
){
return
API_URL
+
"
fiveMostPopular
"
}
}
export
const
GetData
=
(
input
)
=>
{
export
const
GetData
=
async
(
input
)
=>
{
const
url
=
createURL
(
input
)
console
.
log
(
"
Her er url:
"
,
url
)
return
Axios
.
get
(
url
);
return
await
axios
.
get
(
url
).
catch
((
err
)
=>
{
console
.
log
(
"
Error from axios:
"
,
err
)})
}
/*
const UpdatePopulatiry =(destinationID, newPopularity) => {
A
xios.post(
API_URL + "
updateData", {
export
const
UpdatePopulatiry
=
(
destinationID
,
newPopularity
)
=>
{
a
xios
.
post
(
"
http://it2810-10.idi.ntnu.no:3001/api/
updateData
"
,
{
id
:
destinationID
,
update
:
{
popularity
:
newPopularity
},
})
}
*/
\ No newline at end of file
assets/icon.png
→
frontend/
assets/icon.png
View file @
427e1e4f
File moved
assets/splash.png
→
frontend/
assets/splash.png
View file @
427e1e4f
File moved
frontend/components/Card.js
View file @
427e1e4f
import
React
,
{
Component
}
from
'
react
'
;
import
{
StyleSheet
,
Text
,
View
,
Alert
,
TouchableHighlight
,
Image
}
from
'
react-native
'
;
import
{
StyleSheet
,
Text
,
View
,
Alert
,
TouchableHighlight
,
Image
,
Dimensions
}
from
'
react-native
'
;
import
{
connect
}
from
'
react-redux
'
;
import
{
GetData
}
from
'
../api/fetchers
'
import
{
GetData
,
UpdatePopulatiry
}
from
'
../api/fetchers
'
import
{
ScrollView
}
from
'
react-native-gesture-handler
'
;
class
Card
extends
Component
{
state
=
{
data
:
[],
}
component
Did
Mount
(){
component
Will
Mount
(){
this
.
checkPage
()
}
setData
(
input
)
{
GetData
(
input
).
then
((
res
)
=>
this
.
setState
({
data
:
res
.
data
.
data
}))
}
checkPage
(){
if
(
this
.
props
.
page
===
"
Home
"
){
var
locations
=
GetData
(
5
)
locations
.
then
((
data
)
=>
{
console
.
log
(
data
);
this
.
setState
({
data
:
data
})})
this
.
setData
(
5
)
if
(
this
.
props
.
page
===
"
Explore
"
){
if
(
this
.
props
.
word
===
"
all
"
){
if
(
this
.
props
.
continent
===
'
all
'
){
this
.
setData
()
}
else
{
this
.
setData
(
this
.
props
.
continent
)}
}
else
if
(
this
.
props
.
continent
===
'
all
'
){
this
.
setData
(
this
.
props
.
word
)
}
else
{
this
.
setData
(
this
.
props
.
continent
+
"
/
"
+
this
.
props
.
word
)}
}
}
}
render
(){
const
styles
=
StyleSheet
.
create
({
container
:
{
borderRadius
:
7
,
...
...
@@ -35,32 +49,42 @@ class Card extends Component {
backgroundColor
:
'
white
'
,
margin
:
10
,
padding
:
10
,
alignItems
:
"
center
"
alignItems
:
"
center
"
,
height
:
250
,
},
Image
:
{
width
:
300
,
height
:
200
,
resizeMode
:
'
contain
'
,
alignSelf
:
"
center
"
}
})
const
{
data
}
=
this
.
state
console
.
log
(
data
)
const
dataCards
=
data
.
map
(
dat
=>
{
return
(
<
TouchableHighlight
key
=
{
dat
.
_id
}
underlayColor
=
'
white
'
onPress
=
{()
=>
Alert
.
alert
(
"
HEI
"
)}
>
<
View
style
=
{
styles
.
container
}
>
<
View
><
Image
style
=
{
styles
.
Image
}
source
=
{{
uri
:
dat
.
img
}}
/></
View
>
<
View
><
Text
>
{
dat
.
name
}
<
/Text></
View
>
<
/View
>
<
/TouchableHighlight
>
);
})
return
(
<
View
>
{
data
.
map
(
dat
=>
{
<
TouchableHighlight
underlayColor
=
'
transparent
'
onPress
=
{()
=>
Alert
.
alert
(
"
HEI
"
)}
>
<
View
style
=
{
styles
.
container
}
>
<
View
><
Image
source
=
{{
uri
:
dat
.
img
}}
/></
View
>
<
View
><
Text
>
{
dat
.
name
}
<
/Text></
View
>
<
/View
>
<
/TouchableHighlight
>
})}
<
/View
>
<
ScrollView
>
{
dataCards
}
<
/ScrollView
>
)}
}
}
const
mapStateToProps
=
(
state
)
=>
{
//give us accsess to the data in store
return
{
page
:
state
.
page
.
page
,
word
:
state
.
filter
.
searchWord
,
continent
:
state
.
filter
.
continent
}
};
...
...
frontend/pages/HomePage.js
View file @
427e1e4f
import
React
,
{
Component
}
from
'
react
'
;
import
{
Text
,
View
}
from
'
react-native
'
;
import
{
Text
,
View
,
ScrollView
}
from
'
react-native
'
;
import
Card
from
'
../components/Card
'
import
{
createStore
,
applyMiddleware
}
from
'
redux
'
;
import
rootReducer
from
'
../reducers/
'
;
...
...
@@ -18,15 +18,15 @@ class HomePage extends Component{
render
(){
return
(
<
View
style
=
{{
<
Scroll
View
style
=
{{
padding
:
36
,
flex
:
1
}}
>
<
Text
style
=
{{
fontSize
:
28
,
textAlign
:
"
center
"
,
padding
:
8
}}
>
Welcome
to
Dream
Destinations
<
/Text
>
<
Text
style
=
{{
fontSize
:
20
,
textAlign
:
"
center
"
,
padding
:
8
}}
>
Click
here
to
see
a
wordcloud
showing
the
most
popular
locations
<
/Text
>
<
Text
style
=
{{
fontSize
:
16
,
textAlign
:
"
center
"
,
padding
:
8
}}
>
Below
you
see
the
five
most
popular
places
<
/Text
>
<
Card
/>
<
/View
>
<
Card
/>
<
/
Scroll
View
>
/*
<Provider store = {store}>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment