Merge branch 'dev' into staging

This commit is contained in:
Max S 2024-09-12 12:14:46 +02:00
commit 4b165045a8

View File

@ -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>