-
Notifications
You must be signed in to change notification settings - Fork 3
[FEAT] 템플스테이 상세 정보, 이미지 API V2 전환 #311
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,18 +29,17 @@ const SmallMap = dynamic(() => import('@components/templeDetail/naverMap/smallMa | |
| }); | ||
|
|
||
| interface TempleDetailClientProps { | ||
| templestayId: string; | ||
| id: number; | ||
| } | ||
|
|
||
| const TempleDetailClient = ({ templestayId }: TempleDetailClientProps) => { | ||
| const TempleDetailClient = ({ id }: TempleDetailClientProps) => { | ||
| const [userId, setUserId] = useState<string | undefined>(undefined); | ||
|
|
||
| useEffect(() => { | ||
| const id = getCookie('userId') as string; | ||
| setUserId(id); | ||
| const user = getCookie('userId') as string; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 쿠키에 userId 없어져서 로그인 여부 판단하기 위해 쿠키값 가져오는거면 토큰 유무로 판단해야 할 것 같습니뎅
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. user가 해당 컴포넌트 토글 및 위시 부분과만 연관되어 있어서, 영경님 작업과 겹칠 것 같아요. 추후에 영경님 브랜치에서 위시 API 전환 작업하실 때 같이 진행해 주시면 될 것 같습니다. @bykbyk0401 부탁드립니다!!
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 제가 작업할때 반영하겠습니다! |
||
| setUserId(user); | ||
| }, []); | ||
|
|
||
| const { data, isLoading, isError } = useGetTempleDetails(templestayId, userId || undefined); | ||
| const { data, isLoading, isError } = useGetTempleDetails(id); | ||
| const queryClient = useQueryClient(); | ||
| const addWishlistMutation = useAddWishlist(); | ||
| const removeWishlistMutation = useRemoveWishlist(); | ||
|
|
@@ -51,7 +50,7 @@ const TempleDetailClient = ({ templestayId }: TempleDetailClientProps) => { | |
|
|
||
| useEffect(() => { | ||
| if (data) { | ||
| setLiked(data.liked); | ||
| setLiked(data.wish); | ||
| } | ||
| }, [data]); | ||
|
|
||
|
|
@@ -66,7 +65,7 @@ const TempleDetailClient = ({ templestayId }: TempleDetailClientProps) => { | |
| const mutation = liked ? removeWishlistMutation : addWishlistMutation; | ||
|
|
||
| mutation.mutate( | ||
| { userId: Number(userId), templestayId: Number(templestayId) }, | ||
| { userId: Number(userId), templestayId: Number(id) }, | ||
| { | ||
| onSuccess: () => { | ||
| setLiked(!liked); | ||
|
|
@@ -126,17 +125,13 @@ const TempleDetailClient = ({ templestayId }: TempleDetailClientProps) => { | |
| )} | ||
|
|
||
| <div className={styles.headerBox}> | ||
| <TempleTopbar templeName={data.templeName} templestayName={data.templestayName} /> | ||
| <TempleTopbar templestayName={data.templestayName} /> | ||
| </div> | ||
| <div className={styles.topDetailContainer}> | ||
| <DetailCarousel /> | ||
| <div className={styles.templeTitleBox}> | ||
| <TempleTitle | ||
| tag={data.tag} | ||
| templeName={data.templeName} | ||
| templestayName={data.templestayName} | ||
| /> | ||
| <TempleDetailInfo address={data.address} phoneNumber={data.phoneNumber} /> | ||
| <TempleTitle templeName={data.templeName} templestayName={data.templestayName} /> | ||
| <TempleDetailInfo address={data.address} phoneNumber={data.phone} /> | ||
| </div> | ||
| <StickyTapBar> | ||
| <TapBar type="detail" /> | ||
|
|
@@ -145,15 +140,11 @@ const TempleDetailClient = ({ templestayId }: TempleDetailClientProps) => { | |
| <div className={styles.templeDetailMiddle}> | ||
| <TempleReview /> | ||
| <TempleSchedule schedule={data.schedule} /> | ||
| <TemplePrice templestayPrice={data.templestayPrice} /> | ||
| <TemplePrice templestayPrice={data.price} /> | ||
| <TempleInfo introduction={data.introduction} /> | ||
| </div> | ||
|
|
||
| <SmallMap | ||
| detailAddress={data.detailAddress} | ||
| latitude={data.latitude} | ||
| longitude={data.longitude} | ||
| /> | ||
| <SmallMap detailAddress={data.address} latitude={data.lat} longitude={data.lon} /> | ||
| <ButtonBar | ||
| type="wish" | ||
| label="예약하러 가기" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| 'use client'; | ||
| import { useGetTempleImages } from '@apis/templeInfo'; | ||
| import PageName from '@components/common/pageName/PageName'; | ||
| import ExceptLayout from '@components/except/exceptLayout/ExceptLayout'; | ||
| import Image from 'next/image'; | ||
|
|
||
| import * as styles from './style.css'; | ||
|
|
||
| interface TemplePhotoPageProps { | ||
| templestayId: number; | ||
| } | ||
|
|
||
| const TempleImageClient = ({ templestayId }: TemplePhotoPageProps) => { | ||
| const { data, isLoading, isError } = useGetTempleImages(templestayId); | ||
|
|
||
| if (isLoading) { | ||
| return <ExceptLayout type="loading" />; | ||
| } | ||
|
|
||
| if (isError) { | ||
| return <ExceptLayout type="networkError" />; | ||
| } | ||
|
|
||
| if (!data || !data.imgUrls.length) { | ||
| return <p>No temple images available</p>; | ||
| } | ||
|
|
||
| return ( | ||
| <div className={styles.photoContainer}> | ||
| <div className={styles.headerBox}> | ||
| <PageName title="사진" /> | ||
| </div> | ||
| <div className={styles.photoGrid}> | ||
| {data.imgUrls.map((photo) => ( | ||
| <Image | ||
| key={photo.imgurl} | ||
| width={162} | ||
| height={162} | ||
| src={photo.imgurl} | ||
| alt="템플스테이 사진" | ||
| className={styles.photoItem} | ||
| /> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default TempleImageClient; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,10 @@ | ||
| import { templeImagesQueryOptions } from '@apis/templeInfo/prefetch'; | ||
| import { TemplestayImg, TemplestayImgsResponse } from '@apis/templeInfo/type'; | ||
| import PageName from '@components/common/pageName/PageName'; | ||
| import { QueryClient } from '@tanstack/react-query'; | ||
| import Image from 'next/image'; | ||
|
|
||
| import * as styles from './style.css'; | ||
| import TempleImageClient from './TempleImagesClient'; | ||
|
|
||
| const TemplePhotoPage = async ({ params }: { params: Promise<{ templestayId: string }> }) => { | ||
| const { templestayId } = await params; | ||
| const queryClient = new QueryClient(); | ||
| const cachedData = queryClient.getQueryData(['images', templestayId]); | ||
| if (!cachedData) { | ||
| await queryClient.prefetchQuery(templeImagesQueryOptions(templestayId)); | ||
| } | ||
| const data = | ||
| queryClient.getQueryData<TemplestayImgsResponse>(['images', templestayId]) || | ||
| (await queryClient.fetchQuery(templeImagesQueryOptions(templestayId))); | ||
|
|
||
| if (!data) { | ||
| return <p>No temple images available</p>; | ||
| } | ||
| const templestayIdNumber = Number(templestayId); | ||
|
|
||
| return ( | ||
| <div className={styles.photoContainer}> | ||
| <div className={styles.headerBox}> | ||
| <PageName title="사진" /> | ||
| </div> | ||
| <div className={styles.photoGrid}> | ||
| {data.templestayImgs.map((photo: TemplestayImg) => ( | ||
| <Image | ||
| width={162} | ||
| height={162} | ||
| key={photo.imageUrlId} | ||
| src={photo.imgUrl} | ||
| alt={`Temple Stay ${photo.imageUrlId}`} | ||
| className={styles.photoItem} | ||
| /> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ); | ||
| return <TempleImageClient templestayId={templestayIdNumber} />; | ||
| }; | ||
|
|
||
| export default TemplePhotoPage; |
Uh oh!
There was an error while loading. Please reload this page.