<template>
  <div class="top-title">
    <svg-icon :icon-class="icon" size="26" />

    <div class="title">{{ title }}</div>
    <i-ep-plus
      v-if="messageType && canCreateMessage"
      style="margin-left: 8px"
      @click="gotoList"
    />
  </div>
</template>

<script lang="ts" setup>
import { useUserStore } from "@/store";

const props = defineProps<{
  title: string;
  icon: string;
  messageType: {
    type: string;
    default: "";
    required: false;
  };
  canCreateMessage: boolean;
}>();

const router = useRouter();
const userStore = useUserStore();
const gotoList = () => {
  console.log("gotoList", props.messageType);
  router.push({ name: "messagesList", params: { type: props.messageType } });
};
</script>

<style lang="scss" scoped>
.top-title {
  display: flex;
  justify-content: start;
  align-items: center;
  margin-bottom: 12px;
}

.title {
  margin-left: 8px;
  font-weight: bold;
  font-size: 16px;
  color: #666666;
  text-align: left;
}
</style>
