diff --git a/src/pages/block.tsx b/src/pages/block.tsx index f5e91f85..d4cf1bb1 100644 --- a/src/pages/block.tsx +++ b/src/pages/block.tsx @@ -188,7 +188,7 @@ const setIsArchived = useSubmittedButtonStore( const districts = data?.result?.values || []; setDistrictsOptionRead(districts); - const districtNameArray = districts.map((item: any) => item.label.toLowerCase()); + const districtNameArray = districts.map((item: any) => item.label?.toLowerCase()); setDistrictNameArr(districtNameArray); const districtCodeArray = districts.map((item: any) => item.value); @@ -262,7 +262,7 @@ const setIsArchived = useSubmittedButtonStore( } ) .filter((district: { label: any }) => - districtNameArr.includes(district.label.toLowerCase()) + districtNameArr.includes(district.label?.toLowerCase()) ); if (isFirstVisit) { if ( @@ -321,7 +321,7 @@ const setIsArchived = useSubmittedButtonStore( const blocks = response?.result?.values || []; setBlocksOptionRead(blocks); - const blockNameArray = blocks.map((item: any) => item.label.toLowerCase()); + const blockNameArray = blocks.map((item: any) => item.label?.toLowerCase()); setBlockNameArr(blockNameArray); const blockCodeArray = blocks.map((item: any) => item.value); @@ -412,7 +412,7 @@ const setIsArchived = useSubmittedButtonStore( }; } ) - .filter((block: { name: string }) => blockNameArr.includes(block.name.toLocaleLowerCase())); + .filter((block: { name: string }) => blockNameArr.includes(block.name?.toLocaleLowerCase())); setBlockData(filteredBlockData); setShowAllBlocks(filteredBlockData); diff --git a/src/pages/district.tsx b/src/pages/district.tsx index 77a93e93..42ea42b0 100644 --- a/src/pages/district.tsx +++ b/src/pages/district.tsx @@ -146,7 +146,7 @@ const District: React.FC = () => { const districts = data?.result?.values || []; setDistrictsOptionRead(districts); - const districtNameArray = districts.map((item: any) => item.label.toLowerCase()); + const districtNameArray = districts.map((item: any) => item.label?.toLowerCase()); setDistrictNameArr(districtNameArray); const districtCodeArray = districts.map((item: any) => item.value); @@ -252,7 +252,7 @@ const District: React.FC = () => { const matchingDistrict = districtsOptionRead.find( (district: { label: string }) => - district.label.toLowerCase() === transformedName.toLowerCase() + district.label?.toLowerCase() === transformedName?.toLowerCase() ); return {