creating dynamic route for the team and fixing other things
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
export default function Team() {
|
||||
const router = useRouter()
|
||||
const { teamid } = router.query
|
||||
|
||||
// check if the team is a valid team route and show the dashboard for the team
|
||||
|
||||
return (
|
||||
<span>the team is {teamid}</span>
|
||||
)
|
||||
}
|
||||
@@ -31,8 +31,12 @@ function RouteHandler({ user }) {
|
||||
console.log(user)
|
||||
// if user has no profile, then go to create profile
|
||||
if (!user || !user.firstName || !user.lastName || !user.nickName) {
|
||||
console.log('no profile for the user, routing him/her there')
|
||||
router.push('/teams/profile')
|
||||
}
|
||||
|
||||
// check if user is in a team or has created one
|
||||
|
||||
} catch(error) {
|
||||
console.log(error)
|
||||
router.push('/teams/login')
|
||||
|
||||
@@ -44,7 +44,7 @@ export default function Profile() {
|
||||
})();
|
||||
}, [])
|
||||
|
||||
function handleSubmit() {
|
||||
async function handleSubmit() {
|
||||
if (!firstName) {
|
||||
setError('Must input first name')
|
||||
return
|
||||
@@ -67,7 +67,13 @@ export default function Profile() {
|
||||
newUser.nickName = nickname
|
||||
newUser.avatarUrl = currUser.photoURL
|
||||
|
||||
userService.updateUser(newUser)
|
||||
try {
|
||||
await userService.updateUser(newUser)
|
||||
router.push('/teams')
|
||||
}
|
||||
catch(error) {
|
||||
setError('Something went wrong in saving your information. Please try again.')
|
||||
}
|
||||
}
|
||||
|
||||
const [firstName, setFirstName] = useState<string>(currUser.displayName.split(" ")[0]);
|
||||
|
||||
Reference in New Issue
Block a user