disable switch for votes
This commit is contained in:
parent
30b5d1cd87
commit
cdfc5fc29d
@ -3,6 +3,12 @@
|
||||
gap: 16px;
|
||||
cursor: pointer;
|
||||
width: fit-content;
|
||||
|
||||
.disabled {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.switch-container {
|
||||
position: relative;
|
||||
width: 46px;
|
||||
|
@ -7,8 +7,9 @@ type IProps = {
|
||||
onChange?: (checked: boolean) => void;
|
||||
checked?: boolean;
|
||||
label: string;
|
||||
disabled?: boolean;
|
||||
};
|
||||
export default function Switch({ onChange, checked, label }: IProps) {
|
||||
export default function Switch({ onChange, checked, label, disabled }: IProps) {
|
||||
const [isChecked, setIsChecked] = useState<boolean>(checked ? checked : false);
|
||||
|
||||
useEffect(() => {
|
||||
@ -21,10 +22,12 @@ export default function Switch({ onChange, checked, label }: IProps) {
|
||||
}, [isChecked, onChange]);
|
||||
|
||||
return (
|
||||
<div className={classes["root"]} onClick={handleChange}>
|
||||
<div className={classes["root"]}>
|
||||
<div className={disabled ? classes["disabled"] : classes["root"]} onClick={disabled ? () => {} : handleChange}>
|
||||
<div className={classes["switch-container"]} data-checked={isChecked.toString()}>
|
||||
<div className={classes["round"]} />
|
||||
</div>
|
||||
</div>
|
||||
<Typography typo={ITypo.P_ERR_16} color={ITypoColor.BLACK}>
|
||||
{label}
|
||||
</Typography>
|
||||
|
@ -81,7 +81,7 @@ export default function UserInformations(props: IProps) {
|
||||
|
||||
useEffect(() => {
|
||||
if (!userSelected) return;
|
||||
setCurrentAppointment(userSelected?.appointment?.find((appointment) => appointment.status === EAppointmentStatus.OPEN) ?? null);
|
||||
setCurrentAppointment(userSelected?.appointment?.find((appointment) => appointment.status === EAppointmentStatus.OPEN && appointment.votes?.length != 0) ?? null);
|
||||
}, [userSelected]);
|
||||
|
||||
/** Functions for the admin modal */
|
||||
@ -282,7 +282,7 @@ export default function UserInformations(props: IProps) {
|
||||
</div>
|
||||
<div className={classes["second-line"]}>
|
||||
<Switch label="Admin de son office" checked={isAdminChecked} onChange={handleAdminChanged} />
|
||||
<Switch label="Super-admin LeCoffre.io" checked={isSuperAdminChecked} onChange={handleSuperAdminChanged} />
|
||||
<Switch label="Super-admin LeCoffre.io" checked={isSuperAdminChecked} disabled={userHasVoted()} onChange={handleSuperAdminChanged} />
|
||||
{currentAppointment && (
|
||||
<div className={classes["votes-block"]}>
|
||||
<div className={classes["left"]}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user