<style scoped>
.area1 {
  background-image: linear-gradient(rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 1) 90%), url("@images/news/news_bg.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  min-height: 120vh;
}
.mt {
  margin-top: 100px;
}
.area1 h1 {
  color: #fff;
  font-family: Poppins;
  font-size: 2rem;
  font-weight: bold;
  text-align: center;
  padding-top: 5rem;
}
.styled-hr {
  border: none;
  width: 10rem;
  height: 1px;
  background-color: #fff;
  position: relative;
  margin: 0.5rem 0;
  opacity: 0.5;
}
.styled-hr::before,
.styled-hr::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 1px;
  height: 0.5rem;
  background-color: #fff;
  transform: translateY(-50%);
}
.styled-hr::before {
  left: 5px;
}
.styled-hr::after {
  right: 5px;
}
.area1 .news-main {
  min-height: 30rem;
  background: linear-gradient(rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.2) 100%);
  backdrop-filter: blur(0.2rem);
  display: flex;
  flex-direction: column;
  padding: 2rem;
  margin-top: 2rem;
  font-family: Poppins;
  color: #fff;
}
.area1 .news-main .title {
  font-size: 1.5rem;
  font-weight: bold;
  text-align: center;
}
.area1 .news-main .date {
  font-size: 1rem;
  text-align: start;
  margin: 2rem 0;
}
.area1 .news-main .content {
  font-size: 1rem;
  text-align: start;
}
.btn-goback {
  background-color: #000;
  color: #fff;
  font-size: 1rem;
  border: 1px #fff solid;
  border-radius: 50rem;
  padding: 0.5rem 2.5rem;
}
.btn-goback:hover {
  background-color: #fff;
  color: #000;
}
.area2 {
  background-color: #000;
  min-height: 10rem;
}
@media (max-width: 768px) {
  .area1 .news-area > .row > div+div {
    border: 0;
  }
}
</style>
<template>
  <div class="area1">
    <div class="container d-flex flex-column align-items-center" :class="{'mt': !isAuthenticated}">
      <h1 class="title">{{ $t('backend.news.latest_news') }}</h1>
      <hr class="styled-hr">
      <div class="news-main col-12 col-md-8">
        <p class="title">{{ news.title }}</p>
        <p class="date">{{ news.post_date }}</p>
        <pre class="content">{{ news.content }}</pre>
      </div>
      <div class="text-start col-12 col-md-8">
        <button class="btn-goback" @click="$router.back()">
          ← {{ $t('global.back') }}
        </button>
      </div>
    </div>
  </div>
  <div class="area2"></div>
</template>
<script>
import { api } from "@/global/axios";
import { isAuthenticated } from "@/global/request";
export default {
  data() {
    return {
      isAuthenticated: isAuthenticated(),
      id: this.$route.params.id ?? null,
      newsType: [this.$t('global.system'), this.$t('global.notification')],
      news: {},
    };
  },
  mounted() {
    const vm = this;
    vm.fetchData();
  },
  methods: {
    fetchData: async function () {
      const vm = this;
      await api
        .get(`/api/getNewsById/${vm.id}`)
        .then((res) => {
          vm.news = res.data.data;
        });
    },
  },
};
</script>