diff --git a/src/front/Components/LayoutTemplates/DefaultRoleDashboard/RoleListContainer/index.tsx b/src/front/Components/LayoutTemplates/DefaultRoleDashboard/RoleListContainer/index.tsx
index ffb79fef..360b58e6 100644
--- a/src/front/Components/LayoutTemplates/DefaultRoleDashboard/RoleListContainer/index.tsx
+++ b/src/front/Components/LayoutTemplates/DefaultRoleDashboard/RoleListContainer/index.tsx
@@ -46,13 +46,18 @@ export default function RoleListContainer(props: IProps) {
{
- return {
- name: role.name,
- id: role.uid!,
- selected: role.uid === roleUid,
- };
- })}
+ blocks={filteredRoles
+ .filter((role) => {
+ if (role.name === "admin") return false;
+ return true;
+ })
+ .map((role) => {
+ return {
+ name: role.name,
+ id: role.uid!,
+ selected: role.uid === roleUid,
+ };
+ })}
onSelectedBlock={onSelectedBlock}
/>
diff --git a/src/front/Components/Layouts/Collaborators/CollaboratorInformations/index.tsx b/src/front/Components/Layouts/Collaborators/CollaboratorInformations/index.tsx
index f5730d3c..ee40ef15 100644
--- a/src/front/Components/Layouts/Collaborators/CollaboratorInformations/index.tsx
+++ b/src/front/Components/Layouts/Collaborators/CollaboratorInformations/index.tsx
@@ -178,7 +178,9 @@ export default function CollaboratorInformations(props: IProps) {
{
+ return role.label !== "admin";
+ })}
selectedOption={selectedOption!}
onChange={handleRoleChange}
disabled={userSelected?.role?.name === "super-admin"}
diff --git a/src/front/Components/Layouts/DeedTypes/DeedTypesCreate/index.tsx b/src/front/Components/Layouts/DeedTypes/DeedTypesCreate/index.tsx
index 39d22720..a7220d15 100644
--- a/src/front/Components/Layouts/DeedTypes/DeedTypesCreate/index.tsx
+++ b/src/front/Components/Layouts/DeedTypes/DeedTypesCreate/index.tsx
@@ -3,18 +3,22 @@ import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
import Form from "@Front/Components/DesignSystem/Form";
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
import TextField from "@Front/Components/DesignSystem/Form/TextField";
+import Confirm from "@Front/Components/DesignSystem/Modal/Confirm";
import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography";
import DefaultDeedTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDeedTypeDashboard";
import Module from "@Front/Config/Module";
import JwtService from "@Front/Services/JwtService/JwtService";
import { DeedType, Office } from "le-coffre-resources/dist/Admin";
import { useRouter } from "next/router";
-import { useCallback } from "react";
+import { useCallback, useState } from "react";
import classes from "./classes.module.scss";
type IProps = {};
export default function DeedTypesCreate(props: IProps) {
+ const [hasChanged, setHasChanged] = useState(false);
+ const [isConfirmModalVisible, setIsConfirmModalVisible] = useState(false);
+
const router = useRouter();
const onSubmitHandler = useCallback(
async (e: React.FormEvent | null, values: { [key: string]: string }) => {
@@ -42,20 +46,58 @@ export default function DeedTypesCreate(props: IProps) {
[router],
);
+ const closeConfirmModal = useCallback(() => {
+ setIsConfirmModalVisible(false);
+ }, []);
+
+ const onFieldChange = useCallback((name: string, field: any) => {
+ setHasChanged(true);
+ }, []);
+
+ const redirect = useCallback(() => {
+ router.push(
+ Module.getInstance()
+ .get()
+ .modules.pages.DeedTypes.props.path
+ );
+ }, [router]);
+
+ const onCancel = useCallback(() => {
+ if (hasChanged) {
+ setIsConfirmModalVisible(true);
+ } else {
+ redirect();
+ }
+ }, [hasChanged, redirect]);
+
return (
Créer un type d'acte
-
+
+
+
+ Si vous quittez, toutes les modifications que vous avez effectuées ne seront pas enregistrées.
+
+
+
);
diff --git a/src/front/Components/Layouts/DeedTypes/DeedTypesEdit/index.tsx b/src/front/Components/Layouts/DeedTypes/DeedTypesEdit/index.tsx
index 5838bffc..3b5c8f24 100644
--- a/src/front/Components/Layouts/DeedTypes/DeedTypesEdit/index.tsx
+++ b/src/front/Components/Layouts/DeedTypes/DeedTypesEdit/index.tsx
@@ -3,6 +3,7 @@ import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
import Form from "@Front/Components/DesignSystem/Form";
import TextAreaField from "@Front/Components/DesignSystem/Form/TextareaField";
import TextField from "@Front/Components/DesignSystem/Form/TextField";
+import Confirm from "@Front/Components/DesignSystem/Modal/Confirm";
import Typography, { ITypo } from "@Front/Components/DesignSystem/Typography";
import DefaultDeedTypesDashboard from "@Front/Components/LayoutTemplates/DefaultDeedTypeDashboard";
import Module from "@Front/Config/Module";
@@ -17,8 +18,11 @@ export default function DeedTypesEdit() {
let { deedTypeUid } = router.query;
const [deedTypeSelected, setDeedTypeSelected] = useState(null);
+ const [hasChanged, setHasChanged] = useState(false);
+ const [isConfirmModalVisible, setIsConfirmModalVisible] = useState(false);
useEffect(() => {
+ setHasChanged(false);
async function getDeedType() {
if (!deedTypeUid) return;
const deedType = await DeedTypes.getInstance().getByUid(deedTypeUid as string, {
@@ -32,6 +36,10 @@ export default function DeedTypesEdit() {
getDeedType();
}, [deedTypeUid]);
+ const closeConfirmModal = useCallback(() => {
+ setIsConfirmModalVisible(false);
+ }, []);
+
const onSubmitHandler = useCallback(
async (e: React.FormEvent | null, values: { [key: string]: string }) => {
try {
@@ -55,20 +63,56 @@ export default function DeedTypesEdit() {
[deedTypeUid, router],
);
+ const onFieldChange = useCallback((name: string, field: any) => {
+ setHasChanged(true);
+ }, []);
+
+ const redirect = useCallback(() => {
+ router.push(
+ Module.getInstance()
+ .get()
+ .modules.pages.DeedTypes.pages.DeedTypesInformations.props.path.replace("[uid]", deedTypeUid as string),
+ );
+ }, [deedTypeUid, router]);
+
+ const onCancel = useCallback(() => {
+ if (hasChanged) {
+ setIsConfirmModalVisible(true);
+ } else {
+ redirect();
+ }
+ }, [hasChanged, redirect]);
+
return (
Modifier les informations de l'acte
-
+
+
+
+ Si vous quittez, toutes les modifications que vous avez effectuées ne seront pas enregistrées.
+
+
+
);
diff --git a/src/front/Components/Layouts/Offices/OfficeInformations/index.tsx b/src/front/Components/Layouts/Offices/OfficeInformations/index.tsx
index 56495989..eec32c9d 100644
--- a/src/front/Components/Layouts/Offices/OfficeInformations/index.tsx
+++ b/src/front/Components/Layouts/Offices/OfficeInformations/index.tsx
@@ -142,6 +142,9 @@ export default function OfficeInformations(props: IProps) {
if (!user.office_role && user.role?.name === "admin") {
return true;
}
+ if (!user.office_role && user.role?.name === "super-admin") {
+ return true;
+ }
return false;
})
.map((user) => {
@@ -173,13 +176,16 @@ export default function OfficeInformations(props: IProps) {
{officeSelected?.users
?.filter((user) => {
- if (user.office_role && user.office_role.name !== "admin") {
- return true;
+ if (user.office_role && user.office_role.name === "admin") {
+ return false;
}
- if (!user.office_role && user.role?.name !== "admin") {
- return true;
+ if (!user.office_role && user.role?.name === "admin") {
+ return false;
}
- return false;
+ if (!user.office_role && user.role?.name === "super-admin") {
+ return false;
+ }
+ return true;
})
.map((user) => {
return renderUser(user);