Fix navigation in disclose result related screens (#1964)

* Fix navigation in disclose result related screens

* coderabbit comments
This commit is contained in:
Seshanth.S
2026-04-14 00:46:09 +05:30
committed by GitHub
parent f348c3e6bf
commit d861bed826
2 changed files with 21 additions and 24 deletions

View File

@@ -21,14 +21,6 @@ export const TunnelProofReceiptScreen: React.FC = () => {
const { backPath = '/tunnel/proof/result', backState } =
(location.state as { backPath?: string; backState?: Record<string, unknown> } | null) ?? {};
const showConfirm = backPath !== '/tunnel/proof/result' || backState?.success === true;
const onConfirm = useCallback(() => {
haptic.trigger('selection');
analytics.trackEvent('tunnel_proof_receipt_confirmed');
navigate('/tunnel/proof/disclose');
}, [navigate, haptic, analytics]);
const proofItems = useMemo(() => {
if (displayLabels && displayLabels.length > 0) {
return displayLabels.map(label => ({ label }));
@@ -49,7 +41,6 @@ export const TunnelProofReceiptScreen: React.FC = () => {
{...WEB_SAFE_AREA}
variant="default"
onClose={onClose}
onConfirm={showConfirm ? onConfirm : undefined}
appIcon={<SelfLogo size={40} />}
appName={appName}
appEndpoint={appEndpoint}

View File

@@ -31,18 +31,6 @@ const getTunnelBackPath = (source: TunnelResultState['source']): string => {
}
};
const getTunnelClosePath = (source: TunnelResultState['source']): string => {
switch (source) {
case 'disclose':
return '/tunnel/proof/disclose';
case 'kyc':
return '/tunnel/kyc';
case 'proving':
default:
return '/tunnel/tour/4';
}
};
export const TunnelResultScreen: React.FC = () => {
const navigate = useNavigate();
const location = useLocation();
@@ -84,9 +72,27 @@ export const TunnelResultScreen: React.FC = () => {
});
}, [location.pathname, location.state, navigate]);
const onCancel = useCallback(() => {
navigate(getTunnelClosePath(source), { replace: true });
}, [navigate, source]);
const onCancel = useCallback(async () => {
try {
const result: VerificationResult = {
success: false,
userId: request.userId,
verificationId,
error: {
code: 'VERIFICATION_FAILED',
message: error ?? 'Verification failed',
},
};
await lifecycle.setResult(result);
analytics.trackEvent('tunnel_result_cancelled', { source });
lifecycle.dismiss();
} catch (err) {
analytics.trackEvent('tunnel_result_cancel_failed', {
error: err instanceof Error ? err.message : 'Failed to send cancel result',
});
lifecycle.dismiss();
}
}, [request.userId, verificationId, error, lifecycle, analytics, source]);
if (success) {
return (