add loading for files
This commit is contained in:
parent
e725efb945
commit
3752e51170
@ -66,6 +66,10 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
.loader {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.cross {
|
.cross {
|
||||||
|
@ -16,6 +16,7 @@ import classNames from "classnames";
|
|||||||
import Confirm from "../Modal/Confirm";
|
import Confirm from "../Modal/Confirm";
|
||||||
import InputField from "../Form/Elements/InputField";
|
import InputField from "../Form/Elements/InputField";
|
||||||
import GreenCheckIcon from "@Assets/Icons/green-check.svg";
|
import GreenCheckIcon from "@Assets/Icons/green-check.svg";
|
||||||
|
import Loader from "../Loader";
|
||||||
|
|
||||||
type IProps = {
|
type IProps = {
|
||||||
defaultFiles?: FileCustomer[];
|
defaultFiles?: FileCustomer[];
|
||||||
@ -28,6 +29,7 @@ type IFile = {
|
|||||||
file: File;
|
file: File;
|
||||||
uid: string;
|
uid: string;
|
||||||
archived: Date | null;
|
archived: Date | null;
|
||||||
|
fileName: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type IState = {
|
type IState = {
|
||||||
@ -36,6 +38,7 @@ type IState = {
|
|||||||
currentFiles?: FileCustomer[];
|
currentFiles?: FileCustomer[];
|
||||||
refusedReason?: string;
|
refusedReason?: string;
|
||||||
isShowRefusedReasonModalVisible: boolean;
|
isShowRefusedReasonModalVisible: boolean;
|
||||||
|
loading: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class DepositDocument extends React.Component<IProps, IState> {
|
export default class DepositDocument extends React.Component<IProps, IState> {
|
||||||
@ -51,6 +54,7 @@ export default class DepositDocument extends React.Component<IProps, IState> {
|
|||||||
currentFiles: this.props.defaultFiles,
|
currentFiles: this.props.defaultFiles,
|
||||||
refusedReason: "",
|
refusedReason: "",
|
||||||
isShowRefusedReasonModalVisible: false,
|
isShowRefusedReasonModalVisible: false,
|
||||||
|
loading: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.addDocument = this.addDocument.bind(this);
|
this.addDocument = this.addDocument.bind(this);
|
||||||
@ -118,7 +122,7 @@ export default class DepositDocument extends React.Component<IProps, IState> {
|
|||||||
<div className={classes["left-part"]}>
|
<div className={classes["left-part"]}>
|
||||||
<Image src={DocumentCheckIcon} alt="Document check" />
|
<Image src={DocumentCheckIcon} alt="Document check" />
|
||||||
<Typography typo={ITypo.P_16} color={ITypoColor.GREY}>
|
<Typography typo={ITypo.P_16} color={ITypoColor.GREY}>
|
||||||
{this.shortName(fileObj.name)}
|
{this.shortName(file.fileName || fileObj.name)}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</div>
|
||||||
<Image
|
<Image
|
||||||
@ -131,6 +135,19 @@ export default class DepositDocument extends React.Component<IProps, IState> {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{this.state.loading && (
|
||||||
|
<div className={classes["file-container"]}>
|
||||||
|
<div className={classes["left-part"]}>
|
||||||
|
<div className={classes["loader"]}>
|
||||||
|
<Loader />
|
||||||
|
</div>
|
||||||
|
<Typography typo={ITypo.P_16} color={ITypoColor.GREY}>
|
||||||
|
Chargement...
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
<div />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{this.props.document.document_status !== EDocumentStatus.VALIDATED && (
|
{this.props.document.document_status !== EDocumentStatus.VALIDATED && (
|
||||||
@ -174,6 +191,7 @@ export default class DepositDocument extends React.Component<IProps, IState> {
|
|||||||
index: this.index++,
|
index: this.index++,
|
||||||
file: new File([""], file.file_path ?? "", {}),
|
file: new File([""], file.file_path ?? "", {}),
|
||||||
uid: file.uid!,
|
uid: file.uid!,
|
||||||
|
fileName: file.file_name,
|
||||||
archived: file.archived_at ? new Date(file.archived_at) : null,
|
archived: file.archived_at ? new Date(file.archived_at) : null,
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
@ -276,12 +294,15 @@ export default class DepositDocument extends React.Component<IProps, IState> {
|
|||||||
formData.append("file", file, file.name);
|
formData.append("file", file, file.name);
|
||||||
const query = JSON.stringify({ document: { uid: this.props.document.uid } });
|
const query = JSON.stringify({ document: { uid: this.props.document.uid } });
|
||||||
formData.append("q", query);
|
formData.append("q", query);
|
||||||
|
this.setState({
|
||||||
|
loading: true,
|
||||||
|
});
|
||||||
const newFile = await Files.getInstance().post(formData);
|
const newFile = await Files.getInstance().post(formData);
|
||||||
const files = this.state.currentFiles ? [...this.state.currentFiles, newFile] : [newFile];
|
const files = this.state.currentFiles ? [...this.state.currentFiles, newFile] : [newFile];
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
currentFiles: files,
|
currentFiles: files,
|
||||||
|
loading: false,
|
||||||
files: [
|
files: [
|
||||||
...this.state.files,
|
...this.state.files,
|
||||||
{
|
{
|
||||||
@ -289,6 +310,7 @@ export default class DepositDocument extends React.Component<IProps, IState> {
|
|||||||
file: file,
|
file: file,
|
||||||
uid: newFile.uid!,
|
uid: newFile.uid!,
|
||||||
archived: null,
|
archived: null,
|
||||||
|
fileName: newFile?.file_name ?? "",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
@import "@Themes/constants.scss";
|
@keyframes s2 {
|
||||||
|
|
||||||
.loader {
|
|
||||||
animation: spin 2s linear infinite;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
|
|
||||||
@keyframes spin {
|
|
||||||
from {
|
|
||||||
transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
to {
|
to {
|
||||||
transform: rotate(360deg);
|
transform: rotate(1turn);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.root {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: 8px solid;
|
||||||
|
border-color: var(--grey-soft);
|
||||||
|
border-right-color: var(--blue-soft);
|
||||||
|
animation: s2 1s infinite linear;
|
||||||
|
}
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import LoaderIcon from "@Assets/Icons/loader.svg";
|
|
||||||
import classes from "./classes.module.scss";
|
import classes from "./classes.module.scss";
|
||||||
import Image from "next/image";
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
export default class Loader extends React.Component<IProps> {
|
export default class Loader extends React.Component<IProps> {
|
||||||
public override render(): JSX.Element {
|
public override render(): JSX.Element {
|
||||||
return <Image src={LoaderIcon} className={[classes["loader"], this.props.className].filter(Boolean).join(" ")} alt={"Loader"} />;
|
return <div className={classes["root"]}></div>;
|
||||||
// <LoaderIcon className={[classes["loader"], this.props.className].filter(Boolean).join(" ")} />;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user