Merged in fix/SW-2188-disable-fields-logged-in-user-enter-details (pull request #2595)
fix(SW-2188): disable enter details fields when logged in * fix(SW-2188): disable enter details fields when logged in Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -155,7 +155,7 @@ export default function Details({ user }: DetailsProps) {
|
|||||||
})}
|
})}
|
||||||
maxLength={30}
|
maxLength={30}
|
||||||
name="firstName"
|
name="firstName"
|
||||||
readOnly={!!user}
|
disabled={!!user}
|
||||||
registerOptions={{ required: true, onBlur: updateDetailsStore }}
|
registerOptions={{ required: true, onBlur: updateDetailsStore }}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
@@ -165,7 +165,7 @@ export default function Details({ user }: DetailsProps) {
|
|||||||
})}
|
})}
|
||||||
maxLength={30}
|
maxLength={30}
|
||||||
name="lastName"
|
name="lastName"
|
||||||
readOnly={!!user}
|
disabled={!!user}
|
||||||
registerOptions={{ required: true, onBlur: updateDetailsStore }}
|
registerOptions={{ required: true, onBlur: updateDetailsStore }}
|
||||||
/>
|
/>
|
||||||
<CountrySelect
|
<CountrySelect
|
||||||
@@ -180,8 +180,8 @@ export default function Details({ user }: DetailsProps) {
|
|||||||
formState.errors.countryCode?.message
|
formState.errors.countryCode?.message
|
||||||
)}
|
)}
|
||||||
name="countryCode"
|
name="countryCode"
|
||||||
readOnly={!!user}
|
|
||||||
registerOptions={{ required: true, onBlur: updateDetailsStore }}
|
registerOptions={{ required: true, onBlur: updateDetailsStore }}
|
||||||
|
disabled={!!user}
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
autoComplete="email"
|
autoComplete="email"
|
||||||
@@ -190,7 +190,7 @@ export default function Details({ user }: DetailsProps) {
|
|||||||
defaultMessage: "Email address",
|
defaultMessage: "Email address",
|
||||||
})}
|
})}
|
||||||
name="email"
|
name="email"
|
||||||
readOnly={!!user}
|
disabled={!!user}
|
||||||
registerOptions={{ required: true, onBlur: updateDetailsStore }}
|
registerOptions={{ required: true, onBlur: updateDetailsStore }}
|
||||||
/>
|
/>
|
||||||
<Phone
|
<Phone
|
||||||
@@ -208,7 +208,7 @@ export default function Details({ user }: DetailsProps) {
|
|||||||
defaultMessage: "Phone number",
|
defaultMessage: "Phone number",
|
||||||
})}
|
})}
|
||||||
name="phoneNumber"
|
name="phoneNumber"
|
||||||
readOnly={!!user}
|
disabled={!!user}
|
||||||
registerOptions={{ required: true, onBlur: updateDetailsStore }}
|
registerOptions={{ required: true, onBlur: updateDetailsStore }}
|
||||||
/>
|
/>
|
||||||
{user ? null : (
|
{user ? null : (
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
|
|||||||
maxLength={maxLength}
|
maxLength={maxLength}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
readOnly={readOnly}
|
readOnly={readOnly}
|
||||||
|
disabled={disabled}
|
||||||
required={!!registerOptions.required}
|
required={!!registerOptions.required}
|
||||||
type={type}
|
type={type}
|
||||||
inputMode={inputMode}
|
inputMode={inputMode}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export default function CountryCombobox({
|
|||||||
lang = 'en',
|
lang = 'en',
|
||||||
countries,
|
countries,
|
||||||
name = 'country',
|
name = 'country',
|
||||||
readOnly = false,
|
disabled = false,
|
||||||
registerOptions = {},
|
registerOptions = {},
|
||||||
}: CountryProps) {
|
}: CountryProps) {
|
||||||
const { startsWith } = useFilter({ sensitivity: 'base' })
|
const { startsWith } = useFilter({ sensitivity: 'base' })
|
||||||
@@ -84,7 +84,7 @@ export default function CountryCombobox({
|
|||||||
aria-label={label}
|
aria-label={label}
|
||||||
className={styles.select}
|
className={styles.select}
|
||||||
data-testid={name}
|
data-testid={name}
|
||||||
isReadOnly={readOnly}
|
isDisabled={disabled}
|
||||||
isRequired={Boolean(registerOptions?.required)}
|
isRequired={Boolean(registerOptions?.required)}
|
||||||
isInvalid={fieldState.invalid}
|
isInvalid={fieldState.invalid}
|
||||||
name={name}
|
name={name}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default function CountrySelect({
|
|||||||
countries,
|
countries,
|
||||||
lang = 'en',
|
lang = 'en',
|
||||||
name = 'country',
|
name = 'country',
|
||||||
readOnly = false,
|
disabled = false,
|
||||||
registerOptions = {},
|
registerOptions = {},
|
||||||
}: CountryProps) {
|
}: CountryProps) {
|
||||||
const { field, formState, fieldState } = useController({
|
const { field, formState, fieldState } = useController({
|
||||||
@@ -53,7 +53,7 @@ export default function CountrySelect({
|
|||||||
<Select
|
<Select
|
||||||
items={items}
|
items={items}
|
||||||
label={label}
|
label={label}
|
||||||
isReadOnly={readOnly}
|
isDisabled={disabled}
|
||||||
isRequired={Boolean(registerOptions?.required)}
|
isRequired={Boolean(registerOptions?.required)}
|
||||||
isInvalid={fieldState.invalid}
|
isInvalid={fieldState.invalid}
|
||||||
name={name}
|
name={name}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&[data-disabled] {
|
&[data-disabled] {
|
||||||
|
border: transparent;
|
||||||
|
|
||||||
.inner {
|
.inner {
|
||||||
background-color: var(--Surface-Primary-Disabled);
|
background-color: var(--Surface-Primary-Disabled);
|
||||||
color: var(--Text-Interactive-Disabled);
|
color: var(--Text-Interactive-Disabled);
|
||||||
@@ -41,7 +43,8 @@
|
|||||||
|
|
||||||
.button,
|
.button,
|
||||||
.input,
|
.input,
|
||||||
.label {
|
.label,
|
||||||
|
.chevron {
|
||||||
color: var(--Text-Interactive-Disabled);
|
color: var(--Text-Interactive-Disabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,6 +57,7 @@
|
|||||||
.inner {
|
.inner {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
border-radius: var(--Corner-radius-md);
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: var(--Space-x1);
|
gap: var(--Space-x1);
|
||||||
padding: var(--Space-x15);
|
padding: var(--Space-x15);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export type CountryProps = {
|
|||||||
lang?: string
|
lang?: string
|
||||||
name?: string
|
name?: string
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
readOnly?: boolean
|
disabled?: boolean
|
||||||
registerOptions?: RegisterOptions
|
registerOptions?: RegisterOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ export default function Phone({
|
|||||||
label,
|
label,
|
||||||
name = 'phoneNumber',
|
name = 'phoneNumber',
|
||||||
placeholder,
|
placeholder,
|
||||||
readOnly = false,
|
|
||||||
registerOptions = {
|
registerOptions = {
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
@@ -87,7 +86,7 @@ export default function Phone({
|
|||||||
<div className={`${styles.phone} ${className}`}>
|
<div className={`${styles.phone} ${className}`}>
|
||||||
<CountrySelector
|
<CountrySelector
|
||||||
countries={countries}
|
countries={countries}
|
||||||
disabled={readOnly}
|
disabled={disabled}
|
||||||
dropdownArrowClassName={styles.arrow}
|
dropdownArrowClassName={styles.arrow}
|
||||||
flagClassName={styles.flag}
|
flagClassName={styles.flag}
|
||||||
onSelect={handleSelectCountry}
|
onSelect={handleSelectCountry}
|
||||||
@@ -101,7 +100,11 @@ export default function Phone({
|
|||||||
type="button"
|
type="button"
|
||||||
data-testid="country-selector"
|
data-testid="country-selector"
|
||||||
>
|
>
|
||||||
<Label required={!!registerOptions.required} size="small">
|
<Label
|
||||||
|
required={!!registerOptions.required}
|
||||||
|
size="small"
|
||||||
|
disabled={disabled}
|
||||||
|
>
|
||||||
{countryLabel}
|
{countryLabel}
|
||||||
</Label>
|
</Label>
|
||||||
<span className={styles.selectContainer}>
|
<span className={styles.selectContainer}>
|
||||||
@@ -111,6 +114,7 @@ export default function Phone({
|
|||||||
className={styles.dialCode}
|
className={styles.dialCode}
|
||||||
dialCode={country.dialCode}
|
dialCode={country.dialCode}
|
||||||
prefix="+"
|
prefix="+"
|
||||||
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
</Body>
|
</Body>
|
||||||
<MaterialIcon
|
<MaterialIcon
|
||||||
@@ -128,7 +132,6 @@ export default function Phone({
|
|||||||
isDisabled={disabled || registerOptions.disabled}
|
isDisabled={disabled || registerOptions.disabled}
|
||||||
isInvalid={fieldState.invalid}
|
isInvalid={fieldState.invalid}
|
||||||
isRequired={!!registerOptions?.required}
|
isRequired={!!registerOptions?.required}
|
||||||
isReadOnly={readOnly}
|
|
||||||
name={name}
|
name={name}
|
||||||
type="tel"
|
type="tel"
|
||||||
value={phoneNumber}
|
value={phoneNumber}
|
||||||
@@ -138,7 +141,7 @@ export default function Phone({
|
|||||||
autoComplete="tel-national"
|
autoComplete="tel-national"
|
||||||
label={label}
|
label={label}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
readOnly={readOnly}
|
disabled={disabled}
|
||||||
type="tel"
|
type="tel"
|
||||||
/>
|
/>
|
||||||
<ErrorMessage
|
<ErrorMessage
|
||||||
|
|||||||
@@ -77,6 +77,19 @@
|
|||||||
outline-offset: -2px;
|
outline-offset: -2px;
|
||||||
outline: 2px solid var(--Border-Interactive-Focus);
|
outline: 2px solid var(--Border-Interactive-Focus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
background-color: var(--Surface-Primary-Disabled);
|
||||||
|
color: var(--Text-Interactive-Disabled);
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
.selectContainer,
|
||||||
|
.chevron,
|
||||||
|
.dialCode {
|
||||||
|
background-color: var(--Surface-Primary-Disabled);
|
||||||
|
color: var(--Text-Interactive-Disabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.select[aria-expanded='true'] .chevron {
|
.select[aria-expanded='true'] .chevron {
|
||||||
|
|||||||
@@ -16,6 +16,5 @@ export interface PhoneProps {
|
|||||||
defaultCountryCode: string
|
defaultCountryCode: string
|
||||||
name?: string
|
name?: string
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
readOnly?: boolean
|
|
||||||
registerOptions?: RegisterOptions
|
registerOptions?: RegisterOptions
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export function Label({
|
|||||||
className,
|
className,
|
||||||
selected,
|
selected,
|
||||||
required,
|
required,
|
||||||
|
disabled,
|
||||||
size,
|
size,
|
||||||
}: LabelProps) {
|
}: LabelProps) {
|
||||||
const classNames = labelVariants({
|
const classNames = labelVariants({
|
||||||
@@ -14,6 +15,7 @@ export function Label({
|
|||||||
size,
|
size,
|
||||||
required,
|
required,
|
||||||
selected,
|
selected,
|
||||||
|
disabled,
|
||||||
})
|
})
|
||||||
|
|
||||||
return <span className={classNames}>{children}</span>
|
return <span className={classNames}>{children}</span>
|
||||||
|
|||||||
@@ -61,11 +61,10 @@ textarea[value]:not([value='']) ~ .label,
|
|||||||
margin-bottom: var(--Space-x025);
|
margin-bottom: var(--Space-x025);
|
||||||
}
|
}
|
||||||
|
|
||||||
input:disabled,
|
.label.disabled,
|
||||||
textarea:disabled {
|
input:disabled ~ .label,
|
||||||
& ~ .label {
|
textarea:disabled ~ .label {
|
||||||
color: var(--Text-Interactive-Disabled);
|
color: var(--Text-Interactive-Disabled);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (hover: hover) {
|
@media (hover: hover) {
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ export const labelVariants = cva(styles.label, {
|
|||||||
selected: {
|
selected: {
|
||||||
true: styles.selected,
|
true: styles.selected,
|
||||||
},
|
},
|
||||||
|
disabled: {
|
||||||
|
true: styles.disabled,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
defaultVariants: {
|
defaultVariants: {
|
||||||
size: 'regular',
|
size: 'regular',
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
&[data-disabled] {
|
&[data-disabled] {
|
||||||
|
border: none;
|
||||||
.inner {
|
.inner {
|
||||||
background-color: var(--Surface-Primary-Disabled);
|
background-color: var(--Surface-Primary-Disabled);
|
||||||
color: var(--Text-Interactive-Disabled);
|
color: var(--Text-Interactive-Disabled);
|
||||||
@@ -63,6 +64,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
border-radius: var(--Corner-radius-md);
|
||||||
|
|
||||||
&.button {
|
&.button {
|
||||||
padding: 0 var(--Space-x15);
|
padding: 0 var(--Space-x15);
|
||||||
|
|||||||
Reference in New Issue
Block a user