Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,13 @@
"verify_bio": "Verify Biometrics",
"capture_fingerprint": "Capture Fingerprint",
"initiate_face_auth": "Initiate Face Authentication",
"retry_face_auth": "Retry Face Authentication"
"retry_face_auth": "Retry Face Authentication",
"error_verifying_aadhaar_demographics": "Error verifying Aadhaar demographics.",
"error_verifying_aadhaar_face": "Error verifying Aadhaar face.",
"error_capturing_pid_via_face": "Error capturing PID via face.",
"error_linking_abha_number": "Error linking ABHA number.",
"otp_sent_successfully": "OTP has been sent successfully.",
"otp_verified_successfully": "OTP has been verified successfully.",
"otp_resend_successfully": "OTP has been resend successfully.",
"abha_address_created_successfully": "ABHA Address has been created successfully."
}
15 changes: 11 additions & 4 deletions src/components/ConfigureHealthFacilityForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { GenerateScanAndShareQR } from "./GenerateScanAndShareQR";
import { HealthFacility } from "@/types/healthFacility";
import { I18NNAMESPACE } from "@/lib/constants";
import { Input } from "@/components/ui/input";
import { Meta } from "@/types/meta";
import { apis } from "@/apis";
import { toast } from "@/lib/utils";
import { useForm } from "react-hook-form";
Expand All @@ -34,6 +35,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
type ConfigureHealthFacilityFormProps = {
facilityId: string;
onSuccess?: (data: HealthFacility) => void;
meta?: Meta;
};

