diff --git a/frontend/src/components/@common/VideoCarousel/VideoCarousel.tsx b/frontend/src/components/@common/VideoCarousel/VideoCarousel.tsx index 56d5359d0..07931c692 100644 --- a/frontend/src/components/@common/VideoCarousel/VideoCarousel.tsx +++ b/frontend/src/components/@common/VideoCarousel/VideoCarousel.tsx @@ -1,9 +1,10 @@ import { styled } from 'styled-components'; import Slider from 'react-slick'; -import { BORDER_RADIUS, hideScrollBar, paintSkeleton } from '~/styles/common'; +import { hideScrollBar } from '~/styles/common'; import type { Video } from '~/@types/api.types'; import { VideoCarouselSettings } from '~/constants/carouselSettings'; import useMediaQuery from '~/hooks/useMediaQuery'; +import YoutubeEmbed from '~/components/YoutubeEmbed'; interface VideoCarouselProps { title: string; @@ -18,25 +19,15 @@ function VideoCarousel({ title, videos }: VideoCarouselProps) { {isMobile || videos.length <= 2 ? ( {videos.map(({ name, youtubeVideoKey }) => ( - + ))} ) : ( {videos.map(({ name, youtubeVideoKey }) => ( - - + + ))} @@ -59,15 +50,6 @@ const StyledVideoWrapper = styled.div` width: 100%; `; -const StyledVideo = styled.iframe` - ${paintSkeleton} - width: 352px; - max-width: 352px; - height: 196px; - - border-radius: ${BORDER_RADIUS.md}; -`; - const StyledVideoContainer = styled.div` display: flex; gap: 2rem; diff --git a/frontend/src/components/MiniRestaurantCard/MiniRestaurantCard.tsx b/frontend/src/components/MiniRestaurantCard/MiniRestaurantCard.tsx index c4415bc58..b1716c5b8 100644 --- a/frontend/src/components/MiniRestaurantCard/MiniRestaurantCard.tsx +++ b/frontend/src/components/MiniRestaurantCard/MiniRestaurantCard.tsx @@ -1,5 +1,6 @@ import { css, styled } from 'styled-components'; import { MouseEventHandler, memo, useCallback } from 'react'; +import { useNavigate } from 'react-router-dom'; import Love from '~/assets/icons/love.svg'; import { FONT_SIZE, truncateText } from '~/styles/common'; import Star from '~/assets/icons/star.svg'; @@ -36,10 +37,11 @@ function MiniRestaurantCard({ }: MiniRestaurantCardProps) { const { id, images, name, roadAddress, category, rating, distance } = restaurant; const { toggleRestaurantLike, isLiked } = useToggleLikeNotUpdate(restaurant); + const navigate = useNavigate(); const register = useOnClickBlock({ callback: () => { - window.location.href = `/restaurants/${id}?celebId=${celebs[0].id}`; + navigate(`/restaurants/${id}?celebId=${celebs[0].id}`); }, }); diff --git a/frontend/src/components/YoutubeEmbed/YoutubeEmbed.tsx b/frontend/src/components/YoutubeEmbed/YoutubeEmbed.tsx new file mode 100644 index 000000000..19f78f7e2 --- /dev/null +++ b/frontend/src/components/YoutubeEmbed/YoutubeEmbed.tsx @@ -0,0 +1,26 @@ +import styled from 'styled-components'; +import { BORDER_RADIUS, paintSkeleton } from '~/styles/common'; + +interface YoutubeEmbedProps { + title: string; + pathParam: string; +} + +function YoutubeEmbed({ title, pathParam }: YoutubeEmbedProps) { + return ( + + ); +} + +export default YoutubeEmbed; + +const StyledVideo = styled.iframe` + ${paintSkeleton} + border-radius: ${BORDER_RADIUS.md}; +`; diff --git a/frontend/src/components/YoutubeEmbed/index.tsx b/frontend/src/components/YoutubeEmbed/index.tsx new file mode 100644 index 000000000..52a4a4af9 --- /dev/null +++ b/frontend/src/components/YoutubeEmbed/index.tsx @@ -0,0 +1,3 @@ +import YoutubeEmbed from './YoutubeEmbed'; + +export default YoutubeEmbed; diff --git a/frontend/src/pages/RestaurantDetailPage/DetailInformation.tsx b/frontend/src/pages/RestaurantDetailPage/DetailInformation.tsx index 910d95a32..4f3cc8f35 100644 --- a/frontend/src/pages/RestaurantDetailPage/DetailInformation.tsx +++ b/frontend/src/pages/RestaurantDetailPage/DetailInformation.tsx @@ -10,6 +10,7 @@ import { getRestaurantDetail, getRestaurantVideo } from '~/api/restaurant'; import SuggestionButton from '~/components/SuggestionButton'; import Naver from '~/assets/icons/naver-place.svg'; +import YoutubeEmbed from '~/components/YoutubeEmbed'; interface DetailInformationProps { restaurantId: string; @@ -23,13 +24,13 @@ function DetailInformation({ restaurantId, celebId }: DetailInformationProps) { data: { celebs, category, phoneNumber, roadAddress, naverMapUrl }, } = useQuery({ queryKey: ['restaurantDetail', restaurantId, celebId], - queryFn: async () => getRestaurantDetail(restaurantId, celebId), + queryFn: () => getRestaurantDetail(restaurantId, celebId), suspense: true, }); const { data: restaurantVideo } = useQuery({ queryKey: ['restaurantVideo', restaurantId], - queryFn: async () => getRestaurantVideo(restaurantId), + queryFn: () => getRestaurantVideo(restaurantId), suspense: true, }); @@ -93,12 +94,7 @@ function DetailInformation({ restaurantId, celebId }: DetailInformationProps) {
영상으로 보기
-