mirror of
https://github.com/neynarxyz/create-farcaster-mini-app.git
synced 2025-11-16 08:08:56 -05:00
Fix:auto redirect
This commit is contained in:
parent
c7583b2ffe
commit
5724c92b88
@ -118,9 +118,9 @@ export function AuthDialog({
|
|||||||
const content = getStepContent();
|
const content = getStepContent();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm">
|
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm p-4">
|
||||||
<div className="bg-white dark:bg-gray-800 rounded-xl p-6 max-w-md mx-4 shadow-2xl border border-gray-200 dark:border-gray-700">
|
<div className="bg-white dark:bg-gray-800 rounded-xl w-full max-w-md shadow-2xl border border-gray-200 dark:border-gray-700 max-h-[80vh] sm:max-h-[90vh] flex flex-col">
|
||||||
<div className="flex justify-between items-center mb-4">
|
<div className="flex justify-between items-center p-4 sm:p-6 pb-3 sm:pb-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0">
|
||||||
<h2 className="text-lg font-semibold text-gray-900 dark:text-gray-100">
|
<h2 className="text-lg font-semibold text-gray-900 dark:text-gray-100">
|
||||||
{isError ? 'Error' : content.title}
|
{isError ? 'Error' : content.title}
|
||||||
</h2>
|
</h2>
|
||||||
@ -144,73 +144,75 @@ export function AuthDialog({
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{isError ? (
|
<div className="flex-1 overflow-y-auto p-4 sm:p-6 pt-3 sm:pt-4 min-h-0">
|
||||||
<div className="text-center">
|
{isError ? (
|
||||||
<div className="text-red-600 dark:text-red-400 mb-4">
|
<div className="text-center">
|
||||||
{error?.message || 'Unknown error, please try again.'}
|
<div className="text-red-600 dark:text-red-400 mb-4">
|
||||||
|
{error?.message || 'Unknown error, please try again.'}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
) : (
|
||||||
) : (
|
<div className="text-center">
|
||||||
<div className="text-center">
|
<div className="mb-6">
|
||||||
<div className="mb-6">
|
{typeof content.description === 'string' ? (
|
||||||
{typeof content.description === 'string' ? (
|
<p className="text-gray-600 dark:text-gray-400">
|
||||||
<p className="text-gray-600 dark:text-gray-400">
|
{content.description}
|
||||||
{content.description}
|
</p>
|
||||||
</p>
|
) : (
|
||||||
) : (
|
content.description
|
||||||
content.description
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-6 flex justify-center">
|
||||||
|
{content.showQR && content.qrUrl ? (
|
||||||
|
<div className="p-4 bg-white rounded-lg">
|
||||||
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
|
<img
|
||||||
|
src={`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(
|
||||||
|
content.qrUrl
|
||||||
|
)}`}
|
||||||
|
alt="QR Code"
|
||||||
|
className="w-48 h-48"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : step === 'loading' || isLoading ? (
|
||||||
|
<div className="w-48 h-48 flex items-center justify-center bg-gray-50 dark:bg-gray-700 rounded-lg">
|
||||||
|
<div className="flex flex-col items-center gap-3">
|
||||||
|
<div className="spinner w-8 h-8" />
|
||||||
|
<span className="text-sm text-gray-500 dark:text-gray-400">
|
||||||
|
{step === 'loading'
|
||||||
|
? 'Setting up access...'
|
||||||
|
: 'Loading...'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{content.showOpenButton && content.qrUrl && (
|
||||||
|
<button
|
||||||
|
onClick={() =>
|
||||||
|
window.open(
|
||||||
|
content.qrUrl
|
||||||
|
.replace(
|
||||||
|
'https://farcaster.xyz/',
|
||||||
|
'https://client.farcaster.xyz/deeplinks/'
|
||||||
|
)
|
||||||
|
.replace(
|
||||||
|
'https://client.farcaster.xyz/deeplinks/',
|
||||||
|
'farcaster://'
|
||||||
|
),
|
||||||
|
'_blank'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className="btn btn-outline flex items-center justify-center gap-2 w-full"
|
||||||
|
>
|
||||||
|
I'm using my phone →
|
||||||
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
<div className="mb-6 flex justify-center">
|
</div>
|
||||||
{content.showQR && content.qrUrl ? (
|
|
||||||
<div className="p-4 bg-white rounded-lg">
|
|
||||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
||||||
<img
|
|
||||||
src={`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(
|
|
||||||
content.qrUrl
|
|
||||||
)}`}
|
|
||||||
alt="QR Code"
|
|
||||||
className="w-48 h-48"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
) : step === 'loading' || isLoading ? (
|
|
||||||
<div className="w-48 h-48 flex items-center justify-center bg-gray-50 dark:bg-gray-700 rounded-lg">
|
|
||||||
<div className="flex flex-col items-center gap-3">
|
|
||||||
<div className="spinner w-8 h-8" />
|
|
||||||
<span className="text-sm text-gray-500 dark:text-gray-400">
|
|
||||||
{step === 'loading'
|
|
||||||
? 'Setting up access...'
|
|
||||||
: 'Loading...'}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{content.showOpenButton && content.qrUrl && (
|
|
||||||
<button
|
|
||||||
onClick={() =>
|
|
||||||
window.open(
|
|
||||||
content.qrUrl
|
|
||||||
.replace(
|
|
||||||
'https://farcaster.xyz/',
|
|
||||||
'https://client.farcaster.xyz/deeplinks/'
|
|
||||||
)
|
|
||||||
.replace(
|
|
||||||
'https://client.farcaster.xyz/deeplinks/',
|
|
||||||
'farcaster://'
|
|
||||||
),
|
|
||||||
'_blank'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
className="btn btn-outline flex items-center justify-center gap-2 w-full"
|
|
||||||
>
|
|
||||||
I'm using my phone →
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -378,7 +378,7 @@ export function NeynarAuthButton() {
|
|||||||
}
|
}
|
||||||
// For backend flow, the session will be handled by NextAuth
|
// For backend flow, the session will be handled by NextAuth
|
||||||
},
|
},
|
||||||
[useBackendFlow]
|
[useBackendFlow, fetchUserData]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Error callback
|
// Error callback
|
||||||
@ -538,12 +538,7 @@ export function NeynarAuthButton() {
|
|||||||
setDialogStep('signin');
|
setDialogStep('signin');
|
||||||
setShowDialog(true);
|
setShowDialog(true);
|
||||||
frontendSignIn();
|
frontendSignIn();
|
||||||
|
}, [isError, reconnect, frontendSignIn]);
|
||||||
// Open mobile app if on mobile and URL is available
|
|
||||||
if (url && isMobile()) {
|
|
||||||
window.open(url, '_blank');
|
|
||||||
}
|
|
||||||
}, [isError, reconnect, frontendSignIn, url]);
|
|
||||||
|
|
||||||
const handleSignOut = useCallback(async () => {
|
const handleSignOut = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user