diff --git a/src/components/skeletons/SkeletonACollections.tsx b/src/components/skeletons/SkeletonACollections.tsx new file mode 100644 index 0000000..76e9558 --- /dev/null +++ b/src/components/skeletons/SkeletonACollections.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { Flex, Skeleton, Stack } from '@chakra-ui/react'; + +import { MyContainer } from '@components/ui/MyContainer'; +import { MySimpleGrid } from '@components/ui/MySimpleGrid'; + +export function SkeletonACollections() { + const Cards = Array.from({ length: 6 }, (_, index) => ( + + + + )); + + return ( + <> + + + + + + + + + {Cards} + + + ); +} diff --git a/src/components/skeletons/SkeletonDCollection.tsx b/src/components/skeletons/SkeletonDCollection.tsx new file mode 100644 index 0000000..37bd5c9 --- /dev/null +++ b/src/components/skeletons/SkeletonDCollection.tsx @@ -0,0 +1,29 @@ +import React from 'react'; +import { Flex, Skeleton } from '@chakra-ui/react'; + +import { SkeletonContainer } from './SkeletonContainer'; + +export function SkeletonDCollection() { + return ( + <> + + + + + + + + + + + + + ); +} diff --git a/src/pages/profile/collections/AllCollections.tsx b/src/pages/profile/collections/AllCollections.tsx index e99531b..bc8a02b 100644 --- a/src/pages/profile/collections/AllCollections.tsx +++ b/src/pages/profile/collections/AllCollections.tsx @@ -23,6 +23,7 @@ import { ModalCollection } from '@components/modals/ModalCollection'; import { useCollections } from '@hooks/queries'; import { useAuth } from '@contexts/AuthContext'; import { parseDate } from '@utils/utils'; +import { SkeletonACollections } from '@components/skeletons/SkeletonACollections'; export function AllCollections() { const bgColorButton = useColorModeValue('green.500', 'green.700'); @@ -32,10 +33,9 @@ export function AllCollections() { const uid = currentUser?.uid; const { data, refetch, isPending: isPendingData } = useCollections(uid); let collectionsUI; - let spinnerUI; if (isPendingData) { - spinnerUI = ; + return ; } if (!data || !data?.collections || data?.collections.length === 0) { diff --git a/src/pages/profile/collections/CollectionDetail.tsx b/src/pages/profile/collections/CollectionDetail.tsx index d439179..46bafbc 100644 --- a/src/pages/profile/collections/CollectionDetail.tsx +++ b/src/pages/profile/collections/CollectionDetail.tsx @@ -12,13 +12,14 @@ import { MyContainer } from '@components/ui/MyContainer'; import { useAuth } from '@contexts/AuthContext'; import { MdOutlineExplore } from 'react-icons/md'; import { FiArrowLeft } from 'react-icons/fi'; +import { SkeletonDCollection } from '@components/skeletons/SkeletonDCollection'; export function CollectionDetail() { const { collectionId } = useParams(); const navigate = useNavigate(); const { currentUser } = useAuth(); const uid = currentUser?.uid; - const { data, isPending } = useCollectionDetail(collectionId); + const { data, isPending: isPendingData } = useCollectionDetail(collectionId); const { mutate, isSuccess, isPending: isPendingDelete } = useDeleteCollections(); let asideAndCardsUI; @@ -28,6 +29,10 @@ export function CollectionDetail() { } }, [isSuccess, navigate]); + if (isPendingData) { + return ; + } + function deleteCollection(id: string) { mutate([uid, id]); } @@ -119,7 +124,7 @@ export function CollectionDetail() { justify='space-between' align='center' > -