Portal/rsconcept/frontend/src/components/wrap/DataLoader.tsx
2025-01-28 23:23:03 +03:00

26 lines
623 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import InfoError, { ErrorData } from '@/components/info/InfoError';
import Loader from '@/components/ui/Loader';
interface DataLoaderProps {
isLoading?: boolean;
error?: ErrorData;
hasNoData?: boolean;
}
function DataLoader({ isLoading, hasNoData, error, children }: React.PropsWithChildren<DataLoaderProps>) {
if (isLoading) {
return <Loader />;
}
if (error) {
return <InfoError error={error} />;
}
if (hasNoData) {
return <div className='cc-fade-in w-full text-center p-1'>Данные не загружены</div>;
} else {
return <>{children}</>;
}
}
export default DataLoader;