<script setup lang="ts">
import k_logo from '@/assets/LOGO.svg'
import { apiFetch } from '~/utils/apiFetch';

import tg from '@/assets/icons/telegram.svg'
import vk from '@/assets/icons/vk.svg'
import yt from '@/assets/icons/youtube.svg'
const icons = {
    'simple-icons:vk': vk,
    'simple-icons:telegram': tg,
    'simple-icons:youtube': yt,
}

const { data: footerData } = await apiFetch<ApiFooterType[]>(`footer/?ordering=small_text`)
const { data: social_networkData } = await apiFetch<ApiSocial_networkType[]>(`social_network/`)
</script>
<template>
    <div class="footer" id="contacts">
        <div class="container">
            <div class="k-logo">
                <k_logo />
            </div>
            <template v-for="item in footerData">
                <div class="footer-text" :class="[{ 'footer-text-small': item.small_text }]">{{ item.text }}</div>
            </template>
            <div class="footer-text footer-text-social" v-if="social_networkData">
                <template v-for="item in social_networkData">
                    <a :href="item.link" target="_blank">
                        <component :is="icons[(item.icon.trim() as keyof typeof icons)]"
                            v-if="icons.hasOwnProperty(item.icon.trim())" />
                        <Icon :name="item.icon" v-else /> {{ item.name }}
                    </a>
                </template>
            </div>
        </div>
    </div>
</template>