✨ add loader when sending documents
This commit is contained in:
parent
58500e5266
commit
71873a9001
@ -29,6 +29,7 @@ export default function SendDocuments() {
|
|||||||
const [clientSelection, setClientSelection] = useState<EClientSelection | null>(null);
|
const [clientSelection, setClientSelection] = useState<EClientSelection | null>(null);
|
||||||
const [selectedClients, setSelectedClients] = useState<string[]>([]);
|
const [selectedClients, setSelectedClients] = useState<string[]>([]);
|
||||||
const [files, setFiles] = useState<File[]>([]);
|
const [files, setFiles] = useState<File[]>([]);
|
||||||
|
const [isSending, setIsSending] = useState(false);
|
||||||
|
|
||||||
const onFormSubmit = useCallback(
|
const onFormSubmit = useCallback(
|
||||||
async (
|
async (
|
||||||
@ -43,6 +44,7 @@ export default function SendDocuments() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setIsSending(true);
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
selectedClients.map(async (customer) => {
|
selectedClients.map(async (customer) => {
|
||||||
const promises = files.map(async (file) => {
|
const promises = files.map(async (file) => {
|
||||||
@ -65,8 +67,10 @@ export default function SendDocuments() {
|
|||||||
.get()
|
.get()
|
||||||
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folderUid as string),
|
.modules.pages.Folder.pages.FolderInformation.props.path.replace("[folderUid]", folderUid as string),
|
||||||
);
|
);
|
||||||
|
setIsSending(false);
|
||||||
console.log("All files have been successfully sent.");
|
console.log("All files have been successfully sent.");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
setIsSending(false);
|
||||||
console.error("Error while sending files: ", error);
|
console.error("Error while sending files: ", error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -179,7 +183,7 @@ export default function SendDocuments() {
|
|||||||
Annuler
|
Annuler
|
||||||
</Button>
|
</Button>
|
||||||
</a>
|
</a>
|
||||||
<Button type="submit" rightIcon={<PaperAirplaneIcon />}>
|
<Button type="submit" rightIcon={<PaperAirplaneIcon />} isLoading={isSending}>
|
||||||
Envoyer
|
Envoyer
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user