<template>
  <div>
    <section class="intro-single">
      <div class="container">
        <div class="row">
          <div class="col-md-12 col-lg-8">
            <div class="title-single-box">
              <h2 class="title-single">User Defined Groups List</h2>
            </div>
          </div>
        </div>
      </div>
    </section>
    <div class="container">
      <router-link :to="`/userDefinedGroups/userDefinedGroup`">New</router-link>
      <table class="table table-bordered">
        <thead>
          <tr>
            <th>Description</th>
            <th>Property Type</th>
            <th>Order</th>
            <th></th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="(item, i) in userDefinedGroups" :key="i">
            <td>{{item.description}}</td>
            <td v-if="item.usageType === 0">Residential</td>
            <td v-else-if="item.usageType === 1">Commercial</td>
            <td v-else>Both</td>
            <td>{{item.rank}}</td>
            <td>
              <router-link :to="`/userDefinedGroups/userDefinedGroup/${item.id}`">Edit</router-link>
            </td>
            <td>
              <button>Delete</button>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</template>
<script>
import { mapState, mapActions } from 'vuex';

export default {
  name: 'UserDefinedGroup',
  created() {
    this.getUserDefinedGroups();
  },
  computed: {
    ...mapState('propertyAdmin', ['userDefinedGroups']),
  },
  methods: {
    ...mapActions('propertyAdmin', ['getUserDefinedGroups']),
  },
};
</script>
<style>
</style>