const configureHealthFacilityFormSchema = z.object({
Expand All @@ -44,9 +46,11 @@ type ConfigureHealthFacilityFormValues = z.infer<
typeof configureHealthFacilityFormSchema
>;

export const ConfigureHealthFacilityForm: FC<
ConfigureHealthFacilityFormProps
> = ({ facilityId, onSuccess }) => {
export const ConfigureHealthFacilityForm: FC<ConfigureHealthFacilityFormProps> = ({
facilityId,
onSuccess,
meta,
}) => {
const { t } = useTranslation(I18NNAMESPACE);

const { data: healthFacility, refetch } = useQuery({
Expand Down Expand Up @@ -221,7 +225,10 @@ export const ConfigureHealthFacilityForm: FC<
</Form>

{healthFacility && (
<GenerateScanAndShareQR healthFacilityId={healthFacility.hf_id} />
<GenerateScanAndShareQR
healthFacilityId={healthFacility.hf_id}
scanAndShareUrl={meta?.config?.scanAndShareUrl}
/>
)}
</div>
);
Expand Down
7 changes: 4 additions & 3 deletions src/components/GenerateScanAndShareQR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import { Button } from "./ui/button";
import { I18NNAMESPACE } from "@/lib/constants";
import { Input } from "@/components/ui/input";
import { QRCodeSVG } from "qrcode.react";
import { scanAndShareUrl } from "@/config";
import { useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";

type GenerateScanAndShareQRProps = {
healthFacilityId: string;
scanAndShareUrl?: string;
};

const scanAndShareQrFormSchema = z.object({
Expand All @@ -29,6 +29,7 @@ const scanAndShareQrFormSchema = z.object({

export const GenerateScanAndShareQR: FC<GenerateScanAndShareQRProps> = ({
healthFacilityId,
scanAndShareUrl,
}) => {
const { t } = useTranslation(I18NNAMESPACE);

Expand Down Expand Up @@ -84,7 +85,7 @@ export const GenerateScanAndShareQR: FC<GenerateScanAndShareQRProps> = ({
document.body.removeChild(downloadLink);
};

function onSubmit(_values: z.infer<typeof scanAndShareQrFormSchema>) {
function onSubmit() {
downloadQR();
}

Expand Down Expand Up @@ -135,7 +136,7 @@ export const GenerateScanAndShareQR: FC<GenerateScanAndShareQRProps> = ({
/>
</form>

{!!scanAndShareQrForm.watch("counterName") && (
{!!scanAndShareQrForm.watch("counterName") && scanAndShareQrValue && (
<div className="grid gap-3 items-center justify-center w-full">
<QRCodeSVG
value={scanAndShareQrValue}
Expand Down
50 changes: 37 additions & 13 deletions src/components/LinkAbhaNumber/CreateWithAadhaar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import { QRCodeSVG } from "qrcode.react";
import { Textarea } from "@/components/ui/textarea";
import { apis } from "@/apis";
import { cn } from "@/lib/utils";
import { faceAuthUrl } from "@/config";
import { toast } from "@/lib/utils";
import { useForm } from "react-hook-form";
import { useLinkAbhaNumberContext } from ".";
Expand Down Expand Up @@ -168,6 +167,8 @@ const EnterAadhaar: FC<EnterAadhaarProps> = ({ setMemory, goTo }) => {
const { t } = useTranslation(I18NNAMESPACE);
const { healthFacility, currentUser } = useLinkAbhaNumberContext();

const faceAuthUrl = window.__CARE_PLUGIN_RUNTIME__?.meta?.care_abdm_fe?.config?.faceAuthUrl;

const form = useForm<EnterAadhaarFormValues>({
resolver: zodResolver(enterAadhaarFormSchema),
defaultValues: {
Expand All @@ -182,11 +183,18 @@ const EnterAadhaar: FC<EnterAadhaarProps> = ({ setMemory, goTo }) => {
},
});

const handleCheckAllDisclaimers = () => {
Array.from({ length: 6 }).forEach((_, index) => {
const fieldName = `disclaimer_${index + 1}` as keyof EnterAadhaarFormValues;
form.setValue(fieldName, true, { shouldValidate: true });
});
};

const sendAadhaarOtpMutation = useMutation({
mutationFn: apis.healthId.abhaCreateSendAadhaarOtp,
onSuccess: (data) => {
if (data) {
toast.success(data.detail);
toast.success(data.detail || t("otp_sent_successfully"));
setMemory((prev) => ({
...prev,
transactionId: data.transaction_id,
Expand Down Expand Up @@ -293,6 +301,20 @@ const EnterAadhaar: FC<EnterAadhaarProps> = ({ setMemory, goTo }) => {
)}
/>
))}

<div className="flex justify-end">
<Button
type="button"
variant="outline"
size="sm"
onClick={(e) => {
e.stopPropagation();
handleCheckAllDisclaimers();
}}
>
Check all terms
</Button>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-2">
<Button
type="submit"
Expand Down Expand Up @@ -342,7 +364,7 @@ const EnterAadhaar: FC<EnterAadhaarProps> = ({ setMemory, goTo }) => {
>
{t("verify_with_bio")}
</Button>
<Button
{faceAuthUrl && <Button
type="button"
variant="default"
disabled={!form.formState.isValid}
Expand All @@ -358,7 +380,7 @@ const EnterAadhaar: FC<EnterAadhaarProps> = ({ setMemory, goTo }) => {
className="w-full"
>
{t("verify_with_face")}
</Button>
</Button>}
</div>
</form>
</Form>
Expand Down Expand Up @@ -405,7 +427,7 @@ const VerifyAadhaarWithOtp: FC<VerifyAadhaarWithOtpProps> = ({
mutationFn: apis.healthId.abhaCreateVerifyAadhaarOtp,
onSuccess: (data) => {
if (data) {
toast.success(data.detail);
toast.success(data.detail || t("otp_verified_successfully"));
setMemory((prev) => ({
...prev,
transactionId: data.transaction_id,
Expand All @@ -421,7 +443,7 @@ const VerifyAadhaarWithOtp: FC<VerifyAadhaarWithOtpProps> = ({
mutationFn: apis.healthId.abhaCreateSendAadhaarOtp,
onSuccess: (data) => {
if (data) {
toast.success(data.detail);
toast.success(data.detail || t("otp_resend_successfully"));
form.setValue("otp", "");
setMemory((prev) => ({
...prev,
Expand Down Expand Up @@ -620,7 +642,7 @@ const VerifyAadhaarWithDemographics: FC<VerifyAadhaarWithDemographicsProps> = ({
form.setError("_aadhaar", {
message: error.message,
});
toast.error(error.message);
toast.error(error.message || t("error_verifying_aadhaar_demographics"));
},
});

Expand Down Expand Up @@ -894,6 +916,7 @@ const VerifyAadhaarWithFace: FC<VerifyAadhaarWithFaceProps> = ({
}) => {
const { t } = useTranslation(I18NNAMESPACE);
const [isPolling, setIsPolling] = useState(false);
const faceAuthUrl = window?.__CARE_PLUGIN_RUNTIME__?.meta?.care_abdm_fe?.config?.faceAuthUrl;

const form = useForm<VerifyAadhaarWithFaceFormValues>({
resolver: zodResolver(verifyAadhaarWithFaceFormSchema),
Expand Down Expand Up @@ -923,7 +946,7 @@ const VerifyAadhaarWithFace: FC<VerifyAadhaarWithFaceProps> = ({
}
},
onError: (error) => {
toast.error(error.message);
toast.error(error.message || t("error_verifying_aadhaar_face"));
setMemory((prev) => ({
...prev,
transactionId: "",
Expand Down Expand Up @@ -963,7 +986,7 @@ const VerifyAadhaarWithFace: FC<VerifyAadhaarWithFaceProps> = ({
...prev,
error: error.message,
}));
toast.error(error.message);
toast.error(error.message || t("error_capturing_pid_via_face"));
},
});

Expand All @@ -990,6 +1013,7 @@ const VerifyAadhaarWithFace: FC<VerifyAadhaarWithFaceProps> = ({
}
}, [isPolling]);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
function onSubmit(_values: VerifyAadhaarWithFaceFormValues) {
authInitViaFaceMutation.mutate();
}
Expand Down Expand Up @@ -1423,7 +1447,7 @@ const LinkMobile: FC<LinkMobileProps> = ({ memory, setMemory, goTo }) => {
mutationFn: apis.healthId.abhaCreateLinkMobileNumber,
onSuccess: (data) => {
if (data) {
toast.success(data.detail);
toast.success(data.detail || t("otp_sent_successfully"));
setMemory((prev) => ({
...prev,
transactionId: data.transaction_id,
Expand Down Expand Up @@ -1511,7 +1535,7 @@ const VerifyMobile: FC<VerifyMobileProps> = ({ memory, setMemory, goTo }) => {
mutationFn: apis.healthId.abhaCreateVerifyMobileNumber,
onSuccess: (data) => {
if (data) {
toast.success(data.detail);
toast.success(data.detail || t("otp_verified_successfully"));
setMemory((prev) => ({
...prev,
transactionId: data.transaction_id,
Expand All @@ -1525,7 +1549,7 @@ const VerifyMobile: FC<VerifyMobileProps> = ({ memory, setMemory, goTo }) => {
mutationFn: apis.healthId.abhaCreateLinkMobileNumber,
onSuccess: (data) => {
if (data) {
toast.success(data.detail);
toast.success(data.detail || t("otp_resend_successfully"));
form.setValue("otp", "");
setMemory((prev) => ({
...prev,
Expand Down Expand Up @@ -1714,7 +1738,7 @@ export const ChooseAbhaAddress: FC<ChooseAbhaAddressProps> = ({
transactionId: data.transaction_id,
abhaNumber: data.abha_number,
}));
toast.success("ABHA Address created successfully");
toast.success(t("abha_address_created_successfully"));
goTo("show-abha-profile");
}
},
Expand Down
31 changes: 26 additions & 5 deletions src/components/LinkAbhaNumber/LinkWithOtp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import { Input } from "@/components/ui/input";
import { apis } from "@/apis";
import { toast } from "@/lib/utils";
import { useForm } from "react-hook-form";
import { useLinkAbhaNumberContext } from ".";
import { useMutation } from "@tanstack/react-query";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import { useLinkAbhaNumberContext } from ".";

type LinkWithOtpProps = {
onSuccess: (abhaNumber: AbhaNumber) => void;
Expand Down Expand Up @@ -113,7 +113,7 @@ const enterIdFormSchema = z.object({

type EnterIdFormValues = z.infer<typeof enterIdFormSchema>;

const EnterId: FC<EnterIdProps> = ({ memory, setMemory, goTo }) => {
const EnterId: FC<EnterIdProps> = ({ setMemory, goTo }) => {
const { t } = useTranslation(I18NNAMESPACE);
const { currentUser } = useLinkAbhaNumberContext();

Expand All @@ -134,6 +134,13 @@ const EnterId: FC<EnterIdProps> = ({ memory, setMemory, goTo }) => {
},
});

const handleCheckAllDisclaimers = () => {
Array.from({ length: 5 }).forEach((_, index) => {
const fieldName = `disclaimer_${index + 1}` as keyof EnterIdFormValues;
form.setValue(fieldName, true, { shouldValidate: true });
});
};

const checkAuthMethodsMutation = useMutation({
mutationFn: apis.healthId.abhaLoginCheckAuthMethods,
onSuccess: (data) => {
Expand Down Expand Up @@ -170,7 +177,7 @@ const EnterId: FC<EnterIdProps> = ({ memory, setMemory, goTo }) => {
mutationFn: apis.healthId.abhaLoginSendOtp,
onSuccess: (data) => {
if (data) {
toast.success(data.detail);
toast.success(data.detail || t("otp_sent_successfully"));
setMemory((prev) => ({
...prev,
transactionId: data.transaction_id,
Expand Down Expand Up @@ -249,6 +256,20 @@ const EnterId: FC<EnterIdProps> = ({ memory, setMemory, goTo }) => {
/>
))}

<div className="flex justify-end">
<Button
type="button"
variant="outline"
size="sm"
onClick={(e) => {
e.stopPropagation();
handleCheckAllDisclaimers();
}}
>
Check all terms
</Button>
</div>

<Popover
open={showAuthMethods}
onOpenChange={(open) => !open && setShowAuthMethods(false)}
Expand Down Expand Up @@ -339,7 +360,7 @@ const VerifyId: FC<VerifyIdProps> = ({ memory, setMemory, onSuccess }) => {
mutationFn: apis.healthId.abhaLoginVerifyOtp,
onSuccess: (data) => {
if (data) {
toast.success(t("verify_otp_success"));
toast.success(t("otp_verified_successfully"));
onSuccess(data.abha_number);
}
},
Expand All @@ -349,7 +370,7 @@ const VerifyId: FC<VerifyIdProps> = ({ memory, setMemory, onSuccess }) => {
mutationFn: apis.healthId.abhaLoginSendOtp,
onSuccess: (data) => {
if (data) {
toast.success(data.detail);
toast.success(data.detail || t("otp_resend_successfully"));
form.setValue("otp", "");
setMemory((prev) => ({
...prev,
Expand Down
5 changes: 2 additions & 3 deletions src/components/TokenSearchDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from "@/components/ui/dialog";
import { FC, useMemo, useState } from "react";

import { ArrowRightIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Patient } from "@/types/patient";
Expand Down Expand Up @@ -124,14 +123,14 @@ const PatientCard: FC<{ patient: Patient }> = ({ patient }) => {
return (
<div
onClick={() => {
navigate("patients/verify", {
navigate("patients/home", {
query: {
phone_number: patient.phone_number,
year_of_birth: yearOfBirth,
partial_id: patient.partial_id || patient.id.slice(0, 5),
},
});
}}
}}
className="border rounded-md p-4 cursor-pointer"
>
<div className="flex items-center justify-between">
Expand Down
3 changes: 2 additions & 1 deletion src/components/pluggables/EncounterActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Button } from "@/components/ui/button";
import CreateConsentRequestForm from "../CreateConsentRequestForm";
import { Encounter } from "@/types/encounter";
import { I18NNAMESPACE } from "@/lib/constants";
import { WithMeta } from "@/types/meta";
import { apis } from "@/apis";
import { cn } from "@/lib/utils";
import { useTranslation } from "react-i18next";
Expand All @@ -22,7 +23,7 @@ type EncounterActionsProps = {
className?: string;
};

const EncounterActions: FC<EncounterActionsProps> = ({
const EncounterActions: FC<WithMeta<EncounterActionsProps>> = ({
encounter,
className,
}) => {
Expand Down
Loading
Loading