diff --git a/src/auth/SignInForm.tsx b/src/auth/SignInForm.tsx index c2c36a72..aa686618 100644 --- a/src/auth/SignInForm.tsx +++ b/src/auth/SignInForm.tsx @@ -4,12 +4,14 @@ import FieldSetWithStatus from '@/components/FieldSetWithStatus'; import InfoBlock from '@/components/InfoBlock'; import SubmitButtonWithStatus from '@/components/SubmitButtonWithStatus'; import { useEffect, useLayoutEffect, useRef, useState } from 'react'; -import { getCurrentUser, signInAction } from './actions'; +import { getAuthAction, signInAction } from './actions'; import { useFormState } from 'react-dom'; import ErrorNote from '@/components/ErrorNote'; import { KEY_CALLBACK_URL, KEY_CREDENTIALS_SIGN_IN_ERROR } from '.'; import { useSearchParams } from 'next/navigation'; import { useAppState } from '@/state/AppState'; +import { clsx } from 'clsx/lite'; +import { FiLock } from 'react-icons/fi'; export default function SignInForm() { const params = useSearchParams(); @@ -28,7 +30,8 @@ export default function SignInForm() { useEffect(() => { return () => { // Capture user email before unmounting - getCurrentUser().then(user => setUserEmail?.(user?.email ?? undefined)); + getAuthAction().then(auth => + setUserEmail?.(auth?.user?.email ?? undefined)); }; }, [setUserEmail]); @@ -37,14 +40,29 @@ export default function SignInForm() { password.length > 0; return ( - -
-
+ +

+ + + Sign in + +

+ +
{response === KEY_CREDENTIALS_SIGN_IN_ERROR && Invalid email/password } -
+
signOut({ redirectTo: PATH_ROOT }); -export const getCurrentUser = async () => (await auth())?.user; +export const getAuthAction = () => auth(); diff --git a/src/components/FieldSetWithStatus.tsx b/src/components/FieldSetWithStatus.tsx index 6f152b12..bf8de66d 100644 --- a/src/components/FieldSetWithStatus.tsx +++ b/src/components/FieldSetWithStatus.tsx @@ -140,7 +140,11 @@ export default function FieldSetWithStatus({ autoCapitalize={!capitalize ? 'off' : undefined} readOnly={readOnly || pending || loading} className={clsx( - type === 'text' && 'w-full', + ( + type === 'text' || + type === 'email' || + type === 'password' + ) && 'w-full', Boolean(error) && 'error', )} />} diff --git a/src/components/primitives/LoaderButton.tsx b/src/components/primitives/LoaderButton.tsx index 1abc4993..6011fbe7 100644 --- a/src/components/primitives/LoaderButton.tsx +++ b/src/components/primitives/LoaderButton.tsx @@ -26,9 +26,12 @@ export default function LoaderButton(props: { type={type} className={clsx( className, - styleAsLink - ? 'link h-4 hover:text-dim active:text-medium' - : 'h-9', + ...(styleAsLink + ? [ + 'link h-4 hover:text-dim active:text-medium', + 'disabled:!bg-transparent', + ] + : ['h-9']), 'inline-flex items-center gap-2 self-start', )} disabled={isLoading || disabled} diff --git a/src/site/Footer.tsx b/src/site/Footer.tsx index f874bc62..3572d60d 100644 --- a/src/site/Footer.tsx +++ b/src/site/Footer.tsx @@ -41,7 +41,7 @@ export default function Footer() { {isPathAdmin(pathname) ? <> {userEmail === undefined && - } + } {userEmail && <>
setSwrTimestamp(Date.now()), []); - const { data } = useSWR('getCurrentUser', getCurrentUser); - useEffect(() => setUserEmail(data?.email ?? undefined), [data]); + const { data } = useSWR('getAuth', getAuthAction); + useEffect(() => setUserEmail(data?.user?.email ?? undefined), [data]); const registerAdminUpdate = useCallback(() => setAdminUpdateTimes(updates => [...updates, new Date()])