<script setup>
  import i18n from "@/i18n.js"
  import {ref} from 'vue'
  import {validateRegister, getAllRegisters } from '@/rest/ServiceInscription.js'

  const requests = ref(await getAllRegisters());
  console.log(requests);

  async function upPage(id,review){
    await validateRegister(id,review);
    requests.value = await getAllRegisters();

  }
</script>



<template> 
  <div style='display:flex; justify-content:center; min-width:1140px;' v-for="item of requests">
  <div class="bodu" v-if="item.state === 'Pending'">
  <div class="container">
    <div class="id"><a>{{item.id}}</a></div>
    <div class="surname"><a>{{item.lastName}}</a></div>
    <div class="firstname"><a>{{item.firstName}}</a></div>
    <div class="infos"><button style="background-color:rgb(105,05,105);" >{{i18n("request.moreInfos")}}</button></div>
    <div class="accept"><button @click="upPage(item.id,'Accepted')" style="background-color:rgb(0,105,50);">{{i18n("request.accept")}}</button></div>
    <div class="refuse"><button @click="upPage(item.id,'Refused')" style="background-color:rgb(105,0,0);">{{i18n("request.refuse")}}</button></div>
  </div>
  </div>
  </div>
</template>

<style scoped>
  .container{
    color:white;
    height:100px;
    font-size:20px;
    display:grid;
    grid-template-columns:10% 14.2% 19% 14.2% 14.2% 14.2% 14.2%;
    grid-template-areas:
    "id type surname firstname infos accept refuse"; 
    
  }
  
  .infos {
    grid-area:infos;
    align-self:center;
  }

  .accept{
    grid-area:accept;
    align-self:center;
  }

  .refuse{
    grid-area:refuse;
    align-self:center;
  }

  .titles {
    grid-area:titles;
    background-color:rgb(215,215,215);
  }
  .id{
    grid-area:id;
    margin-left:40px;
    align-self:center;
  }

  .type{
    grid-area:type;
    align-self:center;
  }

  .surname{
    grid-area:surname;
    align-self:center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow:ellipsis;
  }

  .firstname{
    grid-area:firstname;
    align-self:center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow:ellipsis;
  }

  button{
    font-size:15px;
     height:50px;
     width:100px;
    border:none;
    border-radius:20px;

  }

 .bodu {
    margin-top:2%;
    width:66%;
    border:2px solid black;
    border-radius:9px;
    background-color:rgb(50,50,50);
  }


</style>


