Merge pull request #883 from OpenSignLabs/raktima-opensignlabs-patch-10

fix: unnecessary showing message faild to load on send document popup
This commit is contained in:
Amol
2024-06-26 18:17:17 +05:30
committed by GitHub
+6 -17
View File
@@ -2,20 +2,13 @@ import React, { useState, useEffect } from "react";
import { DotLottieReact } from "@lottiefiles/dotlottie-react";
import Loader from "./Loader";
const LottieWithLoader = ({
src = "https://lottie.host/00a72a09-f2d4-493a-9b2d-2843bf067638/Ic7jJ44wLJ.json",
minLoaderTime = 1000,
timeout = 10000
}) => {
const LottieWithLoader = () => {
const [isLoaded, setIsLoaded] = useState(false);
const [hasError, setHasError] = useState(false);
const [animationSrc, setAnimationSrc] = useState(null);
const src =
"https://lottie.host/00a72a09-f2d4-493a-9b2d-2843bf067638/Ic7jJ44wLJ.json";
useEffect(() => {
const timer = setTimeout(() => {
setHasError(true);
}, timeout);
fetch(src)
.then((response) => {
if (!response.ok) {
@@ -26,17 +19,13 @@ const LottieWithLoader = ({
.then((blob) => {
const objectURL = URL.createObjectURL(blob);
setAnimationSrc(objectURL);
setTimeout(() => {
setIsLoaded(true);
}, minLoaderTime);
setIsLoaded(true);
})
.catch((error) => {
console.error("There was a problem with the fetch operation:", error);
console.error("faild to load animation of send request:", error);
setHasError(true);
});
return () => clearTimeout(timer);
}, [src, minLoaderTime, timeout]);
}, [src]);
return (
<div>