From 2cfd3907b74dfeefd5e210f59fe2fcb8ec3c20c6 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Mon, 24 Apr 2023 15:58:21 +0200 Subject: [PATCH] :sparkles: Disable arrows when nothing previous/next --- .../Folder/ViewDocuments/classes.module.scss | 7 +- .../Layouts/Folder/ViewDocuments/index.tsx | 76 ++++++++++++------- 2 files changed, 55 insertions(+), 28 deletions(-) diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/classes.module.scss b/src/front/Components/Layouts/Folder/ViewDocuments/classes.module.scss index 752f6dcc..61d7d101 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/classes.module.scss +++ b/src/front/Components/Layouts/Folder/ViewDocuments/classes.module.scss @@ -15,9 +15,14 @@ display: flex; justify-content: space-between; align-items: center; - + .arrow-container{ cursor: pointer; + + &[data-disabled="true"]{ + opacity: 0.3; + cursor: not-allowed; + } } .file-container{ diff --git a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx index 50e1ad52..27b7209e 100644 --- a/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx +++ b/src/front/Components/Layouts/Folder/ViewDocuments/index.tsx @@ -1,5 +1,6 @@ import "reflect-metadata"; - +import LeftArrowIcon from "@Assets/Icons/left-arrow.svg"; +import RightArrowIcon from "@Assets/Icons/right-arrow.svg"; import ValidateAnchoringGif from "@Front/Assets/images/validate_anchoring.gif"; import Button, { EButtonVariant } from "@Front/Components/DesignSystem/Button"; import CheckBox from "@Front/Components/DesignSystem/CheckBox"; @@ -17,13 +18,11 @@ import React from "react"; import BasePage from "../../Base"; import classes from "./classes.module.scss"; -import LeftArrowIcon from "@Assets/Icons/left-arrow.svg"; -import RightArrowIcon from "@Assets/Icons/right-arrow.svg"; type IProps = {}; type IPropsClass = { documentsList: Document[]; - selectedDocument: Document | null; + selectedDocument: Document | null; router: NextRouter; folderUid: string; }; @@ -47,7 +46,7 @@ class ViewDocumentsClass extends BasePage { refuseText: "", hasValidateAnchoring: false, selectedDocument: null, - selectedDocumentIndex: -1 + selectedDocumentIndex: -1, }; this.closeModals = this.closeModals.bind(this); @@ -55,6 +54,11 @@ class ViewDocumentsClass extends BasePage { this.openRefuseModal = this.openRefuseModal.bind(this); this.onRefuseTextChange = this.onRefuseTextChange.bind(this); this.validateAnchoring = this.validateAnchoring.bind(this); + this.goToNext = this.goToNext.bind(this); + this.goToPrevious = this.goToPrevious.bind(this); + + this.hasPrevious = this.hasPrevious.bind(this); + this.hasNext = this.hasNext.bind(this); } public override render(): JSX.Element | null { @@ -69,17 +73,21 @@ class ViewDocumentsClass extends BasePage { {this.state.selectedDocument.document_type.name}
-
- left arrow -
+ {this.props.documentsList.length > 1 && ( +
+ left arrow +
+ )}
{this.state.selectedDocument.files?.map((file) => ( ))}
-
- right arrow -
+ {this.props.documentsList.length > 1 && ( +
+ right arrow +
+ )}