* Async append user suspended status pill * Rubocop * Relocate JS tests, for build & coverage * Better error-handling for this controller * Refactor HTML to render pill outside h1 * Continuing to tweak design * JS class prepended
25 lines
740 B
JavaScript
25 lines
740 B
JavaScript
import '@utilities/document_ready';
|
|
|
|
export async function asyncUserStatusCheck() {
|
|
const indicator = ` <span data-testid="user-status" class="ml-3 c-indicator c-indicator--danger c-indicator--relaxed">Suspended</span>`;
|
|
|
|
const profile = document.querySelector('.profile-header__details');
|
|
|
|
if (profile && !profile.dataset.statusChecked) {
|
|
await window
|
|
.fetch(profile.dataset.url)
|
|
.then((res) => res.json())
|
|
.then((data) => {
|
|
profile.dataset.statusChecked = true;
|
|
const { suspended } = data;
|
|
if (suspended) {
|
|
profile.querySelector('.js-username-container').innerHTML +=
|
|
indicator;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
document.ready.then(() => {
|
|
asyncUserStatusCheck();
|
|
});
|