From 72d875aa4f1652b04543eae5f478be30e106587a Mon Sep 17 00:00:00 2001 From: Pablo Lara Date: Fri, 4 Oct 2024 16:08:57 +0200 Subject: [PATCH] chore: WIP --- components/auth/AuthButton.tsx | 21 -------------- .../auth/{AuthForm.tsx => auth-form.tsx} | 29 +++++++++++++++++-- components/auth/index.ts | 3 +- components/ui/custom/custom-button.tsx | 16 ++++++++-- tailwind.config.js | 1 + 5 files changed, 42 insertions(+), 28 deletions(-) delete mode 100644 components/auth/AuthButton.tsx rename components/auth/{AuthForm.tsx => auth-form.tsx} (89%) diff --git a/components/auth/AuthButton.tsx b/components/auth/AuthButton.tsx deleted file mode 100644 index 0eda81782a..0000000000 --- a/components/auth/AuthButton.tsx +++ /dev/null @@ -1,21 +0,0 @@ -"use client"; - -import { Button, CircularProgress } from "@nextui-org/react"; -import React from "react"; -import { useFormStatus } from "react-dom"; - -export const AuthButton = ({ type }: { type: string }) => { - const { pending } = useFormStatus(); - - return ( - - ); -}; diff --git a/components/auth/AuthForm.tsx b/components/auth/auth-form.tsx similarity index 89% rename from components/auth/AuthForm.tsx rename to components/auth/auth-form.tsx index 5b6b8402e7..18391d44d4 100644 --- a/components/auth/AuthForm.tsx +++ b/components/auth/auth-form.tsx @@ -20,8 +20,8 @@ import { authFormSchema } from "@/types"; import { NotificationIcon, ProwlerExtended } from "../icons"; import { ThemeSwitch } from "../ThemeSwitch"; -import { CustomInput } from "../ui/custom"; -import { AuthButton } from "./AuthButton"; +import { CustomButton, CustomInput } from "../ui/custom"; +// import { AuthButton } from "./AuthButton"; export const AuthForm = ({ type }: { type: string }) => { const formSchema = authFormSchema(type); @@ -39,8 +39,12 @@ export const AuthForm = ({ type }: { type: string }) => { }, }); + const isLoading = form.formState.isSubmitting; + const [state, dispatch] = useFormState(authenticate, undefined); + console.log(isLoading, state); + useEffect(() => { if (state?.message === "Success") { router.push("/"); @@ -185,7 +189,26 @@ export const AuthForm = ({ type }: { type: string }) => { )} - + {isLoading &&

Loading...

} + + + {isLoading ? ( + Loading + ) : ( + {type === "sign-in" ? "Log In" : "Sign Up"} + )} + diff --git a/components/auth/index.ts b/components/auth/index.ts index 26161c473c..82fc6feefa 100644 --- a/components/auth/index.ts +++ b/components/auth/index.ts @@ -1,2 +1 @@ -export * from "./AuthButton"; -export * from "./AuthForm"; +export * from "./auth-form"; diff --git a/components/ui/custom/custom-button.tsx b/components/ui/custom/custom-button.tsx index 32287a76c6..ca266275b2 100644 --- a/components/ui/custom/custom-button.tsx +++ b/components/ui/custom/custom-button.tsx @@ -8,7 +8,7 @@ export const buttonClasses = { base: "px-4 inline-flex items-center justify-center relative z-0 text-center whitespace-nowrap", primary: "bg-default-100 hover:bg-default-200 text-default-800", secondary: "bg-prowler-grey-light dark:bg-prowler-grey-medium text-white", - action: "text-white bg-prowler-blue-smoky dark:bg-prowler-grey-medium", + action: "text-white bg-prowler-grey-medium dark:bg-prowler-grey-medium", dashed: "border border-default border-dashed bg-transparent justify-center whitespace-nowrap font-medium shadow-sm hover:border-solid hover:bg-default-100 active:bg-default-200 active:border-solid", transparent: "border-0 border-transparent bg-transparent", @@ -19,6 +19,7 @@ export const buttonClasses = { interface ButtonProps { type?: "button" | "submit" | "reset"; ariaLabel: string; + ariaDisabled?: boolean; className?: string; variant?: | "solid" @@ -52,6 +53,7 @@ interface ButtonProps { export const CustomButton = ({ type = "button", ariaLabel, + ariaDisabled, className, variant = "solid", color = "primary", @@ -69,6 +71,7 @@ export const CustomButton = ({