<script setup>
import { hasToken } from '@Services/Api';
import { useRouter } from 'vue-router';
import { computed } from 'vue';

/** Definidores */
const router = useRouter();

/* Propiedades */
const props = defineProps({
    size: {
        type: String,
        default: 'lg',
        validator: (value) => ['sm', 'md', 'lg', 'xl'].includes(value)
    }
});

/** Métodos */
const home = () => {
    if(hasToken()) {
        router.push({ name: 'address.index' });
    } else {
        location.replace('/');
    }
}

/* Computed */
const heightClass = computed(() => {
    const size = {
        sm: 'h-12',
        md: 'h-16',
        lg: 'h-20',
        xl: 'h-64'
    }
    return size[props.size];
});
</script>
<template>
    <div
        class="flex w-full justify-center items-center space-x-2 cursor-pointer"
        @click="home"
    >
        <img :src="'/logo.png'" :class="heightClass" />
    </div>
</template>