From c6ca4a0bb3c09cbc5cefa8b10115578217f16df1 Mon Sep 17 00:00:00 2001 From: Rob Harding Date: Fri, 16 Jun 2023 09:41:43 -0400 Subject: [PATCH 1/4] Fix modal nav --- src/components/SignIn.tsx | 9 ++++++++- src/components/SignUp.tsx | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/SignIn.tsx b/src/components/SignIn.tsx index d935a9b8..514f52c4 100644 --- a/src/components/SignIn.tsx +++ b/src/components/SignIn.tsx @@ -1,8 +1,11 @@ import { Icons } from '@/components/Icons' import UserAuthForm from '@/components/UserAuthForm' import Link from 'next/link' +import {useRouter} from 'next/navigation'; const SignIn = () => { + const router = useRouter(); + return (
@@ -18,7 +21,11 @@ const SignIn = () => { New to Breaddit?{' '} + className='hover:text-brand text-sm underline underline-offset-4' + onClick={(e) => { + e.preventDefault(); + router.replace('/sign-up'); + }}> Sign Up

diff --git a/src/components/SignUp.tsx b/src/components/SignUp.tsx index a0057793..0c06290e 100644 --- a/src/components/SignUp.tsx +++ b/src/components/SignUp.tsx @@ -1,8 +1,11 @@ import { Icons } from '@/components/Icons' import UserAuthForm from '@/components/UserAuthForm' import Link from 'next/link' +import {useRouter} from 'next/navigation'; const SignUp = () => { + const router = useRouter(); + return (
@@ -18,7 +21,11 @@ const SignUp = () => { Already a Breadditor?{' '} + className='hover:text-brand text-sm underline underline-offset-4' + onClick={(e) => { + e.preventDefault(); + router.replace('/sign-in'); + }}> Sign in

From 3f2b09533d13f9a5ed0e2f3fc5c61506fb3d1d95 Mon Sep 17 00:00:00 2001 From: Rob Harding Date: Fri, 16 Jun 2023 09:46:39 -0400 Subject: [PATCH 2/4] make signup and signin client components --- src/components/SignIn.tsx | 2 ++ src/components/SignUp.tsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/components/SignIn.tsx b/src/components/SignIn.tsx index 514f52c4..58d1be43 100644 --- a/src/components/SignIn.tsx +++ b/src/components/SignIn.tsx @@ -1,3 +1,5 @@ +"use client"; + import { Icons } from '@/components/Icons' import UserAuthForm from '@/components/UserAuthForm' import Link from 'next/link' diff --git a/src/components/SignUp.tsx b/src/components/SignUp.tsx index 0c06290e..6fc5c645 100644 --- a/src/components/SignUp.tsx +++ b/src/components/SignUp.tsx @@ -1,3 +1,5 @@ +"use client"; + import { Icons } from '@/components/Icons' import UserAuthForm from '@/components/UserAuthForm' import Link from 'next/link' From 51d2db2d41a70d082d2edefe099fdc31e80c1a2b Mon Sep 17 00:00:00 2001 From: Rob Harding Date: Fri, 16 Jun 2023 10:07:33 -0400 Subject: [PATCH 3/4] Fix navigation when starting from page --- src/app/@authModal/(.)sign-in/page.tsx | 2 +- src/app/@authModal/(.)sign-up/page.tsx | 2 +- src/components/SignIn.tsx | 13 +++++++++++-- src/components/SignUp.tsx | 15 ++++++++++++--- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/app/@authModal/(.)sign-in/page.tsx b/src/app/@authModal/(.)sign-in/page.tsx index 1c84498a..0ec96a4a 100644 --- a/src/app/@authModal/(.)sign-in/page.tsx +++ b/src/app/@authModal/(.)sign-in/page.tsx @@ -11,7 +11,7 @@ const page: FC = () => {
- +
diff --git a/src/app/@authModal/(.)sign-up/page.tsx b/src/app/@authModal/(.)sign-up/page.tsx index a33eb809..30f72425 100644 --- a/src/app/@authModal/(.)sign-up/page.tsx +++ b/src/app/@authModal/(.)sign-up/page.tsx @@ -13,7 +13,7 @@ const page: FC = ({}) => { - + diff --git a/src/components/SignIn.tsx b/src/components/SignIn.tsx index 58d1be43..72bf32cc 100644 --- a/src/components/SignIn.tsx +++ b/src/components/SignIn.tsx @@ -1,11 +1,16 @@ "use client"; +import { FC } from 'react' import { Icons } from '@/components/Icons' import UserAuthForm from '@/components/UserAuthForm' import Link from 'next/link' import {useRouter} from 'next/navigation'; -const SignIn = () => { +interface SignInProps { + isModal?: boolean; +} + +const SignIn: FC = ({ isModal = false }) => { const router = useRouter(); return ( @@ -26,7 +31,11 @@ const SignIn = () => { className='hover:text-brand text-sm underline underline-offset-4' onClick={(e) => { e.preventDefault(); - router.replace('/sign-up'); + if(isModal) { + router.replace('/sign-up'); + } else { + router.push('/sign-up'); + } }}> Sign Up diff --git a/src/components/SignUp.tsx b/src/components/SignUp.tsx index 6fc5c645..d33b5c93 100644 --- a/src/components/SignUp.tsx +++ b/src/components/SignUp.tsx @@ -1,11 +1,16 @@ "use client"; +import { FC } from 'react' import { Icons } from '@/components/Icons' import UserAuthForm from '@/components/UserAuthForm' import Link from 'next/link' -import {useRouter} from 'next/navigation'; +import {useRouter} from 'next/navigation' -const SignUp = () => { +interface SignUpProps { + isModal?: boolean; +} + +const SignUp: Fc = ({ isModal = false }) => { const router = useRouter(); return ( @@ -26,7 +31,11 @@ const SignUp = () => { className='hover:text-brand text-sm underline underline-offset-4' onClick={(e) => { e.preventDefault(); - router.replace('/sign-in'); + if(isModal) { + router.replace('/sign-in'); + } else { + router.push('/sign-in'); + } }}> Sign in From 4ac063095095b47360358a69698c78a732470944 Mon Sep 17 00:00:00 2001 From: Rob Harding Date: Mon, 19 Jun 2023 09:03:58 -0400 Subject: [PATCH 4/4] use replace instead of onClick --- src/components/SignIn.tsx | 13 ++--------- src/components/SignUp.tsx | 45 ++++++++++++++++----------------------- 2 files changed, 20 insertions(+), 38 deletions(-) diff --git a/src/components/SignIn.tsx b/src/components/SignIn.tsx index 72bf32cc..f1f85097 100644 --- a/src/components/SignIn.tsx +++ b/src/components/SignIn.tsx @@ -4,15 +4,12 @@ import { FC } from 'react' import { Icons } from '@/components/Icons' import UserAuthForm from '@/components/UserAuthForm' import Link from 'next/link' -import {useRouter} from 'next/navigation'; interface SignInProps { isModal?: boolean; } const SignIn: FC = ({ isModal = false }) => { - const router = useRouter(); - return (
@@ -29,14 +26,8 @@ const SignIn: FC = ({ isModal = false }) => { { - e.preventDefault(); - if(isModal) { - router.replace('/sign-up'); - } else { - router.push('/sign-up'); - } - }}> + replace={isModal} + }> Sign Up

diff --git a/src/components/SignUp.tsx b/src/components/SignUp.tsx index d33b5c93..1c74635d 100644 --- a/src/components/SignUp.tsx +++ b/src/components/SignUp.tsx @@ -1,47 +1,38 @@ "use client"; -import { FC } from 'react' -import { Icons } from '@/components/Icons' -import UserAuthForm from '@/components/UserAuthForm' -import Link from 'next/link' -import {useRouter} from 'next/navigation' +import { FC } from "react"; +import { Icons } from "@/components/Icons"; +import UserAuthForm from "@/components/UserAuthForm"; +import Link from "next/link"; interface SignUpProps { isModal?: boolean; } const SignUp: Fc = ({ isModal = false }) => { - const router = useRouter(); - return ( -
-
- -

Sign Up

-

+

+
+ +

Sign Up

+

By continuing, you are setting up a Breadit account and agree to our User Agreement and Privacy Policy.

-

- Already a Breadditor?{' '} +

+ Already a Breadditor?{" "} { - e.preventDefault(); - if(isModal) { - router.replace('/sign-in'); - } else { - router.push('/sign-in'); - } - }}> + href="/sign-in" + className="hover:text-brand text-sm underline underline-offset-4" + replace={isModal} + > Sign in

- ) -} + ); +}; -export default SignUp +export default SignUp;