✨ Disable inputs if max length on manage collaborators
This commit is contained in:
parent
ff15c7cf95
commit
55c2614d3a
@ -4,6 +4,9 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
&.disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
input[type="checkbox"] {
|
input[type="checkbox"] {
|
||||||
appearance: none;
|
appearance: none;
|
||||||
@ -15,6 +18,10 @@
|
|||||||
margin-right: 16px;
|
margin-right: 16px;
|
||||||
display: grid;
|
display: grid;
|
||||||
place-content: center;
|
place-content: center;
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="checkbox"]::before {
|
input[type="checkbox"]::before {
|
||||||
|
@ -4,6 +4,7 @@ import { IOption } from "../Form/SelectField";
|
|||||||
import Tooltip from "../ToolTip";
|
import Tooltip from "../ToolTip";
|
||||||
import Typography, { ITypo, ITypoColor } from "../Typography";
|
import Typography, { ITypo, ITypoColor } from "../Typography";
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
|
import classNames from "classnames";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
name?: string;
|
name?: string;
|
||||||
@ -11,6 +12,7 @@ type IProps = {
|
|||||||
toolTip?: string;
|
toolTip?: string;
|
||||||
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
||||||
checked: boolean;
|
checked: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
type IState = {
|
type IState = {
|
||||||
@ -21,6 +23,7 @@ export default class CheckBox extends React.Component<IProps, IState> {
|
|||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
toolTip: "",
|
toolTip: "",
|
||||||
checked: false,
|
checked: false,
|
||||||
|
disabled: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props: IProps) {
|
constructor(props: IProps) {
|
||||||
@ -35,13 +38,14 @@ export default class CheckBox extends React.Component<IProps, IState> {
|
|||||||
public override render(): JSX.Element {
|
public override render(): JSX.Element {
|
||||||
return (
|
return (
|
||||||
<Typography typo={ITypo.P_ERR_16} color={ITypoColor.BLACK}>
|
<Typography typo={ITypo.P_ERR_16} color={ITypoColor.BLACK}>
|
||||||
<label className={classes["root"]}>
|
<label className={classNames(classes["root"], this.props.disabled && classes["disabled"])}>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
name={this.props.name ?? (this.props.option.value as string)}
|
name={this.props.name ?? (this.props.option.value as string)}
|
||||||
value={this.props.option.value as string}
|
value={this.props.option.value as string}
|
||||||
onChange={this.onChange}
|
onChange={this.onChange}
|
||||||
checked={this.state.checked}
|
checked={this.state.checked}
|
||||||
|
disabled={this.props.disabled}
|
||||||
/>
|
/>
|
||||||
{this.props.option.label}
|
{this.props.option.label}
|
||||||
{this.props.toolTip && <Tooltip className={classes["tooltip"]} text={this.props.toolTip} />}
|
{this.props.toolTip && <Tooltip className={classes["tooltip"]} text={this.props.toolTip} />}
|
||||||
|
@ -88,7 +88,7 @@ export default function SubscriptionManageCollaborators() {
|
|||||||
if (selectedCollaborators.includes(value)) {
|
if (selectedCollaborators.includes(value)) {
|
||||||
setSelectedCollaborators((prev) => prev.filter((collaborator) => collaborator !== value));
|
setSelectedCollaborators((prev) => prev.filter((collaborator) => collaborator !== value));
|
||||||
} else {
|
} else {
|
||||||
if (selectedCollaborators.length <= subscription.nb_seats!) {
|
if (selectedCollaborators.length < subscription.nb_seats!) {
|
||||||
setSelectedCollaborators((prev) => [...prev, value]);
|
setSelectedCollaborators((prev) => [...prev, value]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,6 +121,10 @@ export default function SubscriptionManageCollaborators() {
|
|||||||
}}
|
}}
|
||||||
checked={selectedCollaborators.includes(collaborator.uid!)}
|
checked={selectedCollaborators.includes(collaborator.uid!)}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
|
disabled={
|
||||||
|
selectedCollaborators.length >= subscription.nb_seats! &&
|
||||||
|
!selectedCollaborators.includes(collaborator.uid!)
|
||||||
|
}
|
||||||
name="collaborators"
|
name="collaborators"
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user