Skip to content

Commit

Permalink
fix: 추천 목록이 없으면 안보이도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
AAminha committed Nov 23, 2023
1 parent cee962e commit bb125f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 56 deletions.
17 changes: 2 additions & 15 deletions src/pages/DetailProgram/RecommendAccom.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import Loading from '@/components/Loading/Loading';
import RecommendCard from '@/components/RecommendCard/RecommendCard';
import { H1 } from '@/style/fonts/StyledFonts';
import { RecommendDataType } from '@/types';
import styled from 'styled-components';

interface RecommendAccomProps {
resultList: RecommendDataType[];
isLoading: boolean;
}

const RecommendAccom = ({ resultList, isLoading }: RecommendAccomProps) => {
const RecommendAccom = ({ resultList }: RecommendAccomProps) => {
return (
<Container>
<H1 $fontColor="var(--color_gray900)">숙소 추천</H1>
{isLoading ? (
<LoadingWrapper>
<Loading />
</LoadingWrapper>
) : (
<RecommendCard resultList={resultList} />
)}
<RecommendCard resultList={resultList} />
</Container>
);
};
Expand All @@ -34,8 +26,3 @@ const Container = styled.div`
margin-bottom: 193px;
text-align: left;
`;

const LoadingWrapper = styled.div`
background-color: red;
position: relative;
`;
17 changes: 2 additions & 15 deletions src/pages/DetailProgram/RecommendSpot.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import Loading from '@/components/Loading/Loading';
import RecommendCard from '@/components/RecommendCard/RecommendCard';
import { H1 } from '@/style/fonts/StyledFonts';
import { RecommendDataType } from '@/types';
import styled from 'styled-components';

interface RecommendSpotProps {
resultList: RecommendDataType[];
isLoading: boolean;
}

const RecommendSpot = ({ resultList, isLoading }: RecommendSpotProps) => {
const RecommendSpot = ({ resultList }: RecommendSpotProps) => {
return (
<Container>
<H1 $fontColor="var(--color_gray900)">여행지 추천</H1>
{isLoading ? (
<LoadingWrapper>
<Loading />
</LoadingWrapper>
) : (
<RecommendCard resultList={resultList} />
)}
<RecommendCard resultList={resultList} />
</Container>
);
};
Expand All @@ -34,8 +26,3 @@ const Container = styled.div`
padding-bottom: 16px;
text-align: left;
`;

const LoadingWrapper = styled.div`
background-color: red;
position: relative;
`;
40 changes: 14 additions & 26 deletions src/pages/DetailProgram/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ const DetailProgram = () => {
programId,
writerVersion,
});
const { data: recommendSpotList, isLoading: spotListLoading } =
useGetRegionTour({
programId,
writerVersion,
});
const { data: recommendAccomList, isLoading: accomListLoading } =
useGetRegionLodgment({
programId,
writerVersion,
});
const { data: recommendSpotList } = useGetRegionTour({
programId,
writerVersion,
});
const { data: recommendAccomList } = useGetRegionLodgment({
programId,
writerVersion,
});
const userInfo = useRecoilValue(UserAtom);
const navigate = useNavigate();

Expand Down Expand Up @@ -96,22 +94,12 @@ const DetailProgram = () => {
<div>
<BackgroundLine />
<CommonInner>
<RecommendSpot
resultList={
recommendSpotList && recommendSpotList.length > 0
? recommendSpotList
: []
}
isLoading={spotListLoading}
/>
<RecommendAccom
resultList={
recommendAccomList && recommendAccomList.length > 0
? recommendAccomList
: []
}
isLoading={accomListLoading}
/>
{recommendSpotList && recommendSpotList.length > 0 && (
<RecommendSpot resultList={recommendSpotList} />
)}
{recommendAccomList && recommendAccomList.length > 0 && (
<RecommendAccom resultList={recommendAccomList} />
)}
</CommonInner>
<HoneyTipButton />
</div>
Expand Down

0 comments on commit bb125f7

Please sign in to comment.