-
Notifications
You must be signed in to change notification settings - Fork 56
feat: implement unified failure-state UX system for privacy and blockchain edge cases #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Simultech369
wants to merge
1
commit into
BuidlZone-Labs:main
Choose a base branch
from
Simultech369:feat/failure-state-ux-system
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,9 @@ import { useCooldown } from "@/hooks/useCooldown"; | |
| import { CooldownMessage } from "@/app/components/AntiSpam/CooldownMessage"; | ||
| import { TransactionStatusBanner } from "@/components/TransactionStatusBanner"; | ||
| import type { TransactionStatus } from "@/hooks/useTransactionStatus"; | ||
| import { useFailureState } from "@/hooks/useFailureState"; | ||
| import { FailureStateModal } from "@/components/FailureStateModal"; | ||
| import { FailureStateBanner } from "@/components/FailureStateBanner"; | ||
|
|
||
| type PaymentStatus = "idle" | "processing" | "failed"; | ||
|
|
||
|
|
@@ -90,6 +93,32 @@ export const TicketInfo: FC<TicketInfoProps> = ({ | |
|
|
||
| const { isOnCooldown, remainingSeconds, startCooldown } = useCooldown({ duration: 8 }); | ||
|
|
||
| const { | ||
| failureState, | ||
| isOpen: isFailureModalOpen, | ||
| triggerFailure, | ||
| clearFailure, | ||
| downloadDiagnostics, | ||
| } = useFailureState(); | ||
|
|
||
| useEffect(() => { | ||
| if (hasPaymentFailed && paymentError) { | ||
| triggerFailure(paymentError, { | ||
| customMessage: paymentError, | ||
| technicalDetails: `Checkout payment failed for event ${eventId}.`, | ||
| }); | ||
| } else if (txState.status === "failed" && txState.error) { | ||
| triggerFailure(txState.error, { | ||
| txHash: txState.txHash, | ||
| technicalDetails: `Transaction failed after ${txState.attempts} polling attempts.`, | ||
| }); | ||
| } else if (walletState.error) { | ||
| triggerFailure(walletState.error, { | ||
| technicalDetails: `Wallet connection error during checkout.`, | ||
| }); | ||
| } | ||
| }, [hasPaymentFailed, paymentError, txState.status, txState.error, walletState.error, triggerFailure, eventId, txState.txHash, txState.attempts]); | ||
|
|
||
| const intervalRef = useRef<NodeJS.Timeout | null>(null); | ||
|
|
||
| const stopPolling = () => { | ||
|
|
@@ -413,13 +442,12 @@ export const TicketInfo: FC<TicketInfoProps> = ({ | |
| {/* Cooldown message */} | ||
| <CooldownMessage remainingSeconds={remainingSeconds} /> | ||
|
|
||
| {/* Payment error from parent (e.g. sold out, reconcile failure) */} | ||
| {hasPaymentFailed && txState.status === "idle" && ( | ||
| <div className="bg-[#FFF2F2] border border-[#FBCACA] text-[#B42318] py-3 px-5 rounded-lg"> | ||
| <p className="text-xs font-medium"> | ||
| {paymentError ?? "Payment failed. Please retry."} | ||
| </p> | ||
| </div> | ||
| {/* Unified Failure State Banner for payment failure */} | ||
| {hasPaymentFailed && failureState && txState.status === "idle" && ( | ||
| <FailureStateBanner | ||
| failureState={failureState} | ||
| onRetry={handleRetry} | ||
| /> | ||
|
Comment on lines
+445
to
+450
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Use a shared close-and-retry path.
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| )} | ||
|
|
||
| <div className="bg-[#F2FFF2] dark:bg-[#131313] dark:text-[#0BD330] text-[#0ABA2A] py-3 px-5 gap-4 flex"> | ||
|
|
@@ -452,12 +480,23 @@ export const TicketInfo: FC<TicketInfoProps> = ({ | |
| <>{buttonLabel()}</> | ||
| )} | ||
| </button> | ||
| {walletState.error && ( | ||
| <p className="mt-2 text-sm text-red-500">{walletState.error}</p> | ||
| {walletState.error && failureState && ( | ||
| <div className="mt-3"> | ||
| <FailureStateBanner failureState={failureState} onRetry={handleRetry} /> | ||
| </div> | ||
| )} | ||
| </div> | ||
| </fieldset> | ||
| </form> | ||
|
|
||
| {/* Unified Failure State Modal */} | ||
| <FailureStateModal | ||
| isOpen={isFailureModalOpen} | ||
| onClose={clearFailure} | ||
| failureState={failureState} | ||
| onRetry={handleRetry} | ||
| onDownloadDiagnostics={downloadDiagnostics} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Keep source errors in the shared diagnostic payload. Supplying static
technicalDetailsoverridesuseFailureState’s normal error serialization, so users and support lose the actual failure cause.app/components/explore/EventCheckout/TicketInfo.tsx#L104-L118: append the sanitized payment, transaction, or wallet error to the contextual diagnostic string.app/components/organizer/ConnectWalletPrompt.tsx#L28-L34: append the sanitized wallet SDK error to the contextual diagnostic string.📍 Affects 2 files
app/components/explore/EventCheckout/TicketInfo.tsx#L104-L118(this comment)app/components/organizer/ConnectWalletPrompt.tsx#L28-L34🤖 Prompt for AI Agents