Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
ThaliApp
Commits
a4793f5b
Commit
a4793f5b
authored
May 24, 2017
by
wkuipers
Committed by
Wietse Kuipers
May 24, 2017
Browse files
Added url.js and refactored actions to use it
parent
3975f50f
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/actions/calendar.js
View file @
a4793f5b
import
*
as
types
from
'
./actionTypes
'
;
import
{
url
}
from
'
../url
'
;
export
function
calendarRetrieved
(
eventList
)
{
return
{
...
...
@@ -27,7 +28,7 @@ export function retrieveCalendar(token) {
Authorization
:
`Token
${
token
}
`
,
},
};
return
fetch
(
`
http://localhost:8000
/api/events/eventlist/?start=
${
start
}
&end=
${
end
}
`
,
data
)
return
fetch
(
`
${
url
}
/api/events/eventlist/?start=
${
start
}
&end=
${
end
}
`
,
data
)
.
then
(
response
=>
response
.
json
())
.
then
(
...
...
app/actions/events.js
View file @
a4793f5b
import
*
as
types
from
'
./actionTypes
'
;
import
{
navigate
}
from
'
./navigation
'
;
import
{
url
}
from
'
../url
'
;
export
function
success
(
data
)
{
return
{
...
...
@@ -24,7 +25,7 @@ export function loadEvent(id, token) {
Authorization
:
`Token
${
token
}
`
,
},
};
return
fetch
(
`
http://localhost:8000
/api/events/data/?event_id=
${
id
}
`
,
data
)
return
fetch
(
`
${
url
}
/api/events/data/?event_id=
${
id
}
`
,
data
)
.
then
(
response
=>
response
.
json
(),
)
...
...
app/actions/login.js
View file @
a4793f5b
import
{
AsyncStorage
}
from
'
react-native
'
;
import
*
as
types
from
'
./actionTypes
'
;
import
{
url
}
from
'
../url
'
;
const
USERNAMEKEY
=
'
@MyStore:username
'
;
const
TOKENKEY
=
'
@MyStore:token
'
;
const
DISPLAYNAMEKEY
=
'
@MyStore:displayName
'
;
const
PHOTOKEY
=
'
@MyStore:photo
'
;
const
defaultAvatar
=
'
http://localhost:8000/static/members/images/default-avatar.jpg
'
;
const
defaultAvatar
=
`
${
url
}
/static/members/images/default-avatar.jpg`
;
export
function
loginSuccess
(
username
,
token
,
displayName
,
photo
)
{
return
{
...
...
@@ -43,7 +45,7 @@ function getUserInfo(token) {
},
};
return
fetch
(
'
http://localhost:8000
/api/members/info/
'
,
data
)
return
fetch
(
`
${
url
}
/api/members/info/
`
,
data
)
.
then
(
response
=>
response
.
json
())
.
then
(
...
...
@@ -77,7 +79,7 @@ export function login(user, pass) {
password
:
pass
,
}),
};
return
fetch
(
'
http://localhost:8000
/api/token-auth/
'
,
data
)
return
fetch
(
`
${
url
}
/api/token-auth/
`
,
data
)
.
then
(
response
=>
response
.
json
())
.
then
(
...
...
app/url.js
0 → 100644
View file @
a4793f5b
let
server
=
'
https://thalia.nu
'
;
if
(
__DEV__
)
{
// eslint-disable-line no-undef
server
=
'
http://localhost:8000
'
;
}
export
const
url
=
server
;
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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