diff --git a/src/apis/post/queries.ts b/src/apis/post/queries.ts index 50f27c9d..adee3c70 100644 --- a/src/apis/post/queries.ts +++ b/src/apis/post/queries.ts @@ -10,7 +10,15 @@ export const useCreatePostMutation = () => export const useGetPostQuery = (id: number) => useQuery({ queryKey: ['getPost', id], - queryFn: () => getPost(id) + queryFn: () => getPost(id), + select: data => ({ + ...data, + postImages: + data.imageUrls.map((url, idx) => ({ + id: idx, + src: url + })) || [] + }) }) export const useGetCategoriesQuery = () => diff --git a/src/pages/post/[postId]/index.tsx b/src/pages/post/[postId]/index.tsx index d31a16e0..902b4a9d 100644 --- a/src/pages/post/[postId]/index.tsx +++ b/src/pages/post/[postId]/index.tsx @@ -1,14 +1,21 @@ import { css } from '@emotion/react' import type { SerializedStyles } from '@emotion/react' import styled from '@emotion/styled' -import { Carousel, Divider, Text, IconButton, SelectBox } from '@offer-ui/react' +import { + Carousel, + Divider, + Text, + IconButton, + SelectBox, + ImageModal +} from '@offer-ui/react' import type { GetServerSideProps } from 'next' import type { ReactElement } from 'react' import { getTimeDiffText, toLocaleCurrency } from '@utils/format' import { useGetPostQuery } from '@apis' import { UserProfile, PriceOfferCard, PostFieldList } from '@components' import { TRADE_STATUS } from '@constants' -import { useAuth } from '@hooks' +import { useAuth, useModal } from '@hooks' type Props = { postId: number } export const getServerSideProps: GetServerSideProps = async ({ @@ -22,17 +29,15 @@ export const getServerSideProps: GetServerSideProps = async ({ const PostDetailPage = ({ postId }: Props): ReactElement => { const getPostQuery = useGetPostQuery(postId) const { user } = useAuth() + const imageModal = useModal() const isSeller = user.id === getPostQuery.data?.seller.id - const postImages = getPostQuery.data?.imageUrls.map((url, idx) => ({ - id: idx, - src: url - })) + const postImages = getPostQuery.data?.postImages || [] return (
-
+
@@ -91,6 +96,12 @@ const PostDetailPage = ({ postId }: Props): ReactElement => {
+
) } @@ -145,6 +156,8 @@ const MainDivider = styled(Divider)` `} ` const Main = styled.div` + width: 100%; + ${({ theme }): SerializedStyles => css` ${theme.mediaQuery.tablet} { margin: 0; @@ -173,14 +186,11 @@ const ProductConditionSelectBox = styled(SelectBox)` ${theme.mediaQuery.tablet} { margin: 20px 0; } - ${theme.mediaQuery.mobile} { - margin: 20px 0; - } `} ` const ProductConditionBadge = styled.div` - margin-bottom: 20px; + margin: 33px 0 16px; padding: 4px 8px 3px; ${({ theme }) => css` @@ -191,6 +201,13 @@ const ProductConditionBadge = styled.div` color: ${theme.colors.white}; ${theme.fonts.body02B} + + ${theme.mediaQuery.tablet} { + margin: 20px 0; + } + ${theme.mediaQuery.mobile} { + margin: 20px 0; + } `} `