From 3a001da691c8ed9368761ad7d901ec802dd0fcf0 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Fri, 12 May 2023 10:47:38 +0200 Subject: [PATCH 1/3] :sparkles: test --- .../Components/DesignSystem/DepositDocument/index.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/front/Components/DesignSystem/DepositDocument/index.tsx b/src/front/Components/DesignSystem/DepositDocument/index.tsx index 2a85bbfa..d01afe40 100644 --- a/src/front/Components/DesignSystem/DepositDocument/index.tsx +++ b/src/front/Components/DesignSystem/DepositDocument/index.tsx @@ -69,6 +69,7 @@ export default class DepositDocument extends React.Component { } public override render(): JSX.Element { + console.log("Loading :" , this.state.loading); return (
{ } private async addFile(file: File) { + this.setState({ + loading: true, + }); const formData = new FormData(); formData.append("file", file, file.name); const query = JSON.stringify({ document: { uid: this.props.document.uid } }); formData.append("q", query); - this.setState({ - loading: true, - }); + const newFile = await Files.getInstance().post(formData); const files = this.state.currentFiles ? [...this.state.currentFiles, newFile] : [newFile]; @@ -333,6 +335,9 @@ export default class DepositDocument extends React.Component { } private async onFileChange() { + this.setState({ + loading: true, + }); if (!this.inputRef.current) return; const files = this.inputRef.current.files; if (!files) return; From ea40b10af98d434deb000e68d8c4e02edb6cbbf8 Mon Sep 17 00:00:00 2001 From: Hugo Lextrait Date: Fri, 12 May 2023 10:51:12 +0200 Subject: [PATCH 2/3] :art: fix img --- .../Components/DesignSystem/FilePreview/index.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/front/Components/DesignSystem/FilePreview/index.tsx b/src/front/Components/DesignSystem/FilePreview/index.tsx index 6ea12f73..d7e6f794 100644 --- a/src/front/Components/DesignSystem/FilePreview/index.tsx +++ b/src/front/Components/DesignSystem/FilePreview/index.tsx @@ -3,7 +3,6 @@ import React from "react"; import Typography, { ITypo, ITypoColor } from "../Typography"; import classes from "./classes.module.scss"; import Loader from "../Loader"; -import Image from "next/image"; type IProps = { href: string; @@ -27,11 +26,11 @@ export default class FilePreview extends React.Component { )}
- {type?.toLowerCase() === "pdf" && ( - - )} - {type?.toLowerCase() !== "pdf" && File preview} -
+ {type?.toLowerCase() === "pdf" && ( + + )} + {type?.toLowerCase() !== "pdf" && File preview} +
); } From f7406746eee536f4dfa129fe8664e1d6d99104c4 Mon Sep 17 00:00:00 2001 From: Hugo Lextrait Date: Fri, 12 May 2023 10:57:24 +0200 Subject: [PATCH 3/3] loader on first drag and background image --- .../DesignSystem/DepositDocument/index.tsx | 19 ++++++++++++------- .../Layouts/Folder/CreateFolder/index.tsx | 2 +- .../Components/Layouts/PageNotFound/index.tsx | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/front/Components/DesignSystem/DepositDocument/index.tsx b/src/front/Components/DesignSystem/DepositDocument/index.tsx index d01afe40..aac4c284 100644 --- a/src/front/Components/DesignSystem/DepositDocument/index.tsx +++ b/src/front/Components/DesignSystem/DepositDocument/index.tsx @@ -69,7 +69,7 @@ export default class DepositDocument extends React.Component { } public override render(): JSX.Element { - console.log("Loading :" , this.state.loading); + console.log("Loading :", this.state.loading); return (
{ } private async onDragDrop(event: React.DragEvent) { + this.setState({ + loading: true, + }); event.preventDefault(); this.setState({ isDragOver: false, }); const file = event.dataTransfer.files[0]; if (file) this.addFile(file); + else this.setState({ loading: false }); } private async addFile(file: File) { - this.setState({ - loading: true, - }); const formData = new FormData(); formData.append("file", file, file.name); const query = JSON.stringify({ document: { uid: this.props.document.uid } }); formData.append("q", query); - + const newFile = await Files.getInstance().post(formData); const files = this.state.currentFiles ? [...this.state.currentFiles, newFile] : [newFile]; @@ -335,15 +336,19 @@ export default class DepositDocument extends React.Component { } private async onFileChange() { + if (!this.inputRef.current) return; this.setState({ loading: true, }); - if (!this.inputRef.current) return; const files = this.inputRef.current.files; - if (!files) return; + if (!files) { + this.setState({ loading: false }); + return; + } const file = files[0]; if (file) this.addFile(file); + else this.setState({ loading: false }); } private addDocument() { diff --git a/src/front/Components/Layouts/Folder/CreateFolder/index.tsx b/src/front/Components/Layouts/Folder/CreateFolder/index.tsx index b7ee1116..9403e299 100644 --- a/src/front/Components/Layouts/Folder/CreateFolder/index.tsx +++ b/src/front/Components/Layouts/Folder/CreateFolder/index.tsx @@ -18,7 +18,7 @@ import Users from "@Front/Api/LeCoffreApi/SuperAdmin/Users/Users"; import User from "le-coffre-resources/dist/Notary"; import Folders, { IPostFoldersParams } from "@Front/Api/LeCoffreApi/SuperAdmin/Folders/Folders"; import { NextRouter, useRouter } from "next/router"; -import backgroundImage from "@Front/assets/images/404-background-image.jpeg"; +import backgroundImage from "@Assets/images/404-background-image.jpeg"; type IFormValues = { folder_number: string; diff --git a/src/front/Components/Layouts/PageNotFound/index.tsx b/src/front/Components/Layouts/PageNotFound/index.tsx index e0d52b93..6c6022dd 100644 --- a/src/front/Components/Layouts/PageNotFound/index.tsx +++ b/src/front/Components/Layouts/PageNotFound/index.tsx @@ -6,7 +6,7 @@ import BasePage from "../Base"; import classes from "./classes.module.scss"; import DefaultDoubleSidePage from "@Front/Components/LayoutTemplates/DefaultDoubleSidePage"; -import backgroundImage from "@Front/assets/images/404-background-image.jpeg"; +import backgroundImage from "@Assets/images/404-background-image.jpeg"; export default class PageNotFound extends BasePage { public override render(): JSX.Element {