From e5bdb2b37fb3246ce30c8165f7eccc9304062dd8 Mon Sep 17 00:00:00 2001 From: William Fu Date: Thu, 3 Feb 2022 13:58:53 +0700 Subject: [PATCH 1/3] fix: local storage on face enrollment --- .../components/modules/FaceEnrollment/FaceEnrollment.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) { From 3fbb8f84b5fd6a81f29d61bc7ac0049fb35f249d Mon Sep 17 00:00:00 2001 From: William Fu Date: Thu, 3 Feb 2022 13:59:10 +0700 Subject: [PATCH 2/3] fix: local storage on ekyc solution --- .../app/components/templates/EkycPage/EkycPage.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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, From ad79f154082934a6cb0a3628c5fbc39f81ed4be7 Mon Sep 17 00:00:00 2001 From: William Fu Date: Thu, 3 Feb 2022 13:59:41 +0700 Subject: [PATCH 3/3] fix: localstorage on payment completion --- frontend/app/components/modules/PaymentPay/PaymentPay.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) 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')