<template>
  <div>
    <div class="app-list-item">
      <div class="app-name-container"><div class="app-name-name">{{ app.name }}</div><div class="app-name-id">{{ app.client_id}}</div></div>

      <div class="badge-list"> <basic-badge variant="secondary" icon="lock" v-for="group in groups" :key="group">{{group}}</basic-badge></div>
      <div class="action-container"> <icon-button icon="trash" @click="deleteClick"></icon-button></div>
    </div>
  </div>

</template>

<script>
import Box from "@/components/UI/Box.vue";
import IconButton from "@/components/UI/IconButton.vue";
import BasicBadge from "@/components/UI/BasicBadge.vue";

export default {
  name: "AppListItem",
  components: {BasicBadge, IconButton, Box},
  emits: ["deleteApp"],
  props: {
    app: {
      type: Object,
      required: true
    }
  },
  computed: {
    groups() {
      return this.app.groups;
    }
  },
  methods: {
    deleteClick() {
      this.$emit("deleteApp", this.app.id);
    }
  }
}
</script>

<style scoped>
.app-list-item {
  display: grid;
  grid-template-columns: 1fr 2fr 0.5fr;
  grid-gap: 2.4rem;
  padding: 1.2rem 0;
  font-weight: 400;
  font-size: 1.4rem;
  border-bottom: 0.1rem solid #E3EDFF;
  align-items: center;
  justify-items: start;
}

.app-name-container {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.badge-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.8rem;
}


.app-name-name {
  font-weight: 500;
  font-size: 1.4rem;
}

.app-name-id {
  font-weight: 400;
  font-size: 1.4rem;
  color: #6b7280;
}

.action-container{
  align-self: center;
}

</style>