- {this.props.selectedDocument.files?.map((file) => (
-
- ))}
+
+
+
+
+
+ {this.state.selectedDocument.files?.map((file) => (
+
+ ))}
+
+
+
+
)}
- {!this.props.selectedDocument && (
+ {!this.state.selectedDocument && (
Document non trouvé
@@ -128,6 +147,43 @@ class ViewDocumentsClass extends BasePage {
);
}
+ override componentDidMount(): void {
+ if(!this.props.selectedDocument) return;
+ this.setState({
+ selectedDocument: this.props.selectedDocument,
+ selectedDocumentIndex: this.props.documentsList.findIndex((doc) => doc.uid === this.props.selectedDocument!.uid),
+ });
+ }
+
+ override componentDidUpdate(prevProps: Readonly, prevState: Readonly, snapshot?: any): void {
+ if (prevProps.selectedDocument !== this.props.selectedDocument) {
+ this.setState({
+ selectedDocument: this.props.selectedDocument,
+ selectedDocumentIndex: this.props.documentsList.findIndex((doc) => doc.uid === this.props.selectedDocument!.uid),
+ });
+ }
+ }
+
+ private goToPrevious() {
+ return () => {
+ const index = this.state.selectedDocumentIndex - 1;
+ if (index < 0) {
+ return;
+ }
+ this.props.router.push(`/folder/${this.props.folderUid}/document/${this.props.documentsList[index]!.uid}`)
+ };
+ }
+
+ private goToNext() {
+ return () => {
+ const index = this.state.selectedDocumentIndex + 1;
+ if (index >= this.props.documentsList.length) {
+ return;
+ }
+ this.props.router.push(`/folder/${this.props.folderUid}/document/${this.props.documentsList[index]!.uid}`)
+ }
+ }
+
private validateAnchoring() {
this.setState({
hasValidateAnchoring: true,
@@ -163,12 +219,10 @@ class ViewDocumentsClass extends BasePage {
export default function ViewDocuments(props: IProps) {
const router = useRouter();
let { folderUid, documentUid } = router.query;
- folderUid = folderUid as string;
const folder = folders[0]!;
const documents = folder.documents!;
const selectedDocument = documents.find((document) => document.uid === documentUid) ?? null;
-
- return ;
+ return ;
}