gitscope
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/components/awaiting/index.tsx · v0.3.2
Source
1 89eec32 Dawsh 2y ago import { type FC } from "react";
2 89eec32 Dawsh 2y ago
3 89eec32 Dawsh 2y ago interface AwaitingProps {
4 d377c4c Dawsh 2y ago isFetching?: boolean;
5 d377c4c Dawsh 2y ago isNotFound?: boolean;
6 d377c4c Dawsh 2y ago NotFound?: JSX.Element;
7 d377c4c Dawsh 2y ago Skeleton?: JSX.Element;
8 89eec32 Dawsh 2y ago Component: JSX.Element;
9 89eec32 Dawsh 2y ago }
10 89eec32 Dawsh 2y ago
11 89eec32 Dawsh 2y ago /**
12 89eec32 Dawsh 2y ago * @param isFetching - returned from react-query
13 89eec32 Dawsh 2y ago * which indicate the promise is still fetching.
14 89eec32 Dawsh 2y ago * @example
15 89eec32 Dawsh 2y ago * const { data, isFetching} = useQuery();
16 89eec32 Dawsh 2y ago *
17 89eec32 Dawsh 2y ago * @param isNotFound - whether the data return is empty or not
18 89eec32 Dawsh 2y ago * @param NotFound - Not found component
19 89eec32 Dawsh 2y ago * @param Component - The actual component itself
20 89eec32 Dawsh 2y ago * @param Skeleton - Skeleton structure which will be presented
21 89eec32 Dawsh 2y ago * when the data is still pending and fetching
22 89eec32 Dawsh 2y ago *
23 89eec32 Dawsh 2y ago */
24 89eec32 Dawsh 2y ago export const Awaiting: FC<AwaitingProps> = ({
25 89eec32 Dawsh 2y ago isFetching, isNotFound, NotFound, Skeleton, Component
26 89eec32 Dawsh 2y ago }) => {
27 89eec32 Dawsh 2y ago if (isFetching) {
28 89eec32 Dawsh 2y ago return Skeleton
29 89eec32 Dawsh 2y ago } else if (isNotFound) {
30 89eec32 Dawsh 2y ago return NotFound
31 89eec32 Dawsh 2y ago } else {
32 89eec32 Dawsh 2y ago return Component
33 89eec32 Dawsh 2y ago }
34 89eec32 Dawsh 2y ago }