From 1602cff06e13bb03e5c48e8369abf5c803426e4d Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Mon, 30 Oct 2023 09:53:40 +0700
Subject: Add set auth on authenticated

---
 src-migrate/modules/account-activation/components/FormOTP.tsx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'src-migrate/modules/account-activation/components/FormOTP.tsx')

diff --git a/src-migrate/modules/account-activation/components/FormOTP.tsx b/src-migrate/modules/account-activation/components/FormOTP.tsx
index e38fa8fe..a4775d61 100644
--- a/src-migrate/modules/account-activation/components/FormOTP.tsx
+++ b/src-migrate/modules/account-activation/components/FormOTP.tsx
@@ -5,6 +5,7 @@ import { useEffect, useState } from "react"
 import { useMutation } from "react-query"
 import { useCountdown } from "usehooks-ts"
 import Modal from '~/common/components/elements/Modal'
+import { setAuth } from "~/common/libs/auth"
 import { ActivationOtpProps, ActivationReqProps } from "~/common/types/auth"
 import { activationReq, activationUserOTP } from "~/services/auth"
 
@@ -50,7 +51,11 @@ const FormOTP = () => {
     //eslint-disable-next-line
   }, [otp])
 
-  // TODO: Save user to local storage
+  useEffect(() => {
+    if (mutationActivation.data?.user) {
+      setAuth(mutationActivation.data.user)
+    }
+  }, [mutationActivation.data])
 
   return (
     <Modal active={active} className="w-10/12 md:w-fit px-10" mode="desktop">
-- 
cgit v1.2.3

