Skip to content

Commit

Permalink
fix: Add type guards for verifiedName and remove UI blocking delay
Browse files Browse the repository at this point in the history
- Add proper type checking for verifiedName throughout component
- Remove 15-second artificial delay causing UI performance issues
- Add fallback text when verifiedName is undefined
- Improve error handling for verification process
  • Loading branch information
devin-ai-integration[bot] committed Nov 17, 2024
1 parent 5f9ae54 commit 8f01818
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions components/EventAttendanceVerification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ const EventAttendanceVerification: React.FC<EventAttendanceVerificationProps> =
)
);

// Add a minimum delay for the drumroll effect (15 seconds)
await new Promise(resolve => setTimeout(resolve, 15000));
if (ethGlobalBrusselsPoap) {
console.log('Found ETHGlobal Brussels POAP:', ethGlobalBrusselsPoap);
setPoapDetails(ethGlobalBrusselsPoap);
Expand All @@ -74,7 +72,7 @@ const EventAttendanceVerification: React.FC<EventAttendanceVerificationProps> =
role,
date: ethGlobalBrusselsPoap.event.start_date,
venue: EVENT_VENUE,
verifiedName: verifiedName,
verifiedName: typeof verifiedName === 'string' && verifiedName.length > 0 ? verifiedName : 'Unknown User',
tokenId: ethGlobalBrusselsPoap.tokenId
};

Expand Down Expand Up @@ -116,12 +114,22 @@ const EventAttendanceVerification: React.FC<EventAttendanceVerificationProps> =
{!hasAnswered ? (
<div className="text-center">
<p className="text-base-content/70 mb-6">
Hello {verifiedName}, did you attend ETHGlobal Brussels in person?
{typeof verifiedName === 'string' && verifiedName.length > 0 ? (
<>Hello {verifiedName}, did you attend ETHGlobal Brussels in person?</>
) : (
<>Did you attend ETHGlobal Brussels in person?</>
)}
</p>
<div className="flex justify-center gap-4">
<button
className="btn btn-primary"
onClick={() => handleAttendanceResponse(true)}
onClick={() => {
if (typeof verifiedName !== 'string' || verifiedName.length === 0) {
setError('User verification required before proceeding');
return;
}
handleAttendanceResponse(true);
}}
>
Yes, I attended
</button>
Expand All @@ -146,7 +154,11 @@ const EventAttendanceVerification: React.FC<EventAttendanceVerificationProps> =
) : (
<>
<p className="text-base-content/70 mb-4">
Hello {verifiedName}, we're checking your attendance at ETHGlobal Brussels.
{typeof verifiedName === 'string' && verifiedName.length > 0 ? (
<>Hello {verifiedName}, we're checking your attendance at ETHGlobal Brussels.</>
) : (
<>We're checking your attendance at ETHGlobal Brussels.</>
)}
</p>

{isVerifying && (
Expand Down

0 comments on commit 8f01818

Please sign in to comment.