<script setup>
import { ref, onMounted, watch } from "vue";
import { useRoute, useRouter } from "vue-router";

import PageBanner from "@/components/PageBanner.vue";

import featureImg from '@/assets/img/iStock.jpg';
import bannerImg from '@/assets/img/news.jpg';

const { t } = useI18n();

const route = useRoute();
const router = useRouter();

const bannerObj = computed(() => {
  let title, path;

  if( route.path.includes('/social/news') ){
    title = t('Social.news');
    path = t('Social.news');
  }else if( route.path.includes('/social/activity') ){
    title = t('Social.activity');
    path = t('Social.activity');
  }else{
    title = t('Social.esg');
    path = t('Social.esg');
  }

  return {
    "bImg": bannerImg,
    "pageName": t('news'),
    "path": path,
    "title": title
  }
});

const menuList = [
  {
    "name":t('Social.news'), 
    "path":"/social/news"
  },
]

const currentRoute = ref('');

onMounted(() => {
  currentRoute.value = route.path;
});

watch(() => route.params,
  (n,o) => {
    currentRoute.value = route.path;
  }
)
</script>

<template>
  <div>
    <div class="main social">
      <PageBanner :item="bannerObj"/>

      <section class="section leftMenu">
        <div class="container">
          <div class="row">
            <div class="col-12 col-lg-4 col-xl-3">			
              <div class="list-group">
                <a class="list-group-item"
                  :class="{ 'active': currentRoute.includes(item.path) }"
                  href="javascript:;" 
                  v-for="(item,index) in menuList" :key="index"
                  @click="router.push(localeLocation(item.path));"
                >
                  {{ item.name }}
                </a>
              </div>
            </div>
            <div class="col-12 col-lg-8 col-xl-9">
              <NuxtPage/>
            </div>
          </div>
        </div>
      </section>
      
      
      <!-- <router-view v-slot="{ Component }">
        <template v-if="$route.meta.keepAlive">
            <KeepAlive>
                <component :is="Component" />
            </KeepAlive>
        </template>
        <template v-else>
            <component :is="Component" />
        </template>
      </router-view> -->
    </div>
  </div>
  
</template>

<style lang="less">

</style>
