1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-10-01 00:50:10 +02:00

feat: replace tooltip with toast

This commit is contained in:
Elias Schneider 2022-10-14 13:11:59 +02:00
parent aa5b125367
commit a33b5b37d9

View File

@ -1,6 +1,7 @@
import { Button, Tooltip } from "@mantine/core"; import { Button } from "@mantine/core";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import shareService from "../../services/share.service"; import shareService from "../../services/share.service";
import toast from "../../utils/toast.util";
const DownloadAllButton = ({ shareId }: { shareId: string }) => { const DownloadAllButton = ({ shareId }: { shareId: string }) => {
const [isZipReady, setIsZipReady] = useState(false); const [isZipReady, setIsZipReady] = useState(false);
@ -32,21 +33,18 @@ const DownloadAllButton = ({ shareId }: { shareId: string }) => {
}; };
}, []); }, []);
if (!isZipReady)
return (
<Tooltip
position="bottom"
width={220}
withArrow
label="The share is preparing. This can take a few minutes."
>
<Button variant="outline" onClick={downloadAll} disabled>
Download all
</Button>
</Tooltip>
);
return ( return (
<Button variant="outline" loading={isLoading} onClick={downloadAll}> <Button
variant="outline"
loading={isLoading}
onClick={() => {
if (!isZipReady) {
toast.error("The share is preparing. Try again in a few minutes.");
} else {
downloadAll();
}
}}
>
Download all Download all
</Button> </Button>
); );