From 510294192e5df502923ef9549999fdd3e0d570dd Mon Sep 17 00:00:00 2001 From: Matt Casey Date: Thu, 10 Oct 2024 14:24:54 -0500 Subject: [PATCH] dont disable button (#4785) --- .../common/WarpcastLogin/FarcasterModal.tsx | 8 +++--- .../WarpcastLogin/WarpcastLoginButton.tsx | 26 ++++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/apps/scoutgame/components/common/WarpcastLogin/FarcasterModal.tsx b/apps/scoutgame/components/common/WarpcastLogin/FarcasterModal.tsx index eaf4e921fe..8eecfbabc1 100644 --- a/apps/scoutgame/components/common/WarpcastLogin/FarcasterModal.tsx +++ b/apps/scoutgame/components/common/WarpcastLogin/FarcasterModal.tsx @@ -6,7 +6,7 @@ import { Paper } from '@mui/material'; import Box from '@mui/material/Box'; import Link from '@mui/material/Link'; import type { ModalProps } from '@mui/material/Modal'; -import Modal from '@mui/material/Modal'; +import Dialog from '@mui/material/Modal'; import Typography from '@mui/material/Typography'; const sx = { @@ -21,9 +21,9 @@ const sx = { borderRadius: 3 }; -export function FarcasterLoginModal({ url, ...props }: Omit & { url?: string }) { +export function FarcasterLoginModal({ url, open, onClose }: Omit & { url?: string }) { return ( - + Sign in with Farcaster @@ -39,6 +39,6 @@ export function FarcasterLoginModal({ url, ...props }: Omit - + ); } diff --git a/apps/scoutgame/components/common/WarpcastLogin/WarpcastLoginButton.tsx b/apps/scoutgame/components/common/WarpcastLogin/WarpcastLoginButton.tsx index ef07d2ad3c..f81ae4ec92 100644 --- a/apps/scoutgame/components/common/WarpcastLogin/WarpcastLoginButton.tsx +++ b/apps/scoutgame/components/common/WarpcastLogin/WarpcastLoginButton.tsx @@ -6,10 +6,10 @@ import { useProfile } from '@farcaster/auth-kit'; import type { StatusAPIResponse, AuthClientError } from '@farcaster/auth-kit'; import type { ButtonProps } from '@mui/material'; import { Box, Button, Typography } from '@mui/material'; -import { usePopupState } from 'material-ui-popup-state/hooks'; +import { usePopupState, bindPopover } from 'material-ui-popup-state/hooks'; import { useRouter, useSearchParams } from 'next/navigation'; import { useAction } from 'next-safe-action/hooks'; -import { useCallback } from 'react'; +import { useCallback, useState } from 'react'; import { LoadingComponent } from 'components/common/Loading/LoadingComponent'; import { useFarcasterConnection } from 'hooks/useFarcasterConnection'; @@ -73,7 +73,11 @@ export function WarpcastLoginButton({ children, ...props }: ButtonProps) { popupState.open(); }, []); - const { signIn, url } = useFarcasterConnection({ + const { + signIn, + url, + error: connectionError + } = useFarcasterConnection({ onSuccess: onSuccessCallback, onError: onErrorCallback, onClick @@ -87,16 +91,19 @@ export function WarpcastLoginButton({ children, ...props }: ButtonProps) { ); } - const errorMessage = result?.serverError?.message?.includes('private beta') - ? 'Scout Game is in private beta' - : 'There was an error while logging in'; + const errorMessage = + (connectionError && connectionError.message) || + (hasErrored && + (result?.serverError?.message?.includes('private beta') + ? 'Scout Game is in private beta' + : 'There was an error while logging in')); return ( - {hasErrored && ( + {errorMessage && ( {errorMessage} )} - popupState.close()} url={url} /> + ); }