diff --git a/components/AuthSubmitButton.tsx b/components/AuthSubmitButton.tsx deleted file mode 100644 index 434d0af..0000000 --- a/components/AuthSubmitButton.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { IconProp } from "@fortawesome/fontawesome-svg-core"; - -type Props = { - onClick?: Function; - icon?: IconProp; - label: string; - loading: boolean; - className?: string; -}; - -export default function AuthSubmitButton({ - onClick, - icon, - label, - loading, - className, -}: Props) { - return ( - - ); -} diff --git a/components/SubmitButton.tsx b/components/SubmitButton.tsx index 8a06eac..6ee0a78 100644 --- a/components/SubmitButton.tsx +++ b/components/SubmitButton.tsx @@ -2,11 +2,12 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { IconProp } from "@fortawesome/fontawesome-svg-core"; type Props = { - onClick: Function; + onClick?: Function; icon?: IconProp; label: string; loading: boolean; className?: string; + type?: "button" | "submit" | "reset" | undefined; }; export default function SubmitButton({ @@ -15,20 +16,22 @@ export default function SubmitButton({ label, loading, className, + type, }: Props) { return ( -
{ - if (!loading) onClick(); + if (!loading && onClick) onClick(); }} > - {icon && } -

{label}

-
+ {icon && } +

{label}

+ ); } diff --git a/pages/choose-username.tsx b/pages/choose-username.tsx index 75d6aa0..1b4d9be 100644 --- a/pages/choose-username.tsx +++ b/pages/choose-username.tsx @@ -1,6 +1,6 @@ import SubmitButton from "@/components/SubmitButton"; import { signOut } from "next-auth/react"; -import { useState } from "react"; +import { FormEvent, useState } from "react"; import { toast } from "react-hot-toast"; import { useSession } from "next-auth/react"; import useAccountStore from "@/store/account"; @@ -15,7 +15,9 @@ export default function ChooseUsername() { const { updateAccount, account } = useAccountStore(); - async function submitUsername() { + async function submitUsername(event: FormEvent) { + event.preventDefault(); + setSubmitLoader(true); const redirectionToast = toast.loading("Applying..."); @@ -38,50 +40,53 @@ export default function ChooseUsername() { return ( -
-

- Choose a Username (Last step) -

- -
-

- Username +

+
+

+ Choose a Username (Last step)

- setInputedUsername(e.target.value)} +
+

+ Username +

+ + setInputedUsername(e.target.value)} + /> +
+
+

+ Feel free to reach out to us at{" "} + + support@linkwarden.app + {" "} + in case of any issues. +

+
+ + -
-
-

- Feel free to reach out to us at{" "} - - support@linkwarden.app - {" "} - in case of any issues. -

-
- - -
signOut()} - className="w-fit mx-auto cursor-pointer text-gray-500 dark:text-gray-400 font-semibold " - > - Sign Out +
signOut()} + className="w-fit mx-auto cursor-pointer text-gray-500 dark:text-gray-400 font-semibold " + > + Sign Out +
-
+ ); } diff --git a/pages/forgot.tsx b/pages/forgot.tsx index eb60eb7..d2fc8c7 100644 --- a/pages/forgot.tsx +++ b/pages/forgot.tsx @@ -3,7 +3,7 @@ import TextInput from "@/components/TextInput"; import CenteredForm from "@/layouts/CenteredForm"; import { signIn } from "next-auth/react"; import Link from "next/link"; -import { useState } from "react"; +import { FormEvent, useState } from "react"; import { toast } from "react-hot-toast"; interface FormData { @@ -17,7 +17,9 @@ export default function Forgot() { email: "", }); - async function loginUser() { + async function sendConfirmation(event: FormEvent) { + event.preventDefault(); + if (form.email !== "") { setSubmitLoader(true); @@ -40,49 +42,52 @@ export default function Forgot() { return ( -
-

- Password Recovery -

-
-

- Enter your Email so we can send you a link to recover your account. - Make sure to change your password in the profile settings - afterwards. -

-

- You wont get logged in if you haven't created an account yet. -

-
-
-

- Email +

+
+

+ Password Recovery

+
+

+ Enter your Email so we can send you a link to recover your + account. Make sure to change your password in the profile settings + afterwards. +

+

+ You wont get logged in if you haven't created an account yet. +

+
+
+

+ Email +

- setForm({ ...form, email: e.target.value })} + setForm({ ...form, email: e.target.value })} + /> +
+ + +
+ + Go back + +
- - -
- - Go back - -
-
+ ); } diff --git a/pages/login.tsx b/pages/login.tsx index 3c39284..6c9c402 100644 --- a/pages/login.tsx +++ b/pages/login.tsx @@ -5,7 +5,6 @@ import { signIn } from "next-auth/react"; import Link from "next/link"; import { useState, FormEvent } from "react"; import { toast } from "react-hot-toast"; -import AuthSubmitButton from "@/components/AuthSubmitButton"; interface FormData { username: string; @@ -95,14 +94,18 @@ export default function Login() { )}
- - {process.env.NEXT_PUBLIC_DISABLE_REGISTRATION === "true" ? undefined : ( + {process.env.NEXT_PUBLIC_DISABLE_REGISTRATION === + "true" ? undefined : (
-

New here?

+

+ New here? +

-

- Enter your details -

-
-

- Display Name +

+ Enter your details

- - setForm({ ...form, name: e.target.value })} - /> -
- - {emailEnabled ? undefined : (

- Username + Display Name

setForm({ ...form, username: e.target.value })} + onChange={(e) => setForm({ ...form, name: e.target.value })} />
- )} - {emailEnabled ? ( -
-

- Email + {emailEnabled ? undefined : ( +

+

+ Username +

+ + + setForm({ ...form, username: e.target.value }) + } + /> +
+ )} + + {emailEnabled ? ( +
+

+ Email +

+ + setForm({ ...form, email: e.target.value })} + /> +
+ ) : undefined} + +
+

+ Password

setForm({ ...form, email: e.target.value })} + onChange={(e) => setForm({ ...form, password: e.target.value })} />
- ) : undefined} -
-

- Password -

- - setForm({ ...form, password: e.target.value })} - /> -
- -
-

- Confirm Password -

- - - setForm({ ...form, passwordConfirmation: e.target.value }) - } - /> -
- - {process.env.NEXT_PUBLIC_STRIPE_IS_ACTIVE ? ( -
-

- By signing up, you agree to our{" "} - - Terms of Service - {" "} - and{" "} - - Privacy Policy - - . -

-

- Need help?{" "} - - Get in touch - - . +

+

+ Confirm Password

+ + + setForm({ ...form, passwordConfirmation: e.target.value }) + } + />
- ) : undefined} - -
-

- Already have an account? -

- - Login - + {process.env.NEXT_PUBLIC_STRIPE_IS_ACTIVE ? ( +
+

+ By signing up, you agree to our{" "} + + Terms of Service + {" "} + and{" "} + + Privacy Policy + + . +

+

+ Need help?{" "} + + Get in touch + + . +

+
+ ) : undefined} + + +
+

+ Already have an account? +

+ + Login + +
-
)}