From cdfc5fc29d8a83983d81e0bcf093b9e0514b8e53 Mon Sep 17 00:00:00 2001 From: OxSaitama Date: Tue, 5 Sep 2023 09:35:45 +0200 Subject: [PATCH] disable switch for votes --- .../DesignSystem/Switch/classes.module.scss | 6 ++++++ src/front/Components/DesignSystem/Switch/index.tsx | 11 +++++++---- .../Layouts/Users/UserInformations/index.tsx | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/front/Components/DesignSystem/Switch/classes.module.scss b/src/front/Components/DesignSystem/Switch/classes.module.scss index c900ab5e..21873d6a 100644 --- a/src/front/Components/DesignSystem/Switch/classes.module.scss +++ b/src/front/Components/DesignSystem/Switch/classes.module.scss @@ -3,6 +3,12 @@ gap: 16px; cursor: pointer; width: fit-content; + + .disabled { + cursor: not-allowed; + opacity: 0.5; + } + .switch-container { position: relative; width: 46px; diff --git a/src/front/Components/DesignSystem/Switch/index.tsx b/src/front/Components/DesignSystem/Switch/index.tsx index 3b911bb7..c2b10c85 100644 --- a/src/front/Components/DesignSystem/Switch/index.tsx +++ b/src/front/Components/DesignSystem/Switch/index.tsx @@ -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(checked ? checked : false); useEffect(() => { @@ -21,9 +22,11 @@ export default function Switch({ onChange, checked, label }: IProps) { }, [isChecked, onChange]); return ( -
-
-
+
+
{} : handleChange}> +
+
+
{label} diff --git a/src/front/Components/Layouts/Users/UserInformations/index.tsx b/src/front/Components/Layouts/Users/UserInformations/index.tsx index 4bff2860..08e3c512 100644 --- a/src/front/Components/Layouts/Users/UserInformations/index.tsx +++ b/src/front/Components/Layouts/Users/UserInformations/index.tsx @@ -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) {
- + {currentAppointment && (