Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const routes = [
meta: { layout: 'HomeLayout' },
},
{
path: '/communities/:communitySlug',
path: '/communities/:slug',
name: 'CommunityDetail',
component: () => import('../views/home/CommunityDetail.vue'),
meta: { layout: 'HomeLayout' },
Expand Down
43 changes: 36 additions & 7 deletions src/views/home/CommunityDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,38 @@
<button type="button" class="new btn btn-link" @click="newDiscussion">
Create a Discussion</button>
<hr />
<a href="">POSTS</a><br />
<a href="">POSTS</a><br />
<a href="">POSTS</a><br />
<a href="">POSTS</a><br />
<a href="">POSTS</a><br />
<a href="">POSTS</a><br />
</div>
</div>
</div>
</div>
<div class="row">
<table class="table col-12 col-md-12" style=" margin:auto;">
<thead>
<tr>
<th scope="col"> Header </th>
<th scope="col"> Text </th>
<th scope="col"> Create Date </th>
</tr>
</thead>
<tbody>
<tr v-for="discussion in discussions" :key="discussion.id">
<td ><a :href="'http://localhost:8080/communities/'+discussion.communities.slug+'/'+discussion.slug">
{{discussion.header}}</a></td>
<td> {{ discussion.text }} </td>
<td >{{discussion.createdAt.slice(0, 10)+" " +
discussion.createdAt.slice(11, 19)}}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>

<script>
import axios from 'axios';

export default {
name: 'CommunityDetail',
components: {},
Expand All @@ -129,8 +146,20 @@ export default {
// createdAt: date,
// updatedAt: date,
},
discussions: [],
};
},
mounted() {
axios
.get(`/api/communities/${this.$route.params.slug}/discussions`, {
headers: {
'x-access-token': window.localStorage.getItem('x-access-token'),
},
})
.then((res) => {
this.discussions = res.data.discussions;
});
},
methods: {
activateReadMore() {
this.readMoreActivated = true;
Expand All @@ -142,7 +171,7 @@ export default {
this.$router.replace({ name: 'Home' });
},
newDiscussion() {
this.$router.push(`/communities/${this.$route.params.communitySlug}/discussion/new`);
this.$router.push(`/communities/${this.$route.params.slug}/discussion/new`);
},
},
};
Expand Down
4 changes: 2 additions & 2 deletions src/views/home/MyContents.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="row">
<table class="table col-12 col-md-8" style=" margin:auto;">
<table class="table col-12 col-md-8" style=" margin:auto;">
<thead>
<tr>
<th scope="col">Cover</th>
Expand All @@ -25,7 +25,7 @@
</td>
</tr>
</tbody>
</table>
</table>
</div>
</template>

Expand Down