Merge branch 'dev' into staging

This commit is contained in:
Vins 2023-10-09 12:19:50 +02:00
commit 1092229e6b
11 changed files with 123 additions and 147 deletions

139
package-lock.json generated
View File

@ -22,7 +22,7 @@
"eslint-config-next": "13.2.4",
"form-data": "^4.0.0",
"jwt-decode": "^3.1.2",
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.89",
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.90",
"next": "13.2.4",
"prettier": "^2.8.7",
"react": "18.2.0",
@ -496,14 +496,14 @@
"integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA=="
},
"node_modules/@mui/base": {
"version": "5.0.0-beta.17",
"resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-beta.17.tgz",
"integrity": "sha512-xNbk7iOXrglNdIxFBN0k3ySsPIFLWCnFxqsAYl7CIcDkD9low4kJ7IUuy6ctwx/HAy2fenrT3KXHr1sGjAMgpQ==",
"version": "5.0.0-beta.18",
"resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-beta.18.tgz",
"integrity": "sha512-e9ZCy/ndhyt5MTshAS3qAUy/40UiO0jX+kAo6a+XirrPJE+rrQW+mKPSI0uyp+5z4Vh+z0pvNoJ2S2gSrNz3BQ==",
"dependencies": {
"@babel/runtime": "^7.22.15",
"@babel/runtime": "^7.23.1",
"@floating-ui/react-dom": "^2.0.2",
"@mui/types": "^7.2.4",
"@mui/utils": "^5.14.11",
"@mui/types": "^7.2.5",
"@mui/utils": "^5.14.12",
"@popperjs/core": "^2.11.8",
"clsx": "^2.0.0",
"prop-types": "^15.8.1"
@ -527,25 +527,25 @@
}
},
"node_modules/@mui/core-downloads-tracker": {
"version": "5.14.11",
"resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.14.11.tgz",
"integrity": "sha512-uY8FLQURhXe3f3O4dS5OSGML9KDm9+IE226cBu78jarVIzdQGPlXwGIlSI9VJR8MvZDA6C0+6XfWDhWCHruC5Q==",
"version": "5.14.12",
"resolved": "https://registry.npmjs.org/@mui/core-downloads-tracker/-/core-downloads-tracker-5.14.12.tgz",
"integrity": "sha512-WZhCkKqhrXaSVBzoC6LNcVkIawS000OOt7gmnp4g9HhyvN0PSclRXc/JrkC7EwfzUAZJh+hiK2LaVsbtOpNuOg==",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/mui"
}
},
"node_modules/@mui/material": {
"version": "5.14.11",
"resolved": "https://registry.npmjs.org/@mui/material/-/material-5.14.11.tgz",
"integrity": "sha512-DnSdJzcR7lwG12JA5L2t8JF+RDzMygu5rCNW+logWb/KW2/TRzwLyVWO+CorHTBjBRd38DBxnwOCDiYkDd+N3A==",
"version": "5.14.12",
"resolved": "https://registry.npmjs.org/@mui/material/-/material-5.14.12.tgz",
"integrity": "sha512-EelF2L46VcVqhg3KjzIGBBpOtcBgRh0MMy9Efuk6Do81QdcZsFC9RebCVAflo5jIdbHiBmxBs5/l5Q9NjONozg==",
"dependencies": {
"@babel/runtime": "^7.22.15",
"@mui/base": "5.0.0-beta.17",
"@mui/core-downloads-tracker": "^5.14.11",
"@mui/system": "^5.14.11",
"@mui/types": "^7.2.4",
"@mui/utils": "^5.14.11",
"@babel/runtime": "^7.23.1",
"@mui/base": "5.0.0-beta.18",
"@mui/core-downloads-tracker": "^5.14.12",
"@mui/system": "^5.14.12",
"@mui/types": "^7.2.5",
"@mui/utils": "^5.14.12",
"@types/react-transition-group": "^4.4.6",
"clsx": "^2.0.0",
"csstype": "^3.1.2",
@ -580,12 +580,12 @@
}
},
"node_modules/@mui/private-theming": {
"version": "5.14.11",
"resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.14.11.tgz",
"integrity": "sha512-MSnNNzTu9pfKLCKs1ZAKwOTgE4bz+fQA0fNr8Jm7NDmuWmw0CaN9Vq2/MHsatE7+S0A25IAKby46Uv1u53rKVQ==",
"version": "5.14.12",
"resolved": "https://registry.npmjs.org/@mui/private-theming/-/private-theming-5.14.12.tgz",
"integrity": "sha512-TWwm+9+BgHFpoR3w04FG+IqID4ALa74A27RuKq2CEaWgxliBZB24EVeI6djfjFt5t4FYmIb8BMw2ZJEir7YjLQ==",
"dependencies": {
"@babel/runtime": "^7.22.15",
"@mui/utils": "^5.14.11",
"@babel/runtime": "^7.23.1",
"@mui/utils": "^5.14.12",
"prop-types": "^15.8.1"
},
"engines": {
@ -606,11 +606,11 @@
}
},
"node_modules/@mui/styled-engine": {
"version": "5.14.11",
"resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.14.11.tgz",
"integrity": "sha512-jdUlqRgTYQ8RMtPX4MbRZqar6W2OiIb6J5KEFbIu4FqvPrk44Each4ppg/LAqp1qNlBYq5i+7Q10MYLMpDxX9A==",
"version": "5.14.12",
"resolved": "https://registry.npmjs.org/@mui/styled-engine/-/styled-engine-5.14.12.tgz",
"integrity": "sha512-bocxt1nDmXfB3gpLfCCmFCyJ7sVmscFs+PuheO210QagZwHVp47UIRT1AiswLDYSQo1ZqmVGn7KLEJEYK0d4Xw==",
"dependencies": {
"@babel/runtime": "^7.22.15",
"@babel/runtime": "^7.23.1",
"@emotion/cache": "^11.11.0",
"csstype": "^3.1.2",
"prop-types": "^15.8.1"
@ -637,15 +637,15 @@
}
},
"node_modules/@mui/system": {
"version": "5.14.11",
"resolved": "https://registry.npmjs.org/@mui/system/-/system-5.14.11.tgz",
"integrity": "sha512-yl8xV+y0k7j6dzBsHabKwoShmjqLa8kTxrhUI3JpqLG358VRVMJRW/ES0HhvfcCi4IVXde+Tc2P3K1akGL8zoA==",
"version": "5.14.12",
"resolved": "https://registry.npmjs.org/@mui/system/-/system-5.14.12.tgz",
"integrity": "sha512-6DXfjjLhW0/ia5qU3Crke7j+MnfDbMBOHlLIrqbrEqNs0AuSBv8pXniEGb+kqO0H804NJreRTEJRjCngwOX5CA==",
"dependencies": {
"@babel/runtime": "^7.22.15",
"@mui/private-theming": "^5.14.11",
"@mui/styled-engine": "^5.14.11",
"@mui/types": "^7.2.4",
"@mui/utils": "^5.14.11",
"@babel/runtime": "^7.23.1",
"@mui/private-theming": "^5.14.12",
"@mui/styled-engine": "^5.14.12",
"@mui/types": "^7.2.5",
"@mui/utils": "^5.14.12",
"clsx": "^2.0.0",
"csstype": "^3.1.2",
"prop-types": "^15.8.1"
@ -676,11 +676,11 @@
}
},
"node_modules/@mui/types": {
"version": "7.2.4",
"resolved": "https://registry.npmjs.org/@mui/types/-/types-7.2.4.tgz",
"integrity": "sha512-LBcwa8rN84bKF+f5sDyku42w1NTxaPgPyYKODsh01U1fVstTClbUoSA96oyRBnSNyEiAVjKm6Gwx9vjR+xyqHA==",
"version": "7.2.5",
"resolved": "https://registry.npmjs.org/@mui/types/-/types-7.2.5.tgz",
"integrity": "sha512-S2BwfNczr7VwS6ki8GoAXJyARoeSJDLuxOEPs3vEMyTALlf9PrdHv+sluX7kk3iKrCg/ML2mIWwapZvWbkMCQA==",
"peerDependencies": {
"@types/react": "*"
"@types/react": "^17.0.0 || ^18.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
@ -689,12 +689,12 @@
}
},
"node_modules/@mui/utils": {
"version": "5.14.11",
"resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.14.11.tgz",
"integrity": "sha512-fmkIiCPKyDssYrJ5qk+dime1nlO3dmWfCtaPY/uVBqCRMBZ11JhddB9m8sjI2mgqQQwRJG5bq3biaosNdU/s4Q==",
"version": "5.14.12",
"resolved": "https://registry.npmjs.org/@mui/utils/-/utils-5.14.12.tgz",
"integrity": "sha512-RFNXnhKQlzIkIUig6mmv0r5VbtjPdWoaBPYicq25LETdZux59HAqoRdWw15T7lp3c7gXOoE8y67+hTB8C64m2g==",
"dependencies": {
"@babel/runtime": "^7.22.15",
"@types/prop-types": "^15.7.5",
"@babel/runtime": "^7.23.1",
"@types/prop-types": "^15.7.7",
"prop-types": "^15.8.1",
"react-is": "^18.2.0"
},
@ -1507,9 +1507,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001543",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001543.tgz",
"integrity": "sha512-qxdO8KPWPQ+Zk6bvNpPeQIOH47qZSYdFZd6dXQzb2KzhnSXju4Kd7H1PkSJx6NICSMgo/IhRZRhhfPTHYpJUCA==",
"version": "1.0.30001546",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001546.tgz",
"integrity": "sha512-zvtSJwuQFpewSyRrI3AsftF6rM0X80mZkChIt1spBGEvRglCrjTniXvinc8JKRoqTwXAgvqTImaN9igfSMtUBw==",
"funding": [
{
"type": "opencollective",
@ -2518,11 +2518,11 @@
}
},
"node_modules/flat-cache": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.1.0.tgz",
"integrity": "sha512-OHx4Qwrrt0E4jEIcI5/Xb+f+QmJYNj2rrK8wiIdQOIrB9WrrJL8cjZvXdXuBTkkEwEqLycb5BeZDV1o2i9bTew==",
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.1.1.tgz",
"integrity": "sha512-/qM2b3LUIaIgviBQovTLvijfyOQXPtSRnRK26ksj2J7rzPIecePUIpJsZ4T02Qg+xiAEKIs5K8dsHEd+VaKa/Q==",
"dependencies": {
"flatted": "^3.2.7",
"flatted": "^3.2.9",
"keyv": "^4.5.3",
"rimraf": "^3.0.2"
},
@ -2685,9 +2685,9 @@
}
},
"node_modules/globals": {
"version": "13.22.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.22.0.tgz",
"integrity": "sha512-H1Ddc/PbZHTDVJSnj8kWptIRSD6AM3pK+mKytuIVF4uoBV7rshFlhhvA58ceJ5wp3Er58w6zj7bykMpYXt3ETw==",
"version": "13.23.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz",
"integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==",
"dependencies": {
"type-fest": "^0.20.2"
},
@ -2764,12 +2764,9 @@
"integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ=="
},
"node_modules/has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dependencies": {
"function-bind": "^1.1.1"
},
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.4.tgz",
"integrity": "sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ==",
"engines": {
"node": ">= 0.4.0"
}
@ -3340,9 +3337,9 @@
"integrity": "sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A=="
},
"node_modules/keyv": {
"version": "4.5.3",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.3.tgz",
"integrity": "sha512-QCiSav9WaX1PgETJ+SpNnx2PRRapJ/oRSXM4VO5OGYGSjrxbKPVFVhB3l2OCbLCk329N8qyAtsJjSjvVBWzEug==",
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
"integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==",
"dependencies": {
"json-buffer": "3.0.1"
}
@ -3361,7 +3358,7 @@
}
},
"node_modules/le-coffre-resources": {
"resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#a100398ef5c1984ba74cb1c8c182648315accc3e",
"resolved": "git+ssh://git@github.com/smart-chain-fr/leCoffre-resources.git#16baf46d39953bb19fa5b9e614ae4f72895aff31",
"license": "MIT",
"dependencies": {
"class-transformer": "^0.5.1",
@ -3382,9 +3379,9 @@
}
},
"node_modules/libphonenumber-js": {
"version": "1.10.45",
"resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.45.tgz",
"integrity": "sha512-eeHcvGafEYCaKB4fo2uBINfG7j7PcGwBHUaTVfbwl/6KcjCgIKNlIOsSXVRp9BH10NQwmvvk+nQ1e/Yp4BGB7w=="
"version": "1.10.47",
"resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.47.tgz",
"integrity": "sha512-b4t7VQDV29xx/ni+58yl9KWPGjnDLDXCeCTLrD4V8vDpObXZRZBrg7uX/HWZ7YXiJKqdBDGgc+barUUTNB6Slw=="
},
"node_modules/lines-and-columns": {
"version": "1.2.4",
@ -4297,9 +4294,9 @@
}
},
"node_modules/sass": {
"version": "1.68.0",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.68.0.tgz",
"integrity": "sha512-Lmj9lM/fef0nQswm1J2HJcEsBUba4wgNx2fea6yJHODREoMFnwRpZydBnX/RjyXw2REIwdkbqE4hrTo4qfDBUA==",
"version": "1.69.0",
"resolved": "https://registry.npmjs.org/sass/-/sass-1.69.0.tgz",
"integrity": "sha512-l3bbFpfTOGgQZCLU/gvm1lbsQ5mC/WnLz3djL2v4WCJBDrWm58PO+jgngcGRNnKUh6wSsdm50YaovTqskZ0xDQ==",
"dependencies": {
"chokidar": ">=3.0.0 <4.0.0",
"immutable": "^4.0.0",

View File

@ -71,6 +71,18 @@ export default class Documents extends BaseNotary {
}
}
public async refuse(uid: string, refused_reason: string): Promise<Document> {
const url = new URL(this.baseURl.concat(`/${uid}/refuse`));
try {
return await this.putRequest<Document>(url, {
refused_reason,
});
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
public async put(uid: string, body: IPutDocumentsParams): Promise<Document> {
const url = new URL(this.baseURl.concat(`/${uid}`));
try {

View File

@ -30,6 +30,15 @@
cursor: pointer;
}
}
.notification-subheader {
width: 100%;
display: inline-flex;
justify-content: space-between;
text-decoration: underline;
cursor: pointer;
}
.notification-body {
margin-top: 24px;
overflow: hidden;

View File

@ -37,10 +37,12 @@ export default class NotificationModal extends React.Component<IProps, IState> {
<Image src={CloseIcon} alt="Close notification modal" className={classes["close-icon"]}></Image>
</div>
</div>
;
<div className={classes["notification-subheader"]} onClick={this.readAllNotifications}>
<Typography typo={ITypo.CAPTION_14}>Tout marquer comme lu</Typography>
</div>
<div className={classes["notification-body"]}>
<>
{Toasts.getInstance().toasts.length === 0 ? (
{!this.state.toastList || this.state.toastList.length === 0 ? (
<div className={classes["missing-notification"]}>
<Typography typo={ITypo.P_18} color={ITypoColor.GREY}>
Vous n'avez pas de notifications.
@ -64,6 +66,10 @@ export default class NotificationModal extends React.Component<IProps, IState> {
this.removeOnToastChange();
}
private readAllNotifications() {
Toasts.getInstance().closeAll();
}
private handleToastChange(toastList: IToast[] | null) {
this.setState({
toastList,

View File

@ -95,6 +95,7 @@
font-size: 14px;
line-height: 20px;
color: var(--color-neutral-500);
word-break: break-word;
}
a {

View File

@ -109,7 +109,6 @@ class ToastElementClass extends React.Component<IPropsClass, IState> {
}
private async handleClick(e: React.MouseEvent) {
console.log('redirectUrl', this.props.toast.redirectUrl);
if (this.props.toast.redirectUrl) {
this.onClose(e);
await this.props.router.push(this.props.toast.redirectUrl);

View File

@ -126,7 +126,6 @@ export default class UserFolder extends React.Component<IProps, IState> {
Demander un autre document{" "}
</Button>
</Link>
<Button disabled={documentsAsked ? false : true}>Envoyer un mail de demande</Button>
</div>
)}
</div>

View File

@ -132,7 +132,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
<>
{this.props.isAnchored === AnchorStatus.NOT_ANCHORED && (
<Button variant={EButtonVariant.PRIMARY} onClick={this.openValidateModal}>
Ancrer le dossier
Valider et ancrer
</Button>
)}
{this.props.isAnchored === AnchorStatus.ANCHORING && (
@ -250,9 +250,6 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
rédaction d'acte.
</Typography>
<Image src={ValidateAnchoringGif} alt="Anchoring animation" className={classes["validate-gif"]} />
<div className={classes["dont-show-again"]}>
<CheckBox option={{ label: "Ne plus afficher ce message", value: false }} />
</div>
</div>
)}
</div>

View File

@ -275,10 +275,7 @@ class ViewDocumentsClass extends BasePage<IPropsClass, IState> {
private async refuseDocument() {
try {
await Documents.getInstance().put(this.props.documentUid, {
document_status: EDocumentStatus.REFUSED,
refused_reason: this.state.refuseText,
});
await Documents.getInstance().refuse(this.props.documentUid, this.state.refuseText);
this.props.router.push(
Module.getInstance()

View File

@ -4,20 +4,20 @@ import Roles from "@Front/Api/LeCoffreApi/Admin/Roles/Roles";
import LiveVotes from "@Front/Api/LeCoffreApi/SuperAdmin/LiveVotes/LiveVotes";
import Users from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users";
import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button";
import SelectField, { IOption } from "@Front/Components/DesignSystem/Form/SelectField";
import Confirm from "@Front/Components/DesignSystem/Modal/Confirm";
import Switch from "@Front/Components/DesignSystem/Switch";
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
import DefaultUserDashboard from "@Front/Components/LayoutTemplates/DefaultUserDashboard";
import JwtService from "@Front/Services/JwtService/JwtService";
import Toasts from "@Front/Stores/Toasts";
import User, { Appointment, OfficeRole, Vote } from "le-coffre-resources/dist/SuperAdmin";
import User, { Appointment, Vote } from "le-coffre-resources/dist/SuperAdmin";
import { EAppointmentStatus, EVote } from "le-coffre-resources/dist/SuperAdmin/Appointment";
import Image from "next/image";
import { useRouter } from "next/router";
import { useCallback, useEffect, useState } from "react";
import classes from "./classes.module.scss";
import OfficeRoles from "@Front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles";
type IProps = {};
export default function UserInformations(props: IProps) {
@ -25,9 +25,7 @@ export default function UserInformations(props: IProps) {
let { userUid } = router.query;
const [userSelected, setUserSelected] = useState<User | null>(null);
const [availableRoles, setAvailableRoles] = useState<IOption[]>([]);
const [roleModalOpened, setRoleModalOpened] = useState<boolean>(false);
const [isSuperAdminModalOpened, setIsSuperAdminModalOpened] = useState<boolean>(false);
const [superAdminModalType, setSuperAdminModalType] = useState<"add" | "remove">("add");
const [adminModalType, setAdminModalType] = useState<"add" | "remove">("add");
@ -36,15 +34,8 @@ export default function UserInformations(props: IProps) {
const [isAdminChecked, setIsAdminChecked] = useState<boolean>(false);
const [isAdminModalOpened, setIsAdminModalOpened] = useState<boolean>(false);
const [selectedOption, setSelectedOption] = useState<IOption | null>(null);
const [currentAppointment, setCurrentAppointment] = useState<Appointment | null>(null);
const handleRoleChange = useCallback((option: IOption) => {
setSelectedOption(option);
setRoleModalOpened(true);
}, []);
/** When page change, get the user of the page */
const getUser = useCallback(async () => {
@ -68,11 +59,13 @@ export default function UserInformations(props: IProps) {
},
});
if (!user) return;
const roles = await Roles.getInstance().get({
where: {NOT: {OR:[{name: "super-admin"}, {name: "admin"}]}},
const roles = await OfficeRoles.getInstance().get({
where: {
office: { uid: user.office_membership?.uid },
NOT: { OR: [{ name: "super-admin" }, { name: "admin" }] },
},
});
if (!roles) return
setAvailableRoles(roles.map((role) => ({ value: role.uid, label: role.label })));
if (!roles) return;
setUserSelected(user);
}, [userUid]);
@ -140,8 +133,9 @@ export default function UserInformations(props: IProps) {
}),
);
}
getUser();
setIsAdminModalOpened(false);
}, [userSelected, adminModalType]);
}, [userSelected, adminModalType, getUser]);
/** Functions for the super admin modal */
const openSuperAdminModal = () => {
@ -183,28 +177,6 @@ export default function UserInformations(props: IProps) {
setIsSuperAdminModalOpened(false);
}, [userSelected, currentAppointment, superAdminModalType, getUser]);
const closeRoleModal = useCallback(() => {
setRoleModalOpened(false);
setSelectedOption({
value: userSelected?.office_role ? userSelected?.office_role?.uid : userSelected?.role?.uid,
label: userSelected?.office_role ? userSelected?.office_role?.name : userSelected?.role?.label!,
});
}, [userSelected?.office_role, userSelected?.role?.label, userSelected?.role?.uid]);
const changeRole = useCallback(async () => {
await Users.getInstance().put(
userSelected?.uid as string,
User.hydrate<User>({
uid: userSelected?.uid as string,
office_role: OfficeRole.hydrate<OfficeRole>({
uid: selectedOption?.value as string,
}),
}),
);
setRoleModalOpened(false);
getUser();
}, [getUser, selectedOption?.value, userSelected?.uid]);
/** Reset switch state when userSelect change */
useEffect(() => {
if (!userSelected) return;
@ -269,16 +241,9 @@ export default function UserInformations(props: IProps) {
<Typography typo={ITypo.P_SB_18}>Rôle au sein de son office</Typography>
</div>
<div className={classes["second-line"]}>
<SelectField
placeholder="Rôle"
name="role"
options={availableRoles.filter((role) => role.label !== "admin")}
onChange={handleRoleChange}
selectedOption={{
value: userSelected?.office_role ? userSelected?.office_role?.uid : userSelected?.role?.uid,
label: userSelected?.office_role ? userSelected?.office_role?.name : "Utilisateur restreint",
}}
/>
<Typography typo={ITypo.P_18}>
{userSelected?.office_role ? userSelected?.office_role?.name : "Utilisateur restreint"}
</Typography>
</div>
</div>
<div className={classes["part"]}>
@ -286,7 +251,7 @@ export default function UserInformations(props: IProps) {
<Typography typo={ITypo.P_SB_18}>Attribuer un titre</Typography>
</div>
<div className={classes["second-line"]}>
{!isSuperAdminChecked && (
{!isSuperAdminChecked && !currentAppointment && (
<Switch label="Admin de son office" checked={isAdminChecked} onChange={handleAdminChanged} />
)}
@ -329,21 +294,6 @@ export default function UserInformations(props: IProps) {
</div>
</div>
</div>
<Confirm
isOpen={roleModalOpened}
onClose={closeRoleModal}
onAccept={changeRole}
closeBtn
header={"Changement de rôle"}
confirmText={"Valider"}
cancelText={"Annuler"}>
<div className={classes["modal-content"]}>
<Typography typo={ITypo.P_16} className={classes["text"]}>
Attribuer le rôle de <span className={classes["role-name"]}>{selectedOption?.label}</span> à{" "}
{userSelected?.contact?.first_name} {userSelected?.contact?.last_name} ?
</Typography>
</div>
</Confirm>
<Confirm
isOpen={isSuperAdminModalOpened}
onClose={closeSuperAdminModal}

View File

@ -97,6 +97,15 @@ export default class Toasts {
this.event.emit("change", this.toastList);
}
public async closeAll() {
for (let i = 0; i < this.toastList.length; i++) {
await Notifications.getInstance().put(this.toastList[i]?.uid as string, {
read: true,
});
}
this.event.emit("change", []);
}
/**
* An utility static method you can use to quickly display an error toast
* with a custom error message.