import { h } from "preact";



function UserList({userlist,editUser, deleteUser, start, end}) {


    const displayUser=(user)=>{
        return (
            <div key={`user${user.line}`} class="user-list-item" >
                <div class="user-attributes">
                    <span><b>UID:</b> {user.uid}</span> <span>(<b>{user.enabled?'Aktiv':'Inaktiv'}</b>)</span><br />
                    <span><b>Vorname:</b> {user.first_name}</span><br />
                    <span><b>Nachname:</b> {user.last_name}</span><br />
                    <span><b>RFID:</b> {user.rfid_uid}</span>
                    <span><b>PIN:</b> {user.user_pin}</span>
                </div>
                <div class="btn-group">
                    <button class="btn-trash" onClick={()=>deleteUser(user)}>Löschen</button>
                    <button class="btn-edit" onClick={()=>editUser(user)}>Bearbeiten</button>
                </div>
            </div>);
    }
    

        return (
            <div className="row">
            {userlist&&(start!==undefined&&end?userlist.slice(start,end).map((user)=>displayUser(user)):userlist.map((user)=>displayUser(user)))}
            </div>
        );
    
}
export default UserList