From b7981922e0c1d51208c6e19b13d5934b448deba7 Mon Sep 17 00:00:00 2001 From: upendraTekdi Date: Fri, 10 May 2024 15:27:00 +0530 Subject: [PATCH] feat: MyProfile details page --- src/pages/MyProfile.tsx | 53 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/src/pages/MyProfile.tsx b/src/pages/MyProfile.tsx index d11b099c..57b51027 100644 --- a/src/pages/MyProfile.tsx +++ b/src/pages/MyProfile.tsx @@ -129,34 +129,35 @@ const MyProfile = () => { }; const fetchUserDetails = async () => { - const userId = localStorage.getItem('userId'); - // const userId = '775f4baa-5593-466e-bb24-582cdf4a2d46'; - console.log('userId', userId); - try { - if (userId) { - const response = await getUserDetails(userId, true); - console.log('userId', response); - if (response?.statusCode === 200) { - const data = response?.data; - if (data) { - const userData = data?.userData; - setUserData(userData); - const customDataFields = userData?.customFields; - console.log('customDataFields', customDataFields); - if (customDataFields?.length > 0) { - setCustomFieldsData(customDataFields); + if (typeof window !== 'undefined' && window.localStorage) { + const userId = localStorage.getItem('userId'); + + try { + if (userId) { + const response = await getUserDetails(userId, true); + console.log('userId', response); + if (response?.statusCode === 200) { + const data = response?.data; + if (data) { + const userData = data?.userData; + setUserData(userData); + const customDataFields = userData?.customFields; + console.log('customDataFields', customDataFields); + if (customDataFields?.length > 0) { + setCustomFieldsData(customDataFields); + } + } else { + console.log('No data Found'); } } else { - console.log('No data Found'); + console.log('No Response Found'); } - } else { - console.log('No Response Found'); - } - // console.log(response?.result?.userData?.customFields); + // console.log(response?.result?.userData?.customFields); + } + } catch (error) { + console.error('Error fetching user details:', error); } - } catch (error) { - console.error('Error fetching user details:', error); } }; @@ -230,8 +231,7 @@ const MyProfile = () => { marginBottom: '2px', }} > - {/* {t('PROFILE.MY_PROFILE')} */} - My Profile + {t('PROFILE.MY_PROFILE')} @@ -291,8 +291,7 @@ const MyProfile = () => { startIcon={} onClick={handleOpen} > - Edit Profile - {/* {t('PROFILE.EDIT_PROFILE')} */} + {t('PROFILE.EDIT_PROFILE')} {/* modal for edit profile */}