Skip to content

Commit dce35e0

Browse files
committed
feat(frontend): Add app tour to admin, fix admin register (SCRUM-290)
1 parent bd13329 commit dce35e0

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

Frontend/i18n/locales/en-GB.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"matching": {
9090
"alt": "A video showcasing the use of the matching page",
9191
"description": "Swipe left or right to accept or reject supervision requests from Students. Visit their profile, and undo your actions if you mis-swiped!",
92-
"title": "Match with Supervisors"
92+
"title": "Match with Students"
9393
},
9494
"overview": {
9595
"alt": "A video giving an overview of the app",

Frontend/middleware/01.routing.global.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,27 @@ export default defineNuxtRouteMiddleware(async (to) => {
3434
// Register user if is not already registered
3535

3636
if (!registrationStore.status || !registrationStore.status.exists || !registrationStore.status.is_registered) {
37-
console.log('🍍🍍🍍🍍🍍🍍[ROUTING MIDDLEWARE]: Fetching registration status for user:', userEmail)
3837
await registrationStore.fetchRegistrationStatus(userEmail)
3938
}
4039
let userRole = UserRoles.STUDENT
4140
if (registrationStore.status?.role) {
4241
userRole = registrationStore.status.role
4342
}
4443

45-
// Skip checking is admin is oboarded. They should be redirected to dashboard
44+
const accountRegistrationCompleted = registrationStore.status?.is_registered || false
45+
4646
if (userRole === UserRoles.ADMIN) {
47+
if (!accountRegistrationCompleted) {
48+
if (!to.path.startsWith('/admin/app-tour')) {
49+
return navigateTo('/admin/app-tour')
50+
}
51+
}
4752
if (!to.path.startsWith('/admin')) {
4853
return navigateTo('/admin/dashboard')
4954
}
5055
return
5156
}
5257

53-
const accountRegistrationCompleted = registrationStore.status?.is_registered || false
5458
const tagsSelected = registrationStore.status?.tags || false
5559

5660
if (!accountRegistrationCompleted && to.path.startsWith('/onboarding')) {

Frontend/pages/admin/app-tour.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,32 @@ import { useI18n } from 'vue-i18n';
33
44
const { t } = useI18n();
55
6+
const authStore = useAuthStore();
7+
await authStore.initialize();
8+
const { user } = storeToRefs(authStore);
9+
const userEmail = user.value?.primaryEmailAddress?.emailAddress;
10+
const registrationStore = useRegistrationStore();
611
12+
const registerNewAdmin = async () => {
13+
if (!userEmail) {
14+
console.error('User email is not available');
15+
return;
16+
}
17+
console.log('registerNewAdmin with email:', userEmail);
18+
19+
$fetch('/api/users', {
20+
method: 'POST',
21+
body: {
22+
email: userEmail
23+
}
24+
})
25+
.then(() => {
26+
navigateTo('/dashboard/admin');
27+
})
28+
.catch((error) => {
29+
console.error('Error registering new admin:', error);
30+
});
31+
};
732
const steps = [
833
{
934
source: '../appTour/admin/dashboard.jpeg',
@@ -35,7 +60,11 @@ const currentStep = ref(0);
3560
3661
function next() {
3762
if (currentStep.value === steps.length - 1) {
38-
close();
63+
if (!registrationStore.status.is_registered) {
64+
registerNewAdmin()
65+
} else {
66+
close();
67+
}
3968
}
4069
currentStep.value = Math.min(steps.length - 1, currentStep.value + 1);
4170
}

Frontend/pages/onboarding/student.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ async function handleSubmit() {
216216
if (!registrationStore.status || !registrationStore.status.exists || !registrationStore.status.is_registered) {
217217
await registrationStore.fetchRegistrationStatus(userStore.user?.email)
218218
}
219-
return navigateTo('/student/dashboard');
219+
return navigateTo('/student/app-tour');
220220
}
221221
222222
const fetchAlldata = async () => {

0 commit comments

Comments
 (0)