diff --git a/src/front/Components/Layouts/Users/UserInformations/classes.module.scss b/src/front/Components/Layouts/Users/UserInformations/classes.module.scss index 6dd2a010..cc483aa2 100644 --- a/src/front/Components/Layouts/Users/UserInformations/classes.module.scss +++ b/src/front/Components/Layouts/Users/UserInformations/classes.module.scss @@ -83,3 +83,15 @@ .remove-my-vote { margin-top: 16px; } + +.loader-container { + display: flex; + flex: 1; + align-items: center; + justify-content: center; + height: 100%; + .loader { + width: 40px; + height: 40px; + } +} diff --git a/src/front/Components/Layouts/Users/UserInformations/index.tsx b/src/front/Components/Layouts/Users/UserInformations/index.tsx index 82158ea4..b55e45d5 100644 --- a/src/front/Components/Layouts/Users/UserInformations/index.tsx +++ b/src/front/Components/Layouts/Users/UserInformations/index.tsx @@ -18,6 +18,7 @@ import { useCallback, useEffect, useState } from "react"; import classes from "./classes.module.scss"; import OfficeRoles from "@Front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles"; +import Loader from "@Front/Components/DesignSystem/Loader"; type IProps = {}; export default function UserInformations(props: IProps) { @@ -36,10 +37,12 @@ export default function UserInformations(props: IProps) { const [currentAppointment, setCurrentAppointment] = useState(null); + const [isLoading, setIsLoading] = useState(true); /** When page change, get the user of the page */ const getUser = useCallback(async () => { if (!userUid) return; + setIsLoading(true); const user = await Users.getInstance().getByUid(userUid as string, { q: { contact: true, @@ -66,6 +69,7 @@ export default function UserInformations(props: IProps) { }, }); if (!roles) return; + setIsLoading(false); setUserSelected(user); }, [userUid]); @@ -201,135 +205,146 @@ export default function UserInformations(props: IProps) { return ( -
-
- {userSelected?.contact?.first_name + " " + userSelected?.contact?.last_name} - - Office {userSelected?.office_membership?.name.toLocaleUpperCase()} - -
-
-
- - Nom + {!isLoading && ( +
+
+ + {userSelected?.contact?.first_name + " " + userSelected?.contact?.last_name} - {userSelected?.contact?.first_name} -
-
- - Prénom + + Office {userSelected?.office_membership?.name.toLocaleUpperCase()} - {userSelected?.contact?.last_name}
-
- - Numéro de téléphone - - {userSelected?.contact?.phone_number} -
-
- - Email - - {userSelected?.contact?.email} -
-
- -
-
-
- Rôle au sein de son office +
+
+ + Nom + + {userSelected?.contact?.first_name}
-
- - {userSelected?.office_role ? userSelected?.office_role?.name : "Utilisateur restreint"} +
+ + Prénom + + {userSelected?.contact?.last_name} +
+
+ + Numéro de téléphone + + {userSelected?.contact?.phone_number} +
+
+ + Email + + {userSelected?.contact?.email} +
+
+ +
+
+
+ Rôle au sein de son office +
+
+ + {userSelected?.office_role ? userSelected?.office_role?.name : "Utilisateur restreint"} + +
+
+
+
+ Attribuer un titre +
+
+ {!isSuperAdminChecked && !currentAppointment && ( + + )} + + + {currentAppointment && ( +
+
+ warning +
+
+
+ {currentAppointment.votes?.length}/3 +
+
+ + {currentAppointment.choice === EVote.NOMINATE + ? `Un ou des collaborateurs souhaitent attribuer le titre de Super Admin à ce collaborateur. Il manque ${ + 3 - currentAppointment.votes?.length! + } vote(s) pour que le collaborateur se voit attribuer le titre.` + : `Un ou des collaborateurs souhaitent retirer le titre de Super Admin à ce collaborateur. Il manque ${ + 3 - currentAppointment.votes?.length! + } vote(s) pour que le collaborateur se voit retirer le titre.`} + +
+ {userHasVoted() && ( +
+ +
+ )} +
+
+ )} +
+
+
+ +
+ + {superAdminModalType === "add" ? "Nommer" : "Retirer"} une personne Super Administrateur nécessite 3 votes + de super administrateurs existants. Souhaitez-vous attribuer un vote ?
-
-
-
- Attribuer un titre -
-
- {!isSuperAdminChecked && !currentAppointment && ( - - )} - - - {currentAppointment && ( -
-
- warning -
-
-
- {currentAppointment.votes?.length}/3 -
-
- - {currentAppointment.choice === EVote.NOMINATE - ? `Un ou des collaborateurs souhaitent attribuer le titre de Super Admin à ce collaborateur. Il manque ${ - 3 - currentAppointment.votes?.length! - } vote(s) pour que le collaborateur se voit attribuer le titre.` - : `Un ou des collaborateurs souhaitent retirer le titre de Super Admin à ce collaborateur. Il manque ${ - 3 - currentAppointment.votes?.length! - } vote(s) pour que le collaborateur se voit retirer le titre.`} - -
- {userHasVoted() && ( -
- -
- )} -
-
- )} -
+ + +
+
+
+ )} + {isLoading && ( +
+
+
- -
- - {superAdminModalType === "add" ? "Nommer" : "Retirer"} une personne Super Administrateur nécessite 3 votes de - super administrateurs existants. Souhaitez-vous attribuer un vote ? - -
-
- -
-
-
+ )} ); }