Skip to content

Commit

Permalink
[issue-#42-user-favorited-articles] setting up actions to handle fetc…
Browse files Browse the repository at this point in the history
…hing favorited articles
  • Loading branch information
crookse committed May 30, 2020
1 parent f65e09e commit 27b2b8c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions src/vue/components/ArticleList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default {
"articles_count",
"is_loading",
]),
listConfig() {
params() {
const { type } = this;
const filters = {
offset: (this.currentPage - 1) * this.itemsPerPage,
Expand Down Expand Up @@ -91,7 +91,7 @@ export default {
},
watch: {
currentPage(newValue) {
this.listConfig.filters.offset = (newValue - 1) * this.itemsPerPage;
this.params.filters.offset = (newValue - 1) * this.itemsPerPage;
this.fetchArticles();
},
type() {
Expand All @@ -116,10 +116,10 @@ export default {
},
methods: {
fetchArticles() {
this.$store.dispatch("fetchArticles", this.listConfig);
this.$store.dispatch("fetchArticles", this.params.filters);
},
resetPagination() {
this.listConfig.offset = 0;
this.params.offset = 0;
this.currentPage = 1;
}
}
Expand Down
62 changes: 31 additions & 31 deletions src/vue/routes/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,37 @@
</div>
</div>

<!-- <div class="container"> -->
<!-- <div class="row"> -->
<!-- <div class="col-xs-12 col-md-10 offset-md-1"> -->
<!-- <div class="articles-toggle"> -->
<!-- <ul class="nav nav-pills outline-active"> -->
<!-- <li class="nav-item"> -->
<!-- <router-link -->
<!-- class="nav-link" -->
<!-- active-class="active" -->
<!-- exact -->
<!-- :to="{ name: 'profile' }" -->
<!-- > -->
<!-- My Articles -->
<!-- </router-link> -->
<!-- </li> -->
<!-- <li class="nav-item"> -->
<!-- <router-link -->
<!-- class="nav-link" -->
<!-- active-class="active" -->
<!-- exact -->
<!-- :to="{ name: 'profile-favorites' }" -->
<!-- > -->
<!-- Favorited Articles -->
<!-- </router-link> -->
<!-- </li> -->
<!-- </ul> -->
<!-- </div> -->
<!-- <router-view></router-view> -->
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-10 offset-md-1">
<div class="articles-toggle">
<ul class="nav nav-pills outline-active">
<li class="nav-item">
<router-link
class="nav-link"
active-class="active"
exact
:to="{ name: 'profile' }"
>
My Articles
</router-link>
</li>
<li class="nav-item">
<router-link
class="nav-link"
active-class="active"
exact
:to="{ name: 'profile-favorites' }"
>
Favorited Articles
</router-link>
</li>
</ul>
</div>
<router-view></router-view>
</div>
</div>
</div>
</div>
</template>

Expand Down
4 changes: 2 additions & 2 deletions src/vue/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export default {
context.dispatch("unsetUser");
},

fetchArticles({ commit }, offset) {
fetchArticles({ commit }, params) {
return new Promise((resolve) => {
axios
.get("/articles", {
offset: offset
filters: params.filters,
})
.then(({ data }) => {
resolve(data)
Expand Down

0 comments on commit 27b2b8c

Please sign in to comment.