(userId)
| 660 | } |
| 661 | |
| 662 | async function syncRoleForUser(userId) { |
| 663 | const role = state.roles.find((item) => item.user_id === userId); |
| 664 | if (!role || role.is_current) { |
| 665 | renderRoles(state.roles); |
| 666 | return; |
| 667 | } |
| 668 | const data = await api("/api/roles", { |
| 669 | method: "POST", |
| 670 | body: JSON.stringify({ action: "switch", role_name: role.name }), |
| 671 | }); |
| 672 | state.roles = data.roles || []; |
| 673 | renderRoles(state.roles); |
| 674 | await loadUsers(userId); |
| 675 | setActiveUser(userId); |
| 676 | } |
| 677 | |
| 678 | async function createRole() { |
| 679 | const roleName = $("roleName").value.trim(); |
no test coverage detected