Skip to content

Commit

Permalink
Add null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
DonOmalVindula committed Sep 9, 2024
1 parent 03ce70a commit edc0312
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions features/admin.users.v1/components/user-profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,12 @@ export const UserProfile: FunctionComponent<UserProfilePropsInterface> = (
if (schemaName.includes("addresses")) {
// Ex: addresses#home.streetAddress
const addressSubSchema: string = schema?.name?.split(".")[1];
const addressSchemaArray: string[] = schemaName?.split(".");

if (schemaName.split("#").length > 1) {
if (addressSchemaArray.length > 1) {
// Ex: addresses#home
const addressSchema: string = schemaName.split("#")[0];
const addressType: string = schemaName.split("#")[1];
const addressSchema: string = addressSchemaArray[0];
const addressType: string = addressSchemaArray[1];

const subValue: SubValueInterface = userInfo[addressSchema] &&
Array.isArray(userInfo[addressSchema]) &&
Expand All @@ -383,7 +384,7 @@ export const UserProfile: FunctionComponent<UserProfilePropsInterface> = (

tempProfileInfo.set(
schema.name,
subValue[addressSubSchema] ? subValue[addressSubSchema] : ""
(subValue && subValue[addressSubSchema]) ? subValue[addressSubSchema] : ""
);
} else {
tempProfileInfo.set(
Expand Down

0 comments on commit edc0312

Please sign in to comment.