<template>
  <article class="ui--viewer" v-html="$filters.nl2br(post.postDetail)"></article>
</template>

<script>
import axios from 'axios';
import SDLUtil from '@/utils/SDLUtil';

export default {
  data() {
    return {
      boardId: this.$route.params.boardId,
      postId: this.$route.params.postId,
      post: {},
    };
  },
  methods: {
    init() {
      this.getPostInfo();
    },
    getPostInfo() {
      SDLUtil.showLoadingBar(true);
      axios
        .get(`${SDLUtil.API_URL}/boards/${this.boardId}/posts/${this.postId}`)
        .then(({ data }) => {
          this.post = data;
        })
        .catch(err => {
          SDLUtil.showLoadingBar(false);
          SDLUtil.errorAlert(err);
        });
      SDLUtil.showLoadingBar(false);
    },
  },
  mounted() {
    this.$nextTick(() => {
      console.info('initialize Board NoticePopup');
      this.init();
    });
  },
};
</script>
<style scoped></style>
