{#key selectedUser} { users = await getUsers(localStorage.token); }} /> {/key} { users = await getUsers(localStorage.token); }} /> {#if loaded} { showSidebar.set(!$showSidebar); }} > {$i18n.t('Dashboard')} {$i18n.t('All Users')} {users.length} { showAddUserModal = !showAddUserModal; }} > { showSettingsModal = !showSettingsModal; }} > {$i18n.t('Role')} {$i18n.t('Name')} {$i18n.t('Email')} {$i18n.t('Last Active')} {$i18n.t('Created at')} {#each users .filter((user) => { if (search === '') { return true; } else { let name = user.name.toLowerCase(); const query = search.toLowerCase(); return name.includes(query); } }) .slice((page - 1) * 20, page * 20) as user} { if (user.role === 'user') { updateRoleHandler(user.id, 'admin'); } else if (user.role === 'pending') { updateRoleHandler(user.id, 'user'); } else { updateRoleHandler(user.id, 'pending'); } }} > {$i18n.t(user.role)} {user.name} {user.email} {dayjs(user.last_active_at * 1000).fromNow()} {dayjs(user.created_at * 1000).format($i18n.t('MMMM DD, YYYY'))} {#if user.role !== 'admin'} { showUserChatsModal = !showUserChatsModal; selectedUser = user; }} > { showEditUserModal = !showEditUserModal; selectedUser = user; }} > { deleteUserHandler(user.id); }} > {/if} {/each} ⓘ {$i18n.t("Click on the user role button to change a user's role.")} {/if}