<template>
  <q-item
    v-permissions="permission"
    clickable
    tag="a"
    :target="target?target:'_blank'"
    :href="link"
    :disable="disable"
    v-if="!isSeparator"
  >
    <q-item-section
      v-if="icon"
      avatar
    >
      <q-icon :name="icon" />
    </q-item-section>

    <q-item-section>
      <q-item-label>{{ title }}</q-item-label>
      <q-item-label caption>{{ caption }}</q-item-label>
    </q-item-section>
  </q-item>
  <q-separator
    class="q-my-sm"
    v-if="isSeparator"
    inset
  />
</template>

<script setup lang="ts">
export interface EssentialLinkProps {
  title: string;
  caption?: string;
  link?: string;
  icon?: string;
  isSeparator?: boolean;
  target?:string;
  disable?:boolean;
  permission?: string|null;
}
withDefaults(defineProps<EssentialLinkProps>(), {
  caption: '',
  link: '#',
  icon: '',
});
</script>
