import { Check, Loader2 } from 'lucide-react'
import { toast } from 'sonner'
import { Button, Progress } from 'ui'
export default function SonnerUpload() {
const uploadPromise = (files: number, toastId: number) => {
toast.loading(, {
id: toastId,
})
return new Promise((resolve) => {
let currentProgress = 0
toast.loading(, {
id: toastId,
})
const intervalId = setInterval(() => {
currentProgress += Math.floor(Math.random() * 10) + 1 // Increment progress by a random value
if (currentProgress > 100) currentProgress = 100 // Ensure progress does not exceed 100%
if (currentProgress >= 100) {
clearInterval(intervalId) // Clear the interval once upload is complete
resolve({ progress: currentProgress, message: 'Upload complete', files: 3, toastId }) // Resolve the promise when progress reaches 100
}
toast.loading(, {
id: toastId,
})
}, 200) // Adjust the interval time as needed
})
}
const UploadContent = ({ progress, files }: { progress: number; files: number }) => (
{progress >= 100 ? (
) : (
)}
{progress >= 100
? `Upload complete`
: files
? `Uploading ${files} files...`
: `Uploading...`}
{`${progress}%`}
Please do not close the browser until completed
)
return (
)
}