From 3bcfa009a9592598c0168cf2bc57373dc60415c4 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Fri, 26 Apr 2024 11:43:06 +0200 Subject: [PATCH 1/2] :sparkles: Add collaborateur to home --- src/front/Components/Layouts/LoginHome/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/front/Components/Layouts/LoginHome/index.tsx b/src/front/Components/Layouts/LoginHome/index.tsx index 38238259..c7e4d2b2 100644 --- a/src/front/Components/Layouts/LoginHome/index.tsx +++ b/src/front/Components/Layouts/LoginHome/index.tsx @@ -17,7 +17,7 @@ export default function LoginHome() {
- Je suis un notaire + Je suis un notaire / collaborateur From b38cd95617ccd55daf9b4dd47af3860f2bfce916 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Fri, 26 Apr 2024 11:45:01 +0200 Subject: [PATCH 2/2] :sparkles: prevent removing own seat --- .../Manage/SubscriptionManageCollaborators/index.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/front/Components/Layouts/Subscription/Manage/SubscriptionManageCollaborators/index.tsx b/src/front/Components/Layouts/Subscription/Manage/SubscriptionManageCollaborators/index.tsx index 4c9bea8d..17a66917 100644 --- a/src/front/Components/Layouts/Subscription/Manage/SubscriptionManageCollaborators/index.tsx +++ b/src/front/Components/Layouts/Subscription/Manage/SubscriptionManageCollaborators/index.tsx @@ -6,7 +6,7 @@ import CheckBox from "@Front/Components/DesignSystem/CheckBox"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import React, { useCallback, useEffect, useState } from "react"; import User, { Subscription } from "le-coffre-resources/dist/Admin"; -import JwtService from "@Front/Services/JwtService/JwtService"; +import JwtService, { IUserJwtPayload } from "@Front/Services/JwtService/JwtService"; import Subscriptions from "@Front/Api/LeCoffreApi/Admin/Subscriptions/Subscriptions"; import Users from "@Front/Api/LeCoffreApi/Admin/Users/Users"; import { useRouter } from "next/router"; @@ -17,9 +17,10 @@ export default function SubscriptionManageCollaborators() { const [subscription, setSubscription] = useState(null); const [availableCollaborators, _setAvailableCollaborators] = useState([]); const [selectedCollaborators, setSelectedCollaborators] = useState([]); - + const [jwt, setJwt] = useState(undefined); const loadSubscription = useCallback(async () => { const jwt = JwtService.getInstance().decodeJwt(); + setJwt(jwt); const subscription = await Subscriptions.getInstance().get({ where: { office: { uid: jwt?.office_Id } }, include: { seats: { include: { user: true } } }, @@ -80,7 +81,7 @@ export default function SubscriptionManageCollaborators() { return ( - {subscription && ( + {subscription && jwt && (
Choisissez les collaborateurs pour votre abonnement @@ -100,8 +101,9 @@ export default function SubscriptionManageCollaborators() { checked={selectedCollaborators.includes(collaborator.uid!)} onChange={handleChange} disabled={ - selectedCollaborators.length >= subscription.nb_seats! && - !selectedCollaborators.includes(collaborator.uid!) + (selectedCollaborators.length >= subscription.nb_seats! && + !selectedCollaborators.includes(collaborator.uid!)) || + jwt.userId === collaborator.uid } name="collaborators" />