<template>
    <div class="flex items-center justify-between gap-10">
        <h1 class="text-3xl font-bold uppercase">Utilisateurs</h1>
        <button
            class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
            @click="null"
        >
            Ajouter
        </button>
    </div>

    <div>
        <div class="mt-6 border border-slate-200 mb-16 ">
            <div class="grid grid-cols-3 gap-4 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide">
                <div>Username</div>
                <div>Role</div>
                <div>Action</div>
            </div>
            <div
                v-for="user in userList"
                :key="user.id"
                class="grid grid-cols-3 gap-4 px-4 py-3 text-sm hover:bg-slate-50 cursor-pointer border-t border-slate-200 items-center"
                role="button"
                tabindex="0"
            >
                <div>
                    {{ user.username}}
                </div>
                <div>
                    {{ user.roles?.join(', ') || ' ---' }}
                </div>
                <div>
                    <div class="p-4">
                        <button
                            class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
                            @click="null"
                        >
                            Modifier
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>




<script setup lang="ts">
definePageMeta({
    layout: 'admin'
})

import type {UserData} from "~/services/dto/user-data";
import {getUsers} from "~/services/auth";

const userList = ref<UserData[]>([])


onMounted(async () => {
    userList.value = await getUsers()
})
</script>
