From 53ef81cf1dfbc60f36ba71a42eacbc9b67fc94e2 Mon Sep 17 00:00:00 2001 From: Rushikesh-Sonawane99 Date: Fri, 2 Aug 2024 13:41:26 +0530 Subject: [PATCH 1/2] Issue #PS-1275 chore: Modified state, district and block mapping logic for user profile --- src/pages/user-profile/[userId].tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/pages/user-profile/[userId].tsx b/src/pages/user-profile/[userId].tsx index 9280f47bb..04e102a2f 100644 --- a/src/pages/user-profile/[userId].tsx +++ b/src/pages/user-profile/[userId].tsx @@ -56,7 +56,8 @@ const TeacherProfile = () => { const [loading, setLoading] = useState(false); const [image, setImage] = useState(user_placeholder_img); const [isAuthenticated, setIsAuthenticated] = React.useState(false); - const [unitName, setUnitName] = useState(''); + const [stateName, setStateName] = useState(''); + const [districtName, setDistrictName] = useState(''); const [blockName, setBlockName] = useState(''); const [isError, setIsError] = React.useState(false); const [isData, setIsData] = React.useState(false); @@ -213,6 +214,14 @@ const TeacherProfile = () => { const coreFieldData = data?.result?.userData; setUserName(toPascalCase(coreFieldData?.name)); const fields: CustomField[] = data?.result?.userData?.customFields; + if (fields?.length > 0) { + const stateName = getFieldValue(fields, 'State'); + setStateName(toPascalCase(stateName)); + const districtName = getFieldValue(fields, 'District'); + setDistrictName(toPascalCase(districtName)); + const blockName = getFieldValue(fields, 'Block'); + setBlockName(toPascalCase(blockName)); + } const fieldIdToValueMap: { [key: string]: string } = mapFieldIdToValue(fields); console.log(`coreFieldData`, coreFieldData); @@ -264,11 +273,6 @@ const TeacherProfile = () => { if (customDataFields?.length > 0) { setCustomFieldsData(customDataFields); - - const unitName = getFieldValue(customDataFields, 'Unit Name'); - setUnitName(unitName); - const blockName = getFieldValue(customDataFields, 'Block Name'); - setBlockName(blockName); } } } else { @@ -335,7 +339,7 @@ const TeacherProfile = () => { }; // address find - const address = [unitName, blockName, userData?.district, userData?.state] + const address = [stateName, districtName, blockName] ?.filter(Boolean) ?.join(', '); From 59f2fb500a1f8bee1a264dfb6ed994cc1887f161 Mon Sep 17 00:00:00 2001 From: Rushikesh-Sonawane99 Date: Fri, 2 Aug 2024 13:46:00 +0530 Subject: [PATCH 2/2] Issue #000 chore: Updated PR --- src/pages/user-profile/[userId].tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/user-profile/[userId].tsx b/src/pages/user-profile/[userId].tsx index 04e102a2f..9b7df2fab 100644 --- a/src/pages/user-profile/[userId].tsx +++ b/src/pages/user-profile/[userId].tsx @@ -194,7 +194,7 @@ const TeacherProfile = () => { // find Address const getFieldValue = (data: any, label: string) => { const field = data.find((item: any) => item.label === label); - return field ? field?.value[0] : null; + return field ? field?.value : null; }; const { data, error, isLoading } = useProfileInfo(userId ?? '', true, reload);