Skip to content

Commit 880de85

Browse files
authored
fix(console): disable conflicted sign-up identifiers (#7186)
* fix(console): disable conflicted sign-up identifiers disaable conflicted sign-up identifiers * style(console): remove hover style remove hover style of the disabled elements
1 parent 5db244f commit 880de85

File tree

3 files changed

+43
-23
lines changed

3 files changed

+43
-23
lines changed

packages/console/src/pages/SignInExperience/PageContent/SignUpAndSignIn/SignUpForm/SignUpIdentifiersEditBox/index.tsx

+26-22
Original file line numberDiff line numberDiff line change
@@ -83,35 +83,39 @@ function SignUpIdentifiersEditBox({ syncSignInMethods }: Props) {
8383
Array<{
8484
value: SignUpIdentifier;
8585
label: string;
86+
disabled?: boolean;
8687
}>
8788
>(() => {
8889
const identifiersSet = new Set(signUpIdentifiers.map(({ identifier }) => identifier));
89-
90-
return signUpIdentifierOptions.filter(({ value }) => {
91-
// Basic condition: filter out if identifiers include the value
92-
if (identifiersSet.has(value)) {
93-
return false;
94-
}
95-
96-
// Condition 2: If identifiers include EmailOrPhone, filter out Email and Phone
97-
if (
98-
identifiersSet.has(AlternativeSignUpIdentifier.EmailOrPhone) &&
99-
(value === SignInIdentifier.Email || value === SignInIdentifier.Phone)
100-
) {
101-
return false;
90+
const availableOptions = signUpIdentifierOptions.filter(
91+
({ value }) => !identifiersSet.has(value)
92+
);
93+
94+
return availableOptions.map(({ value, label }) => {
95+
// Disable email and phone options if email or phone is selected
96+
if (value === SignInIdentifier.Email || value === SignInIdentifier.Phone) {
97+
return {
98+
value,
99+
label,
100+
disabled: identifiersSet.has(AlternativeSignUpIdentifier.EmailOrPhone),
101+
};
102102
}
103103

104-
// Condition 3: If identifiers include Email or Phone, filter out EmailOrPhone
105-
if (
106-
(identifiersSet.has(SignInIdentifier.Email) ||
107-
identifiersSet.has(SignInIdentifier.Phone)) &&
108-
value === AlternativeSignUpIdentifier.EmailOrPhone
109-
) {
110-
return false;
104+
// Disable emailOrPhone option if email or phone is selected
105+
if (value === AlternativeSignUpIdentifier.EmailOrPhone) {
106+
return {
107+
value,
108+
label,
109+
disabled:
110+
identifiersSet.has(SignInIdentifier.Email) ||
111+
identifiersSet.has(SignInIdentifier.Phone),
112+
};
111113
}
112114

113-
// If none of the conditions matched, keep the value
114-
return true;
115+
return {
116+
value,
117+
label,
118+
};
115119
});
116120
}, [signUpIdentifiers]);
117121

Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
@use '@/scss/underscore' as _;
2+
13
.addAnotherIdentifierDropdown {
24
min-width: 208px;
35
}
46

57
.addIdentifierDropDown {
68
min-width: unset;
79
}
10+
11+
.disabledDropdownItem {
12+
cursor: not-allowed;
13+
color: var(--color-placeholder);
14+
15+
&:hover {
16+
background-color: transparent;
17+
}
18+
}

packages/console/src/pages/SignInExperience/PageContent/SignUpAndSignIn/components/IdentifiersAddButton/index.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type MethodsType = 'sign-in' | 'sign-up';
1515
type Options<T> = Array<{
1616
value: T;
1717
label: string;
18+
disabled?: boolean;
1819
}>;
1920

2021
type Props<T> = {
@@ -60,10 +61,14 @@ function IdentifiersAddButton<T extends SignInIdentifier | SignUpIdentifier>({
6061
)}
6162
isDropdownFullWidth={!hasSelectedIdentifiers}
6263
>
63-
{options.map(({ value, label }) => (
64+
{options.map(({ value, label, disabled }) => (
6465
<DropdownItem
6566
key={value}
67+
className={disabled ? styles.disabledDropdownItem : undefined}
6668
onClick={() => {
69+
if (disabled) {
70+
return;
71+
}
6772
onSelected(value);
6873
}}
6974
>

0 commit comments

Comments
 (0)