Files
js/core-ui/batch-upload/progress-box.tsx
T
Jonas Daniels b3b61f5f9a switch to pnpm (#2257)
* switch to pnpm

* chore(ci): fix pnpm install command

* cleanup

* chore: Remove unused dependencies and imports
2024-02-24 00:25:27 +00:00

43 lines
1.0 KiB
TypeScript

import { Flex, Progress } from "@chakra-ui/react";
import type { UploadProgressEvent } from "@thirdweb-dev/storage";
import { useEffect, useState } from "react";
import { Text } from "tw-components";
interface ProgressBoxProps {
progress: UploadProgressEvent;
}
export const ProgressBox: React.FC<ProgressBoxProps> = ({ progress }) => {
const isFinished = progress.progress >= progress.total;
const [takingLong, setTakingLong] = useState(false);
useEffect(() => {
if (isFinished) {
const t = setTimeout(() => {
setTakingLong(true);
}, 10000);
return () => {
clearTimeout(t);
};
}
}, [isFinished]);
return (
<Flex w="full" direction="column">
<Progress
borderRadius="md"
mt="12px"
transition="500ms ease"
value={(progress.progress / progress.total) * 100}
size="sm"
/>
{takingLong && progress.progress !== 0 && (
<Text size="body.sm" textAlign="center" mt={3}>
This may take a while.
</Text>
)}
</Flex>
);
};