diff --git a/frontend/app/components/modules/FaceEnrollment/FaceEnrollment.tsx b/frontend/app/components/modules/FaceEnrollment/FaceEnrollment.tsx index 893b76ed..9c9bacce 100644 --- a/frontend/app/components/modules/FaceEnrollment/FaceEnrollment.tsx +++ b/frontend/app/components/modules/FaceEnrollment/FaceEnrollment.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useEffect, useState } from 'react' import Image from 'next/image' import { Color } from '../../../types/elements' import { Cam } from '../Cam/Cam' @@ -45,6 +45,12 @@ export const FaceEnrollment = ({ openModal, payload, nextStep }: Props) => { } ] + useEffect(() => { + if (localStorage.getItem(ENROLL_SNAPSHOT)) { + localStorage.removeItem(ENROLL_SNAPSHOT) + } + }, []) + const getPhoto = () => { const photo = localStorage.getItem(ENROLL_SNAPSHOT) if (session_id && photo) { diff --git a/frontend/app/components/modules/PaymentPay/PaymentPay.tsx b/frontend/app/components/modules/PaymentPay/PaymentPay.tsx index 6ac7ff9a..43924f2f 100644 --- a/frontend/app/components/modules/PaymentPay/PaymentPay.tsx +++ b/frontend/app/components/modules/PaymentPay/PaymentPay.tsx @@ -58,6 +58,14 @@ export const PaymentPay = ({ paymentAccountInfo.minimum_payment ]) + // To ensure localStorage stays empty + // when user refresh the page + useEffect(() => { + if (localStorage.getItem(FACE_MATCH_LIVENESS_SNAPSHOT)) { + localStorage.removeItem(FACE_MATCH_LIVENESS_SNAPSHOT) + } + }, []) + const checkPhone = () => { if (paymentAccountInfo.phone !== phone) { setPhoneError('Your phone number does not match with the registered one') diff --git a/frontend/app/components/templates/EkycPage/EkycPage.tsx b/frontend/app/components/templates/EkycPage/EkycPage.tsx index 7cd33865..8e453e07 100644 --- a/frontend/app/components/templates/EkycPage/EkycPage.tsx +++ b/frontend/app/components/templates/EkycPage/EkycPage.tsx @@ -1,5 +1,5 @@ import { parseCookies } from 'nookies' -import { useState } from 'react' +import { useEffect, useState } from 'react' import { postActivities } from '../../../api/activitiesAPI' import { Color } from '../../../types/elements' import { Button } from '../../elements/Button/Button' @@ -34,6 +34,17 @@ export const EkycPage = ({ serviceId, name, longDesc }: Props) => { const [result, setResult] = useState() const [loading, setLoading] = useState(true) + // To ensure localStorage stays empty + // when user refresh the page + useEffect(() => { + if (localStorage.getItem(FL_LOCAL_STORAGE)) { + localStorage.removeItem(FL_LOCAL_STORAGE) + } + if (localStorage.getItem(KTP_LOCAL_STORAGE)) { + localStorage.removeItem(KTP_LOCAL_STORAGE) + } + }, []) + const createVisitorActivities = async ( serviceId: number, sessionId: string,