Commit 9f1d944
Changed files (6)
app
components
infrastructure
queries
screens
app/components/movies.js
@@ -45,7 +45,6 @@ export default class Movies extends Component {
}
mapAll(movies) {
- movies.forEach((item) => console.log(item))
return this.ds.cloneWithRows(movies.map((item) => item.title));
}
app/infrastructure/api.js
@@ -13,22 +13,32 @@ export default class Api {
get(success) {
this.defaultHeaders((headers) => {
+ console.log(`GET ${this.url}`);
fetch(this.url, { method: 'GET', headers: headers })
.then((response) => response.json())
- .then(success)
+ .then((json) => {
+ console.dir(json);
+ success(json);
+ })
.catch((error) => console.error(error))
.done();
});
}
post(body, success) {
+ const jsonBody = JSON.stringify(body);
+ console.log(`POST ${this.url}`);
+ console.dir(jsonBody)
fetch(this.url, {
method: "POST",
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' },
- body: JSON.stringify(body)
+ body: jsonBody
})
.then((response) => response.json())
- .then(success)
+ .then((json) => {
+ console.dir(json);
+ success(json);
+ })
.catch((error) => console.error(error))
.done();
}
@@ -37,7 +47,6 @@ export default class Api {
this.storage
.fetch('authentication_token')
.then((token) => {
- console.dir(token);
success({
'Accept': 'application/json',
'Content-Type': 'application/json',
app/infrastructure/event-aggregator.js
@@ -8,7 +8,12 @@ export default class EventAggregator {
}
publish(event) {
- this._subscriptionsFor(event.event).forEach(x => x.notify(event));
+ this._subscriptionsFor(event.event).forEach((x) => {
+ console.log("publishing:");
+ console.dir(event);
+ console.dir(x);
+ x.notify(event);
+ });
}
unsubscribe(subscriber) {
app/queries/fetch-workouts.js
@@ -11,7 +11,6 @@ export default class FetchWorkouts {
}
onResponse(json) {
- console.dir(json)
this.eventAggregator.publish({
event: 'FETCHED_WORKOUTS',
workouts: json.workouts || []
app/screens/dashboard-screen.js
@@ -14,7 +14,6 @@ export default class DashboardScreen extends ApplicationComponent {
}
render() {
- console.log("LOADING DASHBOARD");
return (
<View>
<Text>Welcome back {this.props.username}!</Text>
@@ -35,7 +34,6 @@ export default class DashboardScreen extends ApplicationComponent {
}
notify(event) {
- console.dir(event);
switch(event.event) {
case "FETCHED_WORKOUTS":
this.setState({ dataSource: this.mapAll(event.workouts) });
@@ -47,11 +45,10 @@ export default class DashboardScreen extends ApplicationComponent {
}
onStartWorkout() {
- console.log("load previous workouts");
+ console.log("start workout");
}
onLogout() {
- console.log("logout");
let storage = new ApplicationStorage();
storage.delete('authentication_token');
storage.delete('username');
@@ -59,7 +56,6 @@ export default class DashboardScreen extends ApplicationComponent {
}
mapAll(workouts) {
- workouts.forEach((item) => console.log(item))
- return this.ds.cloneWithRows(workouts.map((item) => item.title));
+ return this.ds.cloneWithRows(workouts.map((item) => item.routine_name));
}
}
app/screens/login-screen.js
@@ -42,7 +42,6 @@ export default class LoginScreen extends ApplicationComponent {
onLogin() {
let account = this.refs.form.getValue();
- //this.props.login(account.username, account.password);
this.publish({
event: 'LOGIN',
username: account.username,
@@ -55,7 +54,6 @@ export default class LoginScreen extends ApplicationComponent {
}
notify(event) {
- console.dir(event);
this.props.navigator.push({
component: DashboardScreen, params: { username: event.username }
});