diff --git a/src/App.tsx b/src/App.tsx index 138af537..48b9696f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -5,7 +5,6 @@ import { RouteObject, RouterProvider, } from 'react-router-dom'; -import { Suspense } from 'react'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import DetailPetPage from 'pages/detailPet/DetailPetPage'; import ProfileListPage from 'pages/profileList/profileListHome/ProfileListPage'; @@ -22,7 +21,6 @@ import GNB from 'layouts/GNB'; import NotFound from 'pages/notFound/NotFound'; import HomePage from 'pages/home/HomePage'; import UpdatePage from 'pages/update/UpdatePage'; -import { ClipLoader } from 'react-spinners'; const queryClient = new QueryClient({ defaultOptions: { @@ -115,9 +113,7 @@ function App() { return ( - }> - - + ); diff --git a/src/layouts/ErrorBoundary.tsx b/src/layouts/ErrorBoundary.tsx index 40c46778..3ac08bbc 100644 --- a/src/layouts/ErrorBoundary.tsx +++ b/src/layouts/ErrorBoundary.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable class-methods-use-this */ import React, { Component, ErrorInfo, ReactNode } from 'react'; import { Link } from 'react-router-dom'; diff --git a/src/pages/detailPet/DetailPetPage.tsx b/src/pages/detailPet/DetailPetPage.tsx index 937d5a81..89e44abf 100644 --- a/src/pages/detailPet/DetailPetPage.tsx +++ b/src/pages/detailPet/DetailPetPage.tsx @@ -1,13 +1,21 @@ -import DetailPetData from 'pages/detailPet/components/DetailPetData'; +import { Suspense } from 'react'; +import { ClipLoader } from 'react-spinners'; import ErrorBoundary from 'layouts/ErrorBoundary'; +import DetailPetData from './components/DetailPetData'; const DetailPetPage = () => { return ( - <> + + + + } + > - + ); }; diff --git a/src/pages/detailPet/components/DetailPetData.tsx b/src/pages/detailPet/components/DetailPetData.tsx index 8ce2d5dd..e5d84fe9 100644 --- a/src/pages/detailPet/components/DetailPetData.tsx +++ b/src/pages/detailPet/components/DetailPetData.tsx @@ -10,7 +10,7 @@ const DetailPetData = () => { const [canvas, setCanvas] = useState(null); const [modal, setModal] = useState(false); - const { data, isLoading } = useQuery({ + const { data } = useQuery({ queryKey: ['pet', petId], queryFn: () => { return fetch(`${process.env.REACT_APP_URI}/pet/${petId}`).then((res) => { @@ -24,8 +24,8 @@ const DetailPetData = () => { }); }, suspense: true, + retry: false, }); - if (isLoading) return
로딩중
; const labels = ['영리함', '친화력', '운동신경', '적응력', '활발함']; const radarChartProps: RadarChartProps = { diff --git a/src/pages/detailPet/components/VDetailPetInfo.tsx b/src/pages/detailPet/components/VDetailPetInfo.tsx index 5f66d8a6..f75b1a6b 100644 --- a/src/pages/detailPet/components/VDetailPetInfo.tsx +++ b/src/pages/detailPet/components/VDetailPetInfo.tsx @@ -13,7 +13,9 @@ const VDetailPetInfo = (data: DetailPetInfoProps) => {
성별 - {data.sex} + + {data.sex === 'MALE' ? '수컷' : '암컷'} +
diff --git a/src/pages/map/components/Loader.tsx b/src/pages/map/components/Loader.tsx new file mode 100644 index 00000000..2071aa82 --- /dev/null +++ b/src/pages/map/components/Loader.tsx @@ -0,0 +1,35 @@ +import { ClipLoader } from 'react-spinners'; +import { LoaderProps } from '../mapType'; + +const Loader = (props: LoaderProps) => { + const { loading, longLoading, loadingButApiIsOkay } = props; + + return ( + <> + {loadingButApiIsOkay || + (loading && ( +
+

{loading} 중 입니다...

+ {loadingButApiIsOkay && 서버가 느려요... 기다려주세요!} + {longLoading && ( + <> + 로딩이 너무 오래 걸리시나요? + + + )} + +
+ ))} + + ); +}; + +export default Loader; diff --git a/src/pages/map/components/Map.tsx b/src/pages/map/components/Map.tsx index f083959b..4c0b63b3 100644 --- a/src/pages/map/components/Map.tsx +++ b/src/pages/map/components/Map.tsx @@ -10,6 +10,8 @@ import { useState, useEffect, useRef } from 'react'; import MapList from './MapList'; import useMap from '../useMap'; +import Loader from './Loader'; +import { LoaderProps } from '../mapType'; declare global { interface Window { @@ -19,7 +21,8 @@ declare global { const Map = () => { const mapRef = useRef(null); - const [loading, setLoading] = useState(true); + const [loading, setLoading] = useState('지도 로딩'); + const [longLoading, setLongLoading] = useState(false); const { map, displayMarkerByInfo, searchedPlace, mutate, mutateData } = useMap(mapRef, setLoading); useEffect(() => { @@ -40,14 +43,25 @@ const Map = () => { }); }); + setTimeout(() => { + setLongLoading(true); + }, 5000); + + const loaderProps: LoaderProps = { + loading, + longLoading, + loadingButApiIsOkay: + longLoading && mutateData?.response?.length === 0 && !loading, + }; + return ( -
- {loading && ( -
- )} -
- -
+ <> + +
+
+ +
+ ); }; diff --git a/src/pages/map/components/MapList.tsx b/src/pages/map/components/MapList.tsx index b2b28210..384a4811 100644 --- a/src/pages/map/components/MapList.tsx +++ b/src/pages/map/components/MapList.tsx @@ -6,12 +6,10 @@ import { SearchedPlace } from '../mapType'; const MapList = ({ searchedPlace, map, - loading, }: { searchedPlace: SearchedPlace[]; // eslint-disable-next-line @typescript-eslint/no-explicit-any map: any; - loading: boolean; }) => { const { kakao } = window; const navigate = useNavigate(); @@ -33,7 +31,6 @@ const MapList = ({ return ( <> - {loading &&
}
{searchedPlace.map((place) => (
( containerRef: RefObject, - setLoading: React.Dispatch>, + setLoading: React.Dispatch>, ) { const { kakao } = window; const [map, setMap] = useState(); @@ -30,7 +30,6 @@ function useMap( }).then((res) => res.json()), { onSuccess: (data) => { - setLoading(false); if (data.success === false) { throw new Error(data.error.message); } @@ -46,6 +45,7 @@ function useMap( const onLoadKakaoMap = () => { if (!containerRef.current || !kakao) return; + setLoading('근처 보호소 검색'); window.kakao.maps.load(() => { setMap( new window.kakao.maps.Map(containerRef.current, { @@ -55,6 +55,7 @@ function useMap( ); function placesSearchCB(data: any[], status: any) { + setLoading(''); if (status === kakao.maps.services.Status.OK) { const bounds = new kakao.maps.LatLngBounds(); diff --git a/src/pages/profileList/components/ProfileList.tsx b/src/pages/profileList/components/ProfileList.tsx index 80a97b42..13329b46 100644 --- a/src/pages/profileList/components/ProfileList.tsx +++ b/src/pages/profileList/components/ProfileList.tsx @@ -15,7 +15,6 @@ const ProfileList = (prop: { prop: string }) => { navigate(`/profile/${prop.prop}/${page}`); }; const word = prop.prop === 'urgent' ? 'sos' : prop.prop; - console.log(word); const [list, setList] = useState(null);