<template>
  <el-link type="primary" @click="handleClick" :disabled="id == null">{{name | defaultValue}}</el-link>
</template>

<script>
import { UserType } from '@/utils/constants'

export default {
  name: 'StoreLink',
  props: {
    id: {
      type: [Number,String],
      default: null
    },
    name: {
      type: String,
      default: null,
    },
  },
  methods: {
    handleClick() {
      this.$emit('click');
      if (this.$store.getters.userType === UserType.APP) {
        this.$router.push(`/business/store/${this.id}`)
      } else {
        this.$router.push(`/view/store/${this.id}`)
      }
    }
  }
}
</script>
