diff options
Diffstat (limited to 'src/components/announcements_page/announcements_page.js')
| -rw-r--r-- | src/components/announcements_page/announcements_page.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/components/announcements_page/announcements_page.js b/src/components/announcements_page/announcements_page.js index a2a218fd..ec038361 100644 --- a/src/components/announcements_page/announcements_page.js +++ b/src/components/announcements_page/announcements_page.js @@ -1,16 +1,44 @@ +import { mapState } from 'vuex' import Announcement from '../announcement/announcement.vue' const AnnouncementsPage = { components: { Announcement }, + data () { + return { + newAnnouncement: { + content: '' + }, + posting: false, + error: undefined + } + }, mounted () { this.$store.dispatch('fetchAnnouncements') }, computed: { + ...mapState({ + currentUser: state => state.users.currentUser + }), announcements () { return this.$store.state.announcements.announcements } + }, + methods: { + postAnnouncement () { + this.posting = true + this.$store.dispatch('postAnnouncement', this.newAnnouncement) + .catch(error => { + this.error = error.error + }) + .finally(() => { + this.posting = false + }) + }, + clearError () { + this.error = undefined + } } } |
