Skip to content

Commit

Permalink
removed uneccessary logic from validateEmail function in helperUtils …
Browse files Browse the repository at this point in the history
…and refactored modal logic in AccountSettings
  • Loading branch information
corypride committed May 14, 2024
1 parent 14d712f commit 00f2e2a
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 65 deletions.
5 changes: 1 addition & 4 deletions common/utils/helperUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,7 @@ export function replaceSymbolsWithDash(value: string) {
return value.replace(/[^A-Za-z0-9]/g, "-").toLowerCase();
}

export const validateEmail = (email: string | undefined) => {
if (email === undefined) {
return false;
}
export const validateEmail = (email: string) => {
return Boolean(
email
.toLowerCase()
Expand Down
124 changes: 63 additions & 61 deletions publisher/src/components/Settings/AccountSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,68 +78,70 @@ export const AccountSettings = () => {
};
return (
<>
{isSettingInEditMode && editType === EditType.Name_edit && (
<Modal
title="Name"
description={
<AgencySettingsModalInputWrapperSmall>
<NewInput
style={{ marginBottom: "0" }}
persistLabel
value={name}
onChange={(e) => {
setName(() => e.target.value.trimStart());
}}
agencySettingsConfigs
fullWidth
/>
</AgencySettingsModalInputWrapperSmall>
}
buttons={[
{
label: "Save",
onClick: () => {
saveNameEmailChange(name);
},
},
]}
modalBackground="opaque"
onClickClose={onClickClose}
agencySettingsConfigs
/>
{isSettingInEditMode && (
<>
{editType === EditType.Name_edit && (
<Modal
title="Name"
description={
<AgencySettingsModalInputWrapperSmall>
<NewInput
style={{ marginBottom: "0" }}
persistLabel
value={name}
onChange={(e) => {
setName(() => e.target.value.trimStart());
}}
agencySettingsConfigs
fullWidth
/>
</AgencySettingsModalInputWrapperSmall>
}
buttons={[
{
label: "Save",
onClick: () => {
saveNameEmailChange(name);
},
},
]}
modalBackground="opaque"
onClickClose={onClickClose}
agencySettingsConfigs
/>
)}
{editType === EditType.Email_edit && (
<Modal
title="Email"
description={
<AgencySettingsModalInputWrapperSmall error={!isEmailValid}>
<NewInput
style={{ marginBottom: "0" }}
persistLabel
value={email}
error={errorMsg}
onChange={(e) => {
setEmail(() => e.target.value.trimStart());
}}
fullWidth
/>
</AgencySettingsModalInputWrapperSmall>
}
buttons={[
{
label: "Save",
onClick: () => {
saveNameEmailChange(undefined, email);
},
},
]}
modalBackground="opaque"
onClickClose={onClickClose}
agencySettingsConfigs
/>
)}
</>
)}

{isSettingInEditMode && editType === EditType.Email_edit && (
<Modal
title="Email"
description={
<AgencySettingsModalInputWrapperSmall error={!isEmailValid}>
<NewInput
style={{ marginBottom: "0" }}
persistLabel
value={email}
error={errorMsg}
onChange={(e) => {
setEmail(() => e.target.value.trimStart());
}}
fullWidth
/>
</AgencySettingsModalInputWrapperSmall>
}
buttons={[
{
label: "Save",
onClick: () => {
saveNameEmailChange(undefined, email);
},
},
]}
modalBackground="opaque"
onClickClose={onClickClose}
agencySettingsConfigs
/>
)}

<AccountSettingsWrapper>
<AccountSettingsInputsWrapper>
<AccountSettingsSectionCol>
Expand Down

0 comments on commit 00f2e2a

Please sign in to comment.