From dbb17d81b409b61dde3d28d4b2e021a8b655d18f Mon Sep 17 00:00:00 2001 From: Arjun Patel Date: Fri, 14 Jan 2022 02:38:15 -0800 Subject: [PATCH] nice overall component done --- pages/teams/create.js | 6 ++++ pages/teams/index.tsx | 69 ++++++++++++++++++++++++++++++++++------- pages/teams/profile.tsx | 6 ++-- 3 files changed, 68 insertions(+), 13 deletions(-) create mode 100644 pages/teams/create.js diff --git a/pages/teams/create.js b/pages/teams/create.js new file mode 100644 index 0000000..188d096 --- /dev/null +++ b/pages/teams/create.js @@ -0,0 +1,6 @@ +export default function CreateTeam() { + + return ( +
this is the place to create a team
+ ) +} \ No newline at end of file diff --git a/pages/teams/index.tsx b/pages/teams/index.tsx index 0ffea2d..b84f961 100644 --- a/pages/teams/index.tsx +++ b/pages/teams/index.tsx @@ -7,18 +7,24 @@ import { GetServerSidePropsContext } from "next" import nookies from 'nookies' import firebaseAdmin from 'firebase-admin' import unfetch from 'isomorphic-unfetch' +import { + FaPeopleCarry, + FaArrowRight, + FaBullhorn +} from "react-icons/fa"; +import BackgroundLayout from "../../components/Layouts/BackgroundLayout" /** * figure out where to take the user based on everything */ -function RouteHandler({ user }) { +function RouteHandler() { const { currUser } = useAuth() const router = useRouter() const userService: UserService = new UserService() - const [loading, setLoading] = useState(false) + const [loading, setLoading] = useState(true) + const [user, setUser] = useState(null) useEffect(() => { - (async function() { try { // if not authenticated, take user to the login @@ -28,31 +34,72 @@ function RouteHandler({ user }) { } // get user - const user: User | null = await userService.getUser(currUser.uid) - console.log(user) + const returnedUser: User | null = await userService.getUser(currUser.uid) + console.log(returnedUser) // if user has no profile, then go to create profile - if (!user || !user.firstName || !user.lastName || !user.nickName) { + if (!returnedUser || !returnedUser.firstName || !returnedUser.lastName || !returnedUser.nickName) { console.log('no profile for the user, routing him/her there') router.push('/teams/profile') } - - // check if user is in a team go to the team dashboard - + setUser(returnedUser) + // check if user is in a team go to the team dashboard } catch(error) { console.log(error) router.push('/teams/login') } })(); + + setLoading(false) }, [currUser]) - if (loading) { + if (loading || !user) { return
figuring out where you should go
} + // not in a team yet, and have not created a team yet return ( -
this is the route handler page
+
+ {/* header */} +
+ +
👋Hey, {user.firstName}
+ Let's get you started +
+ + +
+ + {/* create team hover thing */} + + + + {/* tell your manager to add your email */} + + + Learn more about +
) } diff --git a/pages/teams/profile.tsx b/pages/teams/profile.tsx index ff24492..9ee8b1f 100644 --- a/pages/teams/profile.tsx +++ b/pages/teams/profile.tsx @@ -44,7 +44,9 @@ export default function Profile() { })(); }, []) - async function handleSubmit() { + async function handleSubmit(e) { + e.preventDefault(); + if (!firstName) { setError('Must input first name') return @@ -133,7 +135,7 @@ export default function Profile() { { user && user.nickName ? <> - +