File tree Expand file tree Collapse file tree 4 files changed +39
-6
lines changed Expand file tree Collapse file tree 4 files changed +39
-6
lines changed Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff 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' ) ) {
Original file line number Diff line number Diff line change @@ -3,7 +3,32 @@ import { useI18n } from 'vue-i18n';
33
44const { 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+ };
732const steps = [
833 {
934 source: ' ../appTour/admin/dashboard.jpeg' ,
@@ -35,7 +60,11 @@ const currentStep = ref(0);
3560
3661function 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}
Original file line number Diff line number Diff 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
222222const fetchAlldata = async () => {
You can’t perform that action at this time.
0 commit comments