From 0ae2f506fb9fc1d9ffdb21c8a56bffdbf3b15351 Mon Sep 17 00:00:00 2001 From: prakharlowanshi Date: Wed, 17 Jun 2026 18:28:48 +0530 Subject: [PATCH] fix the retry --- .../src/app/otp/component/register/register.component.ts | 4 ++++ apps/36-blocks-widget/src/app/otp/model/otp.ts | 1 + apps/36-blocks-widget/src/app/otp/service/otp.service.ts | 6 ++++++ apps/36-blocks-widget/src/app/otp/service/urls/otp-urls.ts | 1 + .../src/app/otp/store/effects/otp.effects.ts | 5 ++++- 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/36-blocks-widget/src/app/otp/component/register/register.component.ts b/apps/36-blocks-widget/src/app/otp/component/register/register.component.ts index 679c3165..206b1c45 100644 --- a/apps/36-blocks-widget/src/app/otp/component/register/register.component.ts +++ b/apps/36-blocks-widget/src/app/otp/component/register/register.component.ts @@ -630,6 +630,7 @@ export class RegisterComponent extends BaseComponent implements AfterViewInit, O return; } const currentEmail = emailControl.value; + const isIdentifierChanged = currentEmail !== this.lastSentEmail; if (isResend && currentEmail !== this.lastSentEmail) { this.stopResendTimer('email'); this.canResendEmailOtp = true; @@ -644,6 +645,7 @@ export class RegisterComponent extends BaseComponent implements AfterViewInit, O request: { referenceId: this.referenceId(), identifier: currentEmail, + useRetry: isResend && !isIdentifierChanged, }, }) ); @@ -664,6 +666,7 @@ export class RegisterComponent extends BaseComponent implements AfterViewInit, O return; } const currentMobile = mobileControl.value; + const isIdentifierChanged = currentMobile !== this.lastSentMobileNumber; if (isResend && currentMobile !== this.lastSentMobileNumber) { this.stopResendTimer('mobile'); this.canResendOtp = true; @@ -678,6 +681,7 @@ export class RegisterComponent extends BaseComponent implements AfterViewInit, O request: { referenceId: this.referenceId(), identifier: currentMobile, + useRetry: isResend && !isIdentifierChanged, }, }) ); diff --git a/apps/36-blocks-widget/src/app/otp/model/otp.ts b/apps/36-blocks-widget/src/app/otp/model/otp.ts index b4713413..bd5f3cbd 100644 --- a/apps/36-blocks-widget/src/app/otp/model/otp.ts +++ b/apps/36-blocks-widget/src/app/otp/model/otp.ts @@ -34,6 +34,7 @@ export interface ISendOtpReq { origin?: string; variables?: any; authToken?: string; + useRetry?: boolean; } export interface IRetryOtpReq extends ISendOtpReq { diff --git a/apps/36-blocks-widget/src/app/otp/service/otp.service.ts b/apps/36-blocks-widget/src/app/otp/service/otp.service.ts index 4d55a550..f669c097 100644 --- a/apps/36-blocks-widget/src/app/otp/service/otp.service.ts +++ b/apps/36-blocks-widget/src/app/otp/service/otp.service.ts @@ -63,6 +63,12 @@ export class OtpService { const body = { identifier: request.identifier ?? request.mobile }; return this.http.post(otpVerificationUrls.sendOtp(this.baseUrl), body, this.options); } + + public retryOtp(request: ISendOtpReq): Observable { + this.setOtpRequestHeaders(request); + const body = { identifier: request.identifier ?? request.mobile }; + return this.http.post(otpVerificationUrls.retryOtp(this.baseUrl), body, this.options); + } public verifyOtpV2(request: IVerifyOtpV2Req): Observable { this.setOtpRequestHeaders(request); const body = { diff --git a/apps/36-blocks-widget/src/app/otp/service/urls/otp-urls.ts b/apps/36-blocks-widget/src/app/otp/service/urls/otp-urls.ts index 05f0f564..376b7626 100644 --- a/apps/36-blocks-widget/src/app/otp/service/urls/otp-urls.ts +++ b/apps/36-blocks-widget/src/app/otp/service/urls/otp-urls.ts @@ -3,6 +3,7 @@ import { createUrl } from '@proxy/service'; export const otpVerificationUrls = { getWidgetData: (baseUrl) => createUrl(baseUrl, ':referenceId/widget'), sendOtp: (baseUrl) => createUrl(baseUrl, 'otp/send'), + retryOtp: (baseUrl) => createUrl(baseUrl, 'otp/retry'), verifyOtpV2: (baseUrl) => createUrl(baseUrl, 'otp/verify'), verifyOtp: (baseUrl) => createUrl(baseUrl, 'widget/verifyOtp'), resend: (baseUrl) => createUrl(baseUrl, 'widget/retryOtp'), diff --git a/apps/36-blocks-widget/src/app/otp/store/effects/otp.effects.ts b/apps/36-blocks-widget/src/app/otp/store/effects/otp.effects.ts index db99301f..c38e6eea 100644 --- a/apps/36-blocks-widget/src/app/otp/store/effects/otp.effects.ts +++ b/apps/36-blocks-widget/src/app/otp/store/effects/otp.effects.ts @@ -55,7 +55,10 @@ export class OtpEffects { this.actions$.pipe( ofType(otpActions.sendOtpAction), switchMap((p) => { - return this.otpService.sendOtp(p.request).pipe( + const otpRequest$ = p.request?.useRetry + ? this.otpService.retryOtp(p.request) + : this.otpService.sendOtp(p.request); + return otpRequest$.pipe( map((res: OtpResModel) => { if (res.type !== 'error') { return otpActions.sendOtpActionComplete({