Merge branch 'dev' into staging

This commit is contained in:
Maxime Lalo 2023-10-02 14:21:15 +02:00
commit adb38fd35c
9 changed files with 86 additions and 69 deletions

30
package-lock.json generated
View File

@ -461,9 +461,9 @@
}
},
"node_modules/@floating-ui/utils": {
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.1.4.tgz",
"integrity": "sha512-qprfWkn82Iw821mcKofJ5Pk9wgioHicxcQMxx+5zt5GSKoqdWvgG5AxVmpmUUjzTLPVSH5auBrhI93Deayn/DA=="
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/@floating-ui/utils/-/utils-0.1.6.tgz",
"integrity": "sha512-OfX7E2oUDYxtBvsuS4e/jSn4Q9Qb6DzgeYtsAdkPZ47znpoNsMgZw0+tVijiv3uGNR6dgNlty6r9rzIzHjtd/A=="
},
"node_modules/@humanwhocodes/config-array": {
"version": "0.11.11",
@ -965,9 +965,9 @@
}
},
"node_modules/@rushstack/eslint-patch": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.5.0.tgz",
"integrity": "sha512-EF3948ckf3f5uPgYbQ6GhyA56Dmv8yg0+ir+BroRjwdxyZJsekhZzawOecC2rOTPCz173t7ZcR1HHZu0dZgOCw=="
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.5.1.tgz",
"integrity": "sha512-6i/8UoL0P5y4leBIGzvkZdS85RDMG9y1ihZzmTZQ5LdHUYmZ7pKFoj8X0236s3lusPs1Fa5HTQUpwI+UfTcmeA=="
},
"node_modules/@swc/helpers": {
"version": "0.4.14",
@ -993,9 +993,9 @@
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA=="
},
"node_modules/@types/prop-types": {
"version": "15.7.7",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.7.tgz",
"integrity": "sha512-FbtmBWCcSa2J4zL781Zf1p5YUBXQomPEcep9QZCfRfQgTxz3pJWiDFLebohZ9fFntX5ibzOkSsrJ0TEew8cAog=="
"version": "15.7.8",
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.8.tgz",
"integrity": "sha512-kMpQpfZKSCBqltAJwskgePRaYRFukDkm1oItcAbC3gNELR20XIBcN9VRgg4+m8DKsTfkWeA4m4Imp4DDuWy7FQ=="
},
"node_modules/@types/react": {
"version": "18.0.28",
@ -1507,9 +1507,9 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001541",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001541.tgz",
"integrity": "sha512-bLOsqxDgTqUBkzxbNlSBt8annkDpQB9NdzdTbO2ooJ+eC/IQcvDspDc058g84ejCelF7vHUx57KIOjEecOHXaw==",
"version": "1.0.30001542",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001542.tgz",
"integrity": "sha512-UrtAXVcj1mvPBFQ4sKd38daP8dEcXXr5sQe6QNNinaPd0iA/cxg9/l3VrSdL73jgw5sKyuQ6jNgiKO12W3SsVA==",
"funding": [
{
"type": "opencollective",
@ -4067,9 +4067,9 @@
"integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w=="
},
"node_modules/react-select": {
"version": "5.7.5",
"resolved": "https://registry.npmjs.org/react-select/-/react-select-5.7.5.tgz",
"integrity": "sha512-jgYZa2xgKP0DVn5GZk7tZwbRx7kaVz1VqU41S8z1KWmshRDhlrpKS0w80aS1RaK5bVIXpttgSou7XCjWw1ncKA==",
"version": "5.7.7",
"resolved": "https://registry.npmjs.org/react-select/-/react-select-5.7.7.tgz",
"integrity": "sha512-HhashZZJDRlfF/AKj0a0Lnfs3sRdw/46VJIRd8IbB9/Ovr74+ZIwkAdSBjSPXsFMG+u72c5xShqwLSKIJllzqw==",
"dependencies": {
"@babel/runtime": "^7.12.0",
"@emotion/cache": "^11.4.0",

View File

@ -24,7 +24,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.85",
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.88",
"next": "13.2.4",
"prettier": "^2.8.7",
"react": "18.2.0",

View File

@ -15,5 +15,6 @@ export enum AppRuleNames {
officeFolders = "folders",
officeRoles = "office-roles",
deedTypes = "deed-types",
offices = "offices"
offices = "offices",
documents = "documents",
}

View File

@ -1,4 +1,4 @@
import { Appointment } from "le-coffre-resources/dist/SuperAdmin";
import { Appointment, Vote } from "le-coffre-resources/dist/SuperAdmin";
import BaseSuperAdmin from "../BaseSuperAdmin";
@ -18,6 +18,9 @@ export type LiveVote = {
appointment: Appointment;
};
export type IDeleteVotesParams = {
uid: Vote["uid"];
};
export default class LiveVotes extends BaseSuperAdmin {
private static instance: LiveVotes;
private readonly baseURl = this.namespaceUrl.concat("/live-votes");
@ -46,4 +49,17 @@ export default class LiveVotes extends BaseSuperAdmin {
return Promise.reject(err);
}
}
/**
* @description : Delete a vote
*/
public async delete(body: IDeleteVotesParams): Promise<Vote> {
const url = new URL(`${this.baseURl}/${body.uid}`);
try {
return await this.deleteRequest<Vote>(url, body);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
}

View File

@ -1,44 +0,0 @@
import { Vote } from "le-coffre-resources/dist/SuperAdmin";
import BaseSuperAdmin from "../BaseSuperAdmin";
// TODO Type get query params -> Where + inclue + orderby
export interface IGetVotessparams {
where?: {};
include?: {};
select?: {};
}
export type IDeleteVotesParams = {
uid: Vote["uid"];
};
export default class Votes extends BaseSuperAdmin {
private static instance: Votes;
private readonly baseURl = this.namespaceUrl.concat("/votes");
private constructor() {
super();
}
public static getInstance() {
if (!this.instance) {
return new this();
} else {
return this.instance;
}
}
/**
* @description : Create a Votes
*/
public async delete(body: IDeleteVotesParams): Promise<Vote> {
const url = new URL(this.baseURl + "/" + body.uid);
try {
return await this.deleteRequest<Vote>(url, body);
} catch (err) {
this.onError(err);
return Promise.reject(err);
}
}
}

View File

@ -71,7 +71,7 @@ export default class DepositOtherDocument extends React.Component<IProps, IState
return (
<Confirm
isOpen={this.state.isAddDocumentModalVisible}
onClose={() => {}}
onClose={this.props.onClose!}
onAccept={this.onAccept}
closeBtn
header={"Ajouter un document"}

View File

@ -10,6 +10,8 @@ import Typography, { ITypo } from "../../Typography";
import WarningBadge from "../../WarningBadge";
import classes from "./classes.module.scss";
import { EDocumentStatus } from "le-coffre-resources/dist/Customer/Document";
import Rules, { RulesMode } from "@Front/Components/Elements/Rules";
import { AppRuleActions, AppRuleNames } from "@Front/Api/Entities/rule";
type IProps = {
folderUid: string;
@ -60,8 +62,11 @@ class DocumentNotaryClass extends React.Component<IPropsClass, IState> {
} else {
const archivedFilesLength = documentFiles.filter((file) => file.archived_at).length;
const documentFileLength = documentFiles.length - archivedFilesLength;
if(this.props.document.document_status === EDocumentStatus.ASKED || this.props.document.document_status === EDocumentStatus.REFUSED){
return 'Aucun document déposé';
if (
this.props.document.document_status === EDocumentStatus.ASKED ||
this.props.document.document_status === EDocumentStatus.REFUSED
) {
return "Aucun document déposé";
}
return `${documentFileLength} documents déposés`;
@ -91,7 +96,18 @@ class DocumentNotaryClass extends React.Component<IPropsClass, IState> {
case EDocumentStatus.DEPOSITED:
return <WarningBadge />;
default:
return <Image src={TrashIcon} alt="trash icon" className={classes["trash"]} onClick={this.onOpenDeletionModal} />;
return (
<Rules
mode={RulesMode.NECESSARY}
rules={[
{
action: AppRuleActions.delete,
name: AppRuleNames.documents,
},
]}>
<Image src={TrashIcon} alt="trash icon" className={classes["trash"]} onClick={this.onOpenDeletionModal} />
</Rules>
);
}
}

View File

@ -37,6 +37,7 @@ type IState = {
hasValidateAnchoring: boolean;
isVerifDeleteModalVisible: boolean;
isAnchored: boolean | null;
isPreventArchiveModalOpen: boolean;
};
class FolderInformationClass extends BasePage<IPropsClass, IState> {
public constructor(props: IPropsClass) {
@ -49,6 +50,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
hasValidateAnchoring: false,
isVerifDeleteModalVisible: false,
isAnchored: null,
isPreventArchiveModalOpen: false,
};
this.onSelectedFolder = this.onSelectedFolder.bind(this);
this.openArchivedModal = this.openArchivedModal.bind(this);
@ -63,6 +65,7 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
this.openVerifDeleteFolder = this.openVerifDeleteFolder.bind(this);
this.closeVerifDeleteFolder = this.closeVerifDeleteFolder.bind(this);
this.verifyAnchorStatus = this.verifyAnchorStatus.bind(this);
this.closePreventArchiveModal = this.closePreventArchiveModal.bind(this);
}
// TODO: Message if the user has not created any folder yet
@ -174,6 +177,22 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
</div>
)}
</div>
<Confirm
isOpen={this.state.isPreventArchiveModalOpen}
onAccept={this.closePreventArchiveModal}
onClose={this.closePreventArchiveModal}
closeBtn
header={"Vous devez valider et certifier un dossier avant de pouvoir l'archiver"}
cancelText={"Annuler"}
confirmText={"J'ai compris"}>
<div className={classes["modal-title"]}>
<Typography typo={ITypo.P_16}>
Pour valider un dossier, toutes les pièces envoyées par vos clients doivent être validées (vert). Si certains
documents sont en attente (orange), alors, veuillez les valider ou les refuser et veillez à ce qu'aucun document
ne soit encore en demandé au client (gris)
</Typography>
</div>
</Confirm>
<Confirm
isOpen={this.state.isValidateModalVisible}
onClose={this.closeModal}
@ -225,6 +244,12 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
);
}
private closePreventArchiveModal() {
this.setState({
isPreventArchiveModalOpen: false,
});
}
private async verifyAnchorStatus() {
if (!this.state.selectedFolder || !this.state.selectedFolder.uid) return;
try {
@ -352,7 +377,11 @@ class FolderInformationClass extends BasePage<IPropsClass, IState> {
}
private openArchivedModal(): void {
if (this.everyDocumentValidated() && this.state.isAnchored) {
this.setState({ isArchivedModalOpen: true });
} else {
this.setState({ isPreventArchiveModalOpen: true });
}
}
private closeArchivedModal(): void {

View File

@ -3,7 +3,6 @@ import WarningIcon from "@Assets/images/warning.png";
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 Votes from "@Front/Api/LeCoffreApi/SuperAdmin/Votes/Votes";
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";
@ -224,7 +223,7 @@ export default function UserInformations(props: IProps) {
const user = JwtService.getInstance().decodeJwt();
const vote = currentAppointment.votes?.find((vote) => vote.voter?.uid === user?.userId);
if (!vote) return;
await Votes.getInstance().delete({ uid: vote.uid });
await LiveVotes.getInstance().delete({ uid: vote.uid });
await getUser();
}, [currentAppointment, getUser]);