diff --git a/src/components/creation/CreateABHAAddress.jsx b/src/components/creation/CreateABHAAddress.jsx index 715e87f..fa1d1f0 100644 --- a/src/components/creation/CreateABHAAddress.jsx +++ b/src/components/creation/CreateABHAAddress.jsx @@ -1,7 +1,7 @@ import React, {useState} from "react"; import './creation.scss'; import Spinner from "../spinner/spinner"; -import {checkIfABHAAddressExists, createABHAAddress} from "../../api/hipServiceApi"; +import {checkIfABHAAddressExists, createABHAAddress, createDefaultHealthId} from "../../api/hipServiceApi"; import Footer from "./Footer"; import {cmSuffixProperty} from "../../api/constants"; @@ -35,6 +35,7 @@ const CreateABHAAddress = (props) => { if (response.data === undefined) { processingError(response); } else { + setNewAbhaAddress(newAbhaAddress.concat(cmSuffix)); props.setABHAAddressCreated(true); } } @@ -51,6 +52,20 @@ const CreateABHAAddress = (props) => { } } + async function createDefault() { + setLoader(true); + setError(''); + const response = await createDefaultHealthId(); + if (response.data !== undefined) { + props.setABHAAddressCreated(true); + setNewAbhaAddress(response.data.healthId); + } + else { + setError(response.details[0].message || response.message) + } + setLoader(false); + } + function processingError(response){ if (response.details !== undefined && response.details.length > 0) setError(response.details[0].message) @@ -64,28 +79,32 @@ const CreateABHAAddress = (props) => { return (
-
-
- -
-
- - {cmSuffix} -
+
+ +
+
+ + {cmSuffix}
-
- - Preferred -
-

Click on the check box to make the above abha-address as a default

- {error !== '' &&
{error}
} - {loader && } -
- -
-
+
+ + Preferred +
+

Click on the check box to make the above abha-address as a default

+ {error !== '' &&
{error}
} +
+ +
+
+ OR +
+
+ +
+ {loader && } +
); } diff --git a/src/components/creation/LinkABHAAddress.jsx b/src/components/creation/LinkABHAAddress.jsx index 245f210..39541bb 100644 --- a/src/components/creation/LinkABHAAddress.jsx +++ b/src/components/creation/LinkABHAAddress.jsx @@ -3,7 +3,7 @@ import './creation.scss'; import PatientDetails from "../patient-details/patientDetails"; import VerifyMobileEmail from "./VerifyMobileEmail"; import CreateABHAAddress from "./CreateABHAAddress"; -import {cmSuffixProperty, enableLinkABHAAddress} from "../../api/constants"; +import {enableLinkABHAAddress} from "../../api/constants"; import CheckIdentifierExists from "../Common/CheckIdentifierExists"; import {fetchGlobalProperty} from "../../api/hipServiceApi"; @@ -22,8 +22,6 @@ const LinkABHAAddress = (props) => { const [healthNumberAlreadyLinked, setHealthNumberAlreadyLinked] = useState(false); let isLinkingEnabled; const refEls = useRef({}); - - const cmSuffix = localStorage.getItem(cmSuffixProperty) function onProceed() { mapPatient(); @@ -65,7 +63,7 @@ const LinkABHAAddress = (props) => { function mapPatient(){ - props.mappedPatient.id = abhaAddressCreated ? newAbhaAddress.concat(cmSuffix) : abhaAddress; + props.mappedPatient.id = abhaAddressCreated ? newAbhaAddress : abhaAddress; } function gotoLink(){ diff --git a/src/components/creation/creation.scss b/src/components/creation/creation.scss index dd0888a..c23bc6b 100644 --- a/src/components/creation/creation.scss +++ b/src/components/creation/creation.scss @@ -46,6 +46,11 @@ color: red; margin-top: 0px; } + + .create-default-healthId { + margin-left: 40%; + margin-top: 5% + } } button {