import React from "react" import * as antd from "antd" import { Icons } from "components/Icons" import { ActionsBar, SelectableList } from "components" import "./index.less" export default class Users extends React.Component { state = { data: null, selectionEnabled: false, } api = window.app.api.withEndpoints("main") componentDidMount = async () => { await this.loadData() } loadData = async () => { this.setState({ data: null }) const data = await this.api.get.users() this.setState({ data }) } toogleSelection = (to) => { this.setState({ selectionEnabled: to ?? !this.state.selectionEnabled }) } openUser(username) { if (this.state.selectionEnabled) { return false } window.app.setLocation(`/@${username}`) } renderRoles(roles) { return roles.map((role) => { return {role} }) } renderItem = (item) => { return (
this.openUser(item.username)} className="user_item" >

{item.fullName ?? item.username}

#{item._id}

{this.renderRoles(item.roles)}
) } render() { return (
: } type={this.state.selectionEnabled ? "default" : "primary"} onClick={() => this.toogleSelection()}> {this.state.selectionEnabled ? "Done" : "Select"}
}>New User
{!this.state.data ? : }
) } }