<template>
  <div>
    <HotPromoted :items="items"></HotPromoted>
    <div class="text-center">
      <v-btn class="buttons" color="primary" to="/recruit/personal/company">{{ $t('enterprise.moreBtn') }}</v-btn>
    </div>
  </div>
</template>

<script setup name="popularEnterprises">
import HotPromoted from '@/components/Enterprise/hotPromoted.vue'
import { ref } from 'vue'
import { getHotEnterprise } from '@/api/enterprise'
import { dealDictArrayData, dealDictObjData } from '@/utils/position'

const items = ref([])

// 热门企业
const getHotEnterpriseList = async () => {
  const { list } = await getHotEnterprise({ pageNo: 1, pageSize: 9 })
  items.value = list.map(e => {
    let jobList = []
    const enterprise = dealDictObjData({}, e.enterprise)
    if (e.jobList && e.jobList.length) jobList = dealDictArrayData([], e.jobList).slice(0, 3)
    return { enterprise, jobList }
  })
}
getHotEnterpriseList()
</script>