-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from JumboCode/ConnectStudent
Connecting Students and Classes
- Loading branch information
Showing
7 changed files
with
143 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
const AdminView = () => { | ||
const [user, setUser] = useState(null); | ||
const [user, setUser] = useState(null); | ||
|
||
useEffect(() => { | ||
const params = new URLSearchParams(location.search); | ||
const user = { | ||
firstName: params.get('firstName'), | ||
lastName: params.get('lastName'), | ||
username: params.get('username') | ||
}; | ||
setUser(user); | ||
}, []); | ||
useEffect(() => { | ||
const params = new URLSearchParams(location.search); | ||
const user = { | ||
firstName: params.get('firstName'), | ||
lastName: params.get('lastName'), | ||
username: params.get('username') | ||
}; | ||
setUser(user); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<h1>Admin: {user ? `${user.firstName} ${user.lastName}` : 'Loading...'}</h1> | ||
</div> | ||
); | ||
return ( | ||
<div className="h-full"> | ||
<h1>Admin: {user ? `${user.firstName} ${user.lastName}` : 'Loading...'}</h1> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AdminView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,47 @@ | ||
import { useEffect, useState } from "react"; | ||
import { useEffect, useState } from 'react'; | ||
import Class from '@/components/Class'; | ||
import { getClassById, getStudentClasses } from '@/api/class-wrapper'; | ||
|
||
const StudentPortal = () => { | ||
const [user, setUser] = useState(null); | ||
const [classes, setClasses] = useState([]); | ||
const [user, setUser] = useState(null); | ||
|
||
useEffect(() => { | ||
const params = new URLSearchParams(location.search); | ||
const user = { | ||
firstName: params.get('firstName'), | ||
lastName: params.get('lastName'), | ||
username: params.get('username') | ||
}; | ||
setUser(user); | ||
}, []); | ||
useEffect(() => { | ||
const params = new URLSearchParams(location.search); | ||
const user = { | ||
firstName: params.get('firstName'), | ||
lastName: params.get('lastName'), | ||
username: params.get('username') | ||
}; | ||
setUser(user); | ||
|
||
return ( | ||
<div> | ||
<h1>Student: {user ? `${user.firstName} ${user.lastName}` : 'Loading...'}</h1> | ||
</div> | ||
); | ||
}; | ||
// get classes for student | ||
const fetchData = async () => { | ||
// fetch a specific user | ||
const response = await getStudentClasses("671edb6d31e448b23d0dc384"); | ||
const classes = await Promise.all( | ||
response.enrolledClasses.map(async (classID) => { | ||
const classResponse = await getClassById(classID); | ||
return classResponse; // Return the class details | ||
}) | ||
); | ||
setClasses(classes); | ||
}; | ||
|
||
fetchData(); | ||
}, []); | ||
|
||
return ( | ||
<div className='h-full'> | ||
<h1>Student: {user ? `${user.firstName} ${user.lastName}` : 'Loading...'}</h1> | ||
<div className='grid grid-cols-3'> | ||
{classes.map((classObj, classIndex) => ( | ||
<Class key={classIndex} classObj={classObj} /> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
|
||
} | ||
|
||
export default StudentPortal; |