Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hofix: 주변다른식당 클릭 이후 뒤로가기가 동작하지 않는 오류 개선 #703

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions frontend/src/components/@common/VideoCarousel/VideoCarousel.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,25 +19,15 @@ function VideoCarousel({ title, videos }: VideoCarouselProps) {
{isMobile || videos.length <= 2 ? (
<StyledVideoContainer>
{videos.map(({ name, youtubeVideoKey }) => (
<StyledVideo
title={`${name}의 영상`}
src={`https://www.youtube.com/embed/${youtubeVideoKey}`}
allow="encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
/>
<YoutubeEmbed pathParam={youtubeVideoKey} title={name} />
))}
</StyledVideoContainer>
) : (
<StyledSliderContainer>
<Slider {...VideoCarouselSettings}>
{videos.map(({ name, youtubeVideoKey }) => (
<StyledVideoWrapper>
<StyledVideo
title={`${name}의 영상`}
src={`https://www.youtube.com/embed/${youtubeVideoKey}`}
allow="encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
/>
<StyledVideoWrapper key={youtubeVideoKey}>
<YoutubeEmbed pathParam={youtubeVideoKey} title={name} />
</StyledVideoWrapper>
))}
</Slider>
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}`);
},
});

Expand Down
26 changes: 26 additions & 0 deletions frontend/src/components/YoutubeEmbed/YoutubeEmbed.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<StyledVideo
key={pathParam}
title={`${title}의 영상`}
src={`https://www.youtube.com/embed/${pathParam}`}
allow="encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
/>
);
}

export default YoutubeEmbed;

const StyledVideo = styled.iframe`
${paintSkeleton}
border-radius: ${BORDER_RADIUS.md};
`;
3 changes: 3 additions & 0 deletions frontend/src/components/YoutubeEmbed/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import YoutubeEmbed from './YoutubeEmbed';

export default YoutubeEmbed;
12 changes: 4 additions & 8 deletions frontend/src/pages/RestaurantDetailPage/DetailInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import SuggestionButton from '~/components/SuggestionButton';

import Naver from '~/assets/icons/naver-place.svg';
import YoutubeEmbed from '~/components/YoutubeEmbed';

interface DetailInformationProps {
restaurantId: string;
Expand All @@ -23,13 +24,13 @@
data: { celebs, category, phoneNumber, roadAddress, naverMapUrl },
} = useQuery<RestaurantData>({
queryKey: ['restaurantDetail', restaurantId, celebId],
queryFn: async () => getRestaurantDetail(restaurantId, celebId),
queryFn: () => getRestaurantDetail(restaurantId, celebId),
suspense: true,
});

const { data: restaurantVideo } = useQuery<VideoList>({
queryKey: ['restaurantVideo', restaurantId],
queryFn: async () => getRestaurantVideo(restaurantId),
queryFn: () => getRestaurantVideo(restaurantId),
suspense: true,
});

Expand All @@ -43,9 +44,9 @@
async () => {
try {
await navigator.clipboard.writeText(text);
alert('클립보드에 저장되었어요.');

Check warning on line 47 in frontend/src/pages/RestaurantDetailPage/DetailInformation.tsx

View workflow job for this annotation

GitHub Actions / 🍔테스트 딱 대라 💢👊

Unexpected alert
} catch (err) {
alert('클립보드에 저장하는데 문제가 생겼어요.');

Check warning on line 49 in frontend/src/pages/RestaurantDetailPage/DetailInformation.tsx

View workflow job for this annotation

GitHub Actions / 🍔테스트 딱 대라 💢👊

Unexpected alert
}
};

Expand Down Expand Up @@ -93,12 +94,7 @@
</div>
<StyledMainVideo>
<h5>영상으로 보기</h5>
<iframe
title={`${restaurantVideo.content[0].name}의 영상`}
src={`https://www.youtube.com/embed/${restaurantVideo.content[0].youtubeVideoKey}`}
allow="encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
/>
<YoutubeEmbed title={restaurantVideo.content[0].name} pathParam={restaurantVideo.content[0].youtubeVideoKey} />
</StyledMainVideo>
</StyledDetailInfo>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,10 @@ const StyledVideoSection = styled.section`
display: flex;
flex-direction: column;
gap: 3.2rem 0;

iframe {
width: 352px;
max-width: 352px;
height: 196px;
}
`;
Loading