From df758d2927035a227e9aa9c0fffb8e5c20c6d68d Mon Sep 17 00:00:00 2001 From: Khavin Shankar Date: Wed, 17 Jan 2024 22:24:20 +0530 Subject: [PATCH] Improve Abha linking process (#7000) --- src/Components/ABDM/LinkABHANumberModal.tsx | 95 ++++++++++++--------- src/Components/Common/components/Menu.tsx | 6 +- 2 files changed, 61 insertions(+), 40 deletions(-) diff --git a/src/Components/ABDM/LinkABHANumberModal.tsx b/src/Components/ABDM/LinkABHANumberModal.tsx index f5da5fedfb9..47b29b805ae 100644 --- a/src/Components/ABDM/LinkABHANumberModal.tsx +++ b/src/Components/ABDM/LinkABHANumberModal.tsx @@ -55,7 +55,7 @@ export default function LinkABHANumberModal({ ...props }: Props) { const [currentStep, setCurrentStep] = useState("AadhaarVerification"); - const [transactionId, setTransactionId] = useState("sds"); + const [transactionId, setTransactionId] = useState(""); const title = (
@@ -73,9 +73,6 @@ export default function LinkABHANumberModal({
{currentStep === "ScanExistingQR" && ( { - setCurrentStep("AadhaarVerification"); - }} patientId={patientId} onSuccess={onSuccess} closeModal={props.onClose} @@ -88,9 +85,6 @@ export default function LinkABHANumberModal({ setTransactionId(transactionId); setCurrentStep("MobileVerification"); }} - onSignin={() => { - setCurrentStep("ScanExistingQR"); - }} /> )} @@ -116,19 +110,37 @@ export default function LinkABHANumberModal({ /> )}
+ +
+ {["AadhaarVerification", "MobileVerification", "HealthIDCreation"].find( + (step) => step === currentStep + ) ? ( +

setCurrentStep("ScanExistingQR")} + className="cursor-pointer text-center text-sm text-blue-800" + > + Already have an ABHA number +

+ ) : ( +

setCurrentStep("AadhaarVerification")} + className="cursor-pointer text-center text-sm text-blue-800" + > + Don't have an ABHA Number +

+ )} +
); } interface ScanABHAQRSectionProps { - onSignup: () => void; patientId?: string; onSuccess?: (abha: any) => void; closeModal: () => void; } const ScanABHAQRSection = ({ - onSignup, patientId, onSuccess, closeModal, @@ -155,15 +167,18 @@ const ScanABHAQRSection = ({ return (
{ - if ([2, 7, 12].includes(value.length)) { - if (qrValue.length && qrValue[qrValue.length - 1] === "-") { - value.slice(value.length - 1); - } else { - value += "-"; + if (value[0] && !isNaN(Number(value[0]))) { + // 92-1234-1234-1234 + if ([2, 7, 12].includes(value.length)) { + if (qrValue.length && qrValue[qrValue.length - 1] === "-") { + value.slice(value.length - 1); + } else { + value += "-"; + } } } setQrValue(value); @@ -230,16 +245,11 @@ const ScanABHAQRSection = ({ error="" /> )} -
- - Don't have an ABHA Number - +
<> {txnId ? ( { let response = null; @@ -299,9 +309,14 @@ const ScanABHAQRSection = ({ Link ) : authMethods.length ? ( - + {authMethods.map((method) => ( { const { res, data } = await request( routes.abha.initiateAbdmAuthentication, @@ -321,6 +336,7 @@ const ScanABHAQRSection = ({ ) : ( { const { res, data } = await request( routes.abha.searchByHealthId, @@ -353,13 +369,9 @@ const ScanABHAQRSection = ({ interface VerifyAadhaarSectionProps { onVerified: (transactionId: string) => void; - onSignin: () => void; } -const VerifyAadhaarSection = ({ - onVerified, - onSignin, -}: VerifyAadhaarSectionProps) => { +const VerifyAadhaarSection = ({ onVerified }: VerifyAadhaarSectionProps) => { const [aadhaarNumber, setAadhaarNumber] = useState(""); const [aadhaarNumberError, setAadhaarNumberError] = useState(); @@ -563,15 +575,10 @@ const VerifyAadhaarSection = ({ /> )} -
- - Already have an ABHA number - +
<> {otpSent && ( - + {(verified && "Verified") || (isVerifyingOtp ? "Verifying..." : "Verify")} @@ -736,8 +747,9 @@ const VerifyMobileSection = ({

)} -
+
{otpDispatched && ( - + {(verified && "Verified") || (isVerifyingOtp ? "Verifying..." : "Verify")} @@ -831,8 +847,9 @@ const CreateHealthIDSection = ({
)} -
+
+