mirror of
https://github.com/ae-utbm/sith.git
synced 2024-12-23 16:21:22 +00:00
26 lines
798 B
TypeScript
26 lines
798 B
TypeScript
document.addEventListener("alpine:init", () => {
|
|
Alpine.data("existing_user_subscription_form", () => ({
|
|
loading: false,
|
|
profileFragment: "" as string,
|
|
|
|
async init() {
|
|
const userSelect = document.getElementById("id_member") as HTMLSelectElement;
|
|
userSelect.addEventListener("change", async () => {
|
|
await this.loadProfile(Number.parseInt(userSelect.value));
|
|
});
|
|
await this.loadProfile(Number.parseInt(userSelect.value));
|
|
},
|
|
|
|
async loadProfile(userId: number) {
|
|
if (!Number.isInteger(userId)) {
|
|
this.profileFragment = "";
|
|
return;
|
|
}
|
|
this.loading = true;
|
|
const response = await fetch(`/user/${userId}/mini/`);
|
|
this.profileFragment = await response.text();
|
|
this.loading = false;
|
|
},
|
|
}));
|
|
});
|