diff --git a/devops/ppd.values.yaml b/devops/ppd.values.yaml index f487465c..94725b64 100644 --- a/devops/ppd.values.yaml +++ b/devops/ppd.values.yaml @@ -1,6 +1,6 @@ dockerPullSecret: docker-pull-secret -scwSecretKey: AgCgjF5QEzxT3GYTS5B6cmQ0e+0/qFWzKaUDSi+Vjc7RoameuvaIJvTXMBkS3he1oy1ulbB34v6vpZI2kxnGNqERA/U5BaYDAyfKSBwMAy4br7HVKhhuwkoF5qoG5JzJXseSmqB1U9vncVIGOZWzJc1Y4/eGlWcvLcLyfw2z/WEpyeNiWJfEhTYpJOB7gv0XnRb2U/JM3jRy1QgEUIk1WR6kgBalF+xaczPQ6uKh+PR2pqkbZa3WaKUrddmzNsgEz4d8PZMWt8IBwR2JOQEHUqCd34p/pJNyLdUgcdDhg02DKwn1oRoAxKTbAio/a7WrMbodjCb3TNWIYGal5mFmItZ7Ok/EBmUf4E85eOkTR+j8ynuuiexld3Q5Kw3o8LsHjgzVL9uP+T2rYaKkjtVt+YQRX1U8l9CrsdUEz0/wEBA0jwCWMfnh1qhD5pM/xwwjsEEAcK4rYV+Q7iAgGZZvZBCQ5aEHzrtn5D95tr1GZCV2hmrW6Seu+LKKLVBS1JmsuEsOuhudYsEK9m2RYVcxbjuS5eokKEjNrGobf2oB8rhBByavfw1JTBixR5JrI8lcYlnCa+oEhxXKJY+4Fx5SAB4YaLCMSo5vw6zsFQ3WKQzlEmCFt+EnapS+a+MGrdlwq07OHTDpvgk/1z39hopoCuhhKckGGfErLXsTYQvDOkFu+EPzgY7m7qDw/d9pSiht5tuSOkAqeOgm7tpNkUufZhaXmP+1aT7i+H5gq1JILGAmXzTI5Wc= +scwSecretKey: AgChoEnPitXp4Ny/rVMEcevaWKNVpyj2cJYAcq+yFqKwVwnLB+ffDvwqz9XBHu+6d4Nyyjkf37zUAMoaM21lEDWA7x3zfG2/D/j+rvX1qxzZgLD0mjBk7fGElVm332I6JA83oInes8AMMYEDPLElzHnpKRb9KtkIP4NzgOcCeW0ijft3N7Vroez6LEHsBPCA1I9XjKSkGEDvrO0MhWX3iJOlfz+SPMfJAV7rPawOs0ZmohTHrPW8qIvGDn8HCzKyU8zRBoMt+Ogpf5pH4U3JryEFuqD61KAQgablAM8edPIvsgNno9HAEuC2QtRLYA9aUhuKdaKuS58c9P2E80PHWXIlbpFCg6EugQTgNfnYp+3qDUNz8edeCfapYLvF4s9eCMGyMsGnpDR8EDNOyuGy7Y3l7okX8Xqu464gMp9E+hX7bHkcD6a4xfyIgJcWxsku0tm1TH1dpn4M1UXRuyZZif8P08nuE6MTUL67sAR9J1lpn4lVEL4kflk0pP2tZ5ncgPQFafJrRz05krMb0eU5tb2H4gs7ao/LL6idWo8MM9K1yr8lIuT5x2WW5CX+RjA+i50ex114V6vX3PNP5oVyt+DynTUB9QmXzVm3oLfDc3Cae1uqh7X0CFd+xiztJBtg0VtJaD/xUJcuWfY4cV2lERo9fRrykltzlJqiXHO4nowt8OtN0BcViVV8NJhPhYFzyb4ympxpOlTjm3GETuT2TYhUqdgS9nzleEAbOmOHZdIO2COunPE= lecoffreFront: serviceAccountName: lecoffre-front-sa diff --git a/src/front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles.ts b/src/front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles.ts index 0c82cc4e..06691262 100644 --- a/src/front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles.ts +++ b/src/front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles.ts @@ -13,6 +13,11 @@ export type IPutRoleParams = { rules: OfficeRole["rules"]; }; +export type IPostRoleParams = { + name: OfficeRole["name"]; + office: OfficeRole["office"]; +}; + export default class OfficeRoles extends BaseAdmin { private static instance: OfficeRoles; private readonly baseURl = this.namespaceUrl.concat("/office-roles"); @@ -63,4 +68,14 @@ export default class OfficeRoles extends BaseAdmin { return Promise.reject(err); } } + + public async post(body: IPostRoleParams) { + const url = new URL(this.baseURl); + try { + return await this.postRequest(url, body); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } } diff --git a/src/front/Api/LeCoffreApi/Admin/Roles/Roles.ts b/src/front/Api/LeCoffreApi/Admin/Roles/Roles.ts index b0e51a69..88bfed5a 100644 --- a/src/front/Api/LeCoffreApi/Admin/Roles/Roles.ts +++ b/src/front/Api/LeCoffreApi/Admin/Roles/Roles.ts @@ -13,6 +13,9 @@ export type IPutRoleParams = { rules: Role["rules"]; }; +export type IPostRoleParams = { + name: Role["name"]; +}; export default class Roles extends BaseAdmin { private static instance: Roles; private readonly baseURl = this.namespaceUrl.concat("/roles"); @@ -43,6 +46,16 @@ export default class Roles extends BaseAdmin { } } + public async post(body: IPostRoleParams) { + const url = new URL(this.baseURl); + try { + return await this.postRequest(url, body); + } catch (err) { + this.onError(err); + return Promise.reject(err); + } + } + public async getOne(q?: IGetRolesParams): Promise { const url = new URL(this.baseURl); if (q) { diff --git a/src/front/Components/DesignSystem/Header/Notifications/NotificationModal/index.tsx b/src/front/Components/DesignSystem/Header/Notifications/NotificationModal/index.tsx index 183731ed..e0a9c9d1 100644 --- a/src/front/Components/DesignSystem/Header/Notifications/NotificationModal/index.tsx +++ b/src/front/Components/DesignSystem/Header/Notifications/NotificationModal/index.tsx @@ -32,7 +32,7 @@ export default class NotificationModal extends React.Component {
- Notifications + Notifications
Close notification modal
diff --git a/src/front/Components/LayoutTemplates/DefaultOfficeDashboard/OfficeListContainer/index.tsx b/src/front/Components/LayoutTemplates/DefaultOfficeDashboard/OfficeListContainer/index.tsx index 35138ab6..fec898d0 100644 --- a/src/front/Components/LayoutTemplates/DefaultOfficeDashboard/OfficeListContainer/index.tsx +++ b/src/front/Components/LayoutTemplates/DefaultOfficeDashboard/OfficeListContainer/index.tsx @@ -43,7 +43,7 @@ export default function OfficeListContainer(props: IProps) {
- +
+
+ + + +
); } diff --git a/src/front/Components/Layouts/DeedTypes/DeedTypesInformations/index.tsx b/src/front/Components/Layouts/DeedTypes/DeedTypesInformations/index.tsx index 631c4585..78035956 100644 --- a/src/front/Components/Layouts/DeedTypes/DeedTypesInformations/index.tsx +++ b/src/front/Components/Layouts/DeedTypes/DeedTypesInformations/index.tsx @@ -142,7 +142,7 @@ export default function DeedTypesInformations(props: IProps) {
diff --git a/src/front/Components/Layouts/Offices/index.tsx b/src/front/Components/Layouts/Offices/index.tsx index 67ba24fc..1427203c 100644 --- a/src/front/Components/Layouts/Offices/index.tsx +++ b/src/front/Components/Layouts/Offices/index.tsx @@ -15,7 +15,7 @@ export default class Offices extends BasePage { Informations des offices
- Sélectionnez une office + Sélectionnez un office
diff --git a/src/front/Components/Layouts/Roles/RolesCreate/classes.module.scss b/src/front/Components/Layouts/Roles/RolesCreate/classes.module.scss new file mode 100644 index 00000000..848ef4bc --- /dev/null +++ b/src/front/Components/Layouts/Roles/RolesCreate/classes.module.scss @@ -0,0 +1,24 @@ +@import "@Themes/constants.scss"; + +.root { + .header { + margin-top: 24px; + } + + .form-container { + margin-top: 32px; + display: flex; + flex-direction: column; + gap: 32px; + } + + .buttons-container { + display: flex; + gap: 32px; + + @media (max-width: $screen-s) { + flex-direction: column-reverse; + gap: 16px; + } + } +} diff --git a/src/front/Components/Layouts/Roles/RolesCreate/index.tsx b/src/front/Components/Layouts/Roles/RolesCreate/index.tsx new file mode 100644 index 00000000..0fbbd749 --- /dev/null +++ b/src/front/Components/Layouts/Roles/RolesCreate/index.tsx @@ -0,0 +1,95 @@ +import OfficeRoles from "@Front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles"; +import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; +import Form from "@Front/Components/DesignSystem/Form"; +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 DefaultRolesDashboard from "@Front/Components/LayoutTemplates/DefaultRoleDashboard"; +import Module from "@Front/Config/Module"; +import { Office, OfficeRole } from "le-coffre-resources/dist/Admin"; +import { useRouter } from "next/router"; +import { useCallback, useState } from "react"; + +import classes from "./classes.module.scss"; +import JwtService from "@Front/Services/JwtService/JwtService"; + +type IProps = {}; +export default function RolesCreate(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 }) => { + try { + const jwt = JwtService.getInstance().decodeJwt(); + const role = await OfficeRoles.getInstance().post( + OfficeRole.hydrate({ + name: values["name"], + office: Office.hydrate({ + uid: jwt?.office_Id, + }), + }), + ); + + router.push(Module.getInstance().get().modules.pages.Roles.pages.RolesInformations.props.path.replace("[uid]", role.uid!)); + } catch (e) { + console.error(e); + } + }, + [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.Roles.props.path); + }, [router]); + + const onCancel = useCallback(() => { + if (hasChanged) { + setIsConfirmModalVisible(true); + } else { + redirect(); + } + }, [hasChanged, redirect]); + + return ( + +
+
+ Créer un rôle +
+
+ +
+ + +
+ + +
+ + Si vous quittez, toutes les modifications que vous avez effectuées ne seront pas enregistrées. + +
+
+
+
+ ); +} diff --git a/src/front/Config/Module/development.json b/src/front/Config/Module/development.json index 187d64de..b2464999 100644 --- a/src/front/Config/Module/development.json +++ b/src/front/Config/Module/development.json @@ -155,6 +155,13 @@ "path": "/roles/[uid]", "labelKey": "roles_informations" } + }, + "Create": { + "enabled": true, + "props": { + "path": "/roles/create", + "labelKey": "create_role" + } } } }, diff --git a/src/front/Config/Module/preprod.json b/src/front/Config/Module/preprod.json index 187d64de..b2464999 100644 --- a/src/front/Config/Module/preprod.json +++ b/src/front/Config/Module/preprod.json @@ -155,6 +155,13 @@ "path": "/roles/[uid]", "labelKey": "roles_informations" } + }, + "Create": { + "enabled": true, + "props": { + "path": "/roles/create", + "labelKey": "create_role" + } } } }, diff --git a/src/front/Config/Module/production.json b/src/front/Config/Module/production.json index 187d64de..b2464999 100644 --- a/src/front/Config/Module/production.json +++ b/src/front/Config/Module/production.json @@ -155,6 +155,13 @@ "path": "/roles/[uid]", "labelKey": "roles_informations" } + }, + "Create": { + "enabled": true, + "props": { + "path": "/roles/create", + "labelKey": "create_role" + } } } }, diff --git a/src/front/Config/Module/staging.json b/src/front/Config/Module/staging.json index 187d64de..b2464999 100644 --- a/src/front/Config/Module/staging.json +++ b/src/front/Config/Module/staging.json @@ -155,6 +155,13 @@ "path": "/roles/[uid]", "labelKey": "roles_informations" } + }, + "Create": { + "enabled": true, + "props": { + "path": "/roles/create", + "labelKey": "create_role" + } } } }, diff --git a/src/pages/roles/create/index.tsx b/src/pages/roles/create/index.tsx new file mode 100644 index 00000000..a947ffeb --- /dev/null +++ b/src/pages/roles/create/index.tsx @@ -0,0 +1,5 @@ +import RolesCreate from "@Front/Components/Layouts/Roles/RolesCreate"; + +export default function Route() { + return ; +}