Skip to content

Commit

Permalink
refactor: loading시 SuspenseFallback component -> Lottie로 수정 (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeseon-han authored Mar 1, 2024
1 parent 35f154e commit 9c299fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 3 additions & 4 deletions src/components/templates/FriendListTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { Modal, ModalBody, ModalContent, ModalOverlay, useDisclosure } from '@ch

import React, { useCallback, useEffect, useRef, useState } from 'react';
import { type SortLabel } from '@/types/common';
import { Button, RadioButtonField, SortButton } from '@/components/atoms';
import { Button, Lottie, RadioButtonField, SortButton } from '@/components/atoms';
import { FriendListItem } from '../organisms';
import { useDeleteFriendship, useGetFriendships } from '@/hooks/queries/friendship';
import type { FriendshipData, FriendshipSortType } from '@/types/friendship';
import { SuspenseFallback } from '.';
import { useObserver } from '@/hooks/useObserver';

export const SORT_TYPES: SortLabel[] = [
Expand Down Expand Up @@ -72,7 +71,7 @@ const FriendListTemplate: React.FC<{ possibleDelete: boolean }> = ({ possibleDel
}, [possibleDelete]);

if (!friendsData?.pages[0].content) {
return <SuspenseFallback />;
return <Lottie />;
}

return (
Expand All @@ -99,7 +98,7 @@ const FriendListTemplate: React.FC<{ possibleDelete: boolean }> = ({ possibleDel
/>
)),
)}
{isFetchingfriendsNextPage ? <SuspenseFallback /> : <div ref={bottom} />}
{isFetchingfriendsNextPage ? <Lottie /> : <div ref={bottom} />}
</div>

{possibleDelete ? (
Expand Down
5 changes: 2 additions & 3 deletions src/pages/mypage/share/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Modal, ModalBody, ModalContent, ModalOverlay, useDisclosure } from '@chakra-ui/react';
import { RadioButtonField, SortButton, TabButton } from '@/components/atoms';
import { Lottie, RadioButtonField, SortButton, TabButton } from '@/components/atoms';
import type { ShareStatusType } from '@/types/friendship';
import type { SortLabel, TabLabel } from '@/types/common';
import { useRef, useState } from 'react';
Expand All @@ -8,7 +8,6 @@ import Header from '@/components/organisms/Header';
import type { NextPage } from 'next';
import { type ShareData } from '@/types/share';
import ShareListItem from '@/components/organisms/ShareListItem';
import { SuspenseFallback } from '@/components/templates';
import { useObserver } from '@/hooks/useObserver';
import { useGetMyShares } from '@/hooks/queries/mypage';
import type { MySharesSortType } from '@/types/mypage';
Expand Down Expand Up @@ -73,7 +72,7 @@ const MySharePage: NextPage = () => {
{data?.pages.map((page) =>
page.content.map((ele: ShareData) => <ShareListItem key={ele.shareId} data={ele} />),
)}
{isFetchingNextPage ? <SuspenseFallback /> : <div ref={bottom} />}
{isFetchingNextPage ? <Lottie /> : <div ref={bottom} />}
</div>
<Modal onClose={onClose} isOpen={isOpen} motionPreset="slideInBottom" trapFocus={false}>
<ModalOverlay height="100vh" onClick={onClose} />
Expand Down
9 changes: 6 additions & 3 deletions src/pages/share/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Modal, ModalBody, ModalContent, ModalOverlay, useDisclosure } from '@chakra-ui/react';
import { RadioButtonField, SortButton, TabButton } from '@/components/atoms';
import { Lottie, RadioButtonField, SortButton, TabButton } from '@/components/atoms';
import type { ShareSortType, ShareStatusType } from '@/types/friendship';
import type { SortLabel, TabLabel } from '@/types/common';
import { useRef, useState } from 'react';
Expand All @@ -10,7 +10,6 @@ import type { NextPage } from 'next';
import { PlusIcon } from '@/assets/icons';
import { type ShareData } from '@/types/share';
import ShareListItem from '@/components/organisms/ShareListItem';
import { SuspenseFallback } from '@/components/templates';
import { useGetShares } from '@/hooks/queries/share';
import { useObserver } from '@/hooks/useObserver';

Expand Down Expand Up @@ -46,6 +45,10 @@ const SharePage: NextPage = () => {
onIntersect,
});

if (!data?.pages[0].content) {
return <Lottie />;
}

return (
<>
<div className={'pt-[52px] min-h-screen'}>
Expand Down Expand Up @@ -74,7 +77,7 @@ const SharePage: NextPage = () => {
{data?.pages.map((page) =>
page.content.map((ele: ShareData) => <ShareListItem key={ele.shareId} data={ele} />),
)}
{isFetchingNextPage ? <SuspenseFallback /> : <div ref={bottom} />}
{isFetchingNextPage ? <Lottie /> : <div ref={bottom} />}
</div>

<div className="flex justify-end pr-[20px]">
Expand Down

0 comments on commit 9c299fc

Please sign in to comment.