feat: laad pagina na laden van user
This commit is contained in:
parent
e21f11185b
commit
feb6bc3d9d
3 changed files with 81 additions and 11 deletions
|
@ -16,6 +16,9 @@
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const classId: string = route.params.id as string;
|
const classId: string = route.params.id as string;
|
||||||
const username = ref<string | undefined>(undefined);
|
const username = ref<string | undefined>(undefined);
|
||||||
|
const isLoading = ref(false);
|
||||||
|
const isError = ref(false);
|
||||||
|
const errorMessage = ref<string>("");
|
||||||
|
|
||||||
// Queries used to access the backend and catch loading or errors
|
// Queries used to access the backend and catch loading or errors
|
||||||
|
|
||||||
|
@ -32,8 +35,16 @@
|
||||||
|
|
||||||
// Load current user before rendering the page
|
// Load current user before rendering the page
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
isLoading.value = true;
|
||||||
|
try {
|
||||||
const userObject = await authState.loadUser();
|
const userObject = await authState.loadUser();
|
||||||
username.value = userObject?.profile?.preferred_username ?? undefined;
|
username.value = userObject!.profile!.preferred_username;
|
||||||
|
} catch (error) {
|
||||||
|
isError.value = true;
|
||||||
|
errorMessage.value = error instanceof Error ? error.message : String(error);
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Used to set the visibility of the dialog
|
// Used to set the visibility of the dialog
|
||||||
|
@ -109,6 +120,19 @@
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<main>
|
<main>
|
||||||
|
<div
|
||||||
|
class="loading-div"
|
||||||
|
v-if="isLoading"
|
||||||
|
>
|
||||||
|
<v-progress-circular indeterminate></v-progress-circular>
|
||||||
|
</div>
|
||||||
|
<div v-if="isError">
|
||||||
|
<v-empty-state
|
||||||
|
icon="mdi-alert-circle-outline"
|
||||||
|
:text="errorMessage"
|
||||||
|
:title="t('error_title')"
|
||||||
|
></v-empty-state>
|
||||||
|
</div>
|
||||||
<using-query-result
|
<using-query-result
|
||||||
:query-result="getClass"
|
:query-result="getClass"
|
||||||
v-slot="classResponse: { data: ClassResponse }"
|
v-slot="classResponse: { data: ClassResponse }"
|
||||||
|
|
|
@ -17,16 +17,26 @@
|
||||||
|
|
||||||
// Username of logged in student
|
// Username of logged in student
|
||||||
const username = ref<string | undefined>(undefined);
|
const username = ref<string | undefined>(undefined);
|
||||||
|
const isLoading = ref(false);
|
||||||
|
const isError = ref(false);
|
||||||
|
const errorMessage = ref<string>("");
|
||||||
|
|
||||||
// Students of selected class are shown when logged in student presses on the member count
|
// Students of selected class are shown when logged in student presses on the member count
|
||||||
const selectedClass = ref<ClassDTO | null>(null);
|
const selectedClass = ref<ClassDTO | null>(null);
|
||||||
const getStudents = ref(false);
|
const getStudents = ref(false);
|
||||||
|
|
||||||
// Find the username of the logged in user so it can be used to fetch other information
|
// Load current user before rendering the page
|
||||||
// When loading the page
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
isLoading.value = true;
|
||||||
|
try {
|
||||||
const userObject = await authState.loadUser();
|
const userObject = await authState.loadUser();
|
||||||
username.value = userObject?.profile?.preferred_username ?? undefined;
|
username.value = userObject!.profile!.preferred_username;
|
||||||
|
} catch (error) {
|
||||||
|
isError.value = true;
|
||||||
|
errorMessage.value = error instanceof Error ? error.message : String(error);
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fetch all classes of the logged in student
|
// Fetch all classes of the logged in student
|
||||||
|
@ -111,7 +121,20 @@
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<main>
|
<main>
|
||||||
<div>
|
<div
|
||||||
|
class="loading-div"
|
||||||
|
v-if="isLoading"
|
||||||
|
>
|
||||||
|
<v-progress-circular indeterminate></v-progress-circular>
|
||||||
|
</div>
|
||||||
|
<div v-if="isError">
|
||||||
|
<v-empty-state
|
||||||
|
icon="mdi-alert-circle-outline"
|
||||||
|
:text="errorMessage"
|
||||||
|
:title="t('error_title')"
|
||||||
|
></v-empty-state>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
<h1 class="title">{{ t("classes") }}</h1>
|
<h1 class="title">{{ t("classes") }}</h1>
|
||||||
<using-query-result
|
<using-query-result
|
||||||
:query-result="classesQuery"
|
:query-result="classesQuery"
|
||||||
|
|
|
@ -15,12 +15,22 @@
|
||||||
|
|
||||||
// Username of logged in teacher
|
// Username of logged in teacher
|
||||||
const username = ref<string | undefined>(undefined);
|
const username = ref<string | undefined>(undefined);
|
||||||
|
const isLoading = ref(false);
|
||||||
|
const isError = ref(false);
|
||||||
|
const errorMessage = ref<string>("");
|
||||||
|
|
||||||
// Find the username of the logged in user so it can be used to fetch other information
|
// Load current user before rendering the page
|
||||||
// When loading the page
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
isLoading.value = true;
|
||||||
|
try {
|
||||||
const userObject = await authState.loadUser();
|
const userObject = await authState.loadUser();
|
||||||
username.value = userObject?.profile?.preferred_username ?? undefined;
|
username.value = userObject!.profile!.preferred_username;
|
||||||
|
} catch (error) {
|
||||||
|
isError.value = true;
|
||||||
|
errorMessage.value = error instanceof Error ? error.message : String(error);
|
||||||
|
} finally {
|
||||||
|
isLoading.value = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fetch all classes of the logged in teacher
|
// Fetch all classes of the logged in teacher
|
||||||
|
@ -111,6 +121,19 @@
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<main>
|
<main>
|
||||||
|
<div
|
||||||
|
class="loading-div"
|
||||||
|
v-if="isLoading"
|
||||||
|
>
|
||||||
|
<v-progress-circular indeterminate></v-progress-circular>
|
||||||
|
</div>
|
||||||
|
<div v-if="isError">
|
||||||
|
<v-empty-state
|
||||||
|
icon="mdi-alert-circle-outline"
|
||||||
|
:text="errorMessage"
|
||||||
|
:title="t('error_title')"
|
||||||
|
></v-empty-state>
|
||||||
|
</div v-else>
|
||||||
<div>
|
<div>
|
||||||
<h1 class="title">{{ t("classes") }}</h1>
|
<h1 class="title">{{ t("classes") }}</h1>
|
||||||
<using-query-result
|
<using-query-result
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue