Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#210_change-post-status
Browse files Browse the repository at this point in the history
  • Loading branch information
shinhyojeong committed Jan 21, 2024
2 parents b059b8f + 3f3fd53 commit d773739
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
12 changes: 11 additions & 1 deletion src/apis/post/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,17 @@ export const useGetPostQuery = (id: number) =>
title: data.title,
description: data.description,
location: data.location
}
},
postImages: [
{
id: 0,
src: data.thumbnailImageUrl || ''
},
...(data.imageUrls.map((url, idx) => ({
id: idx + 1,
src: url
})) || [])
]
})
})

Expand Down
36 changes: 21 additions & 15 deletions src/pages/post/[postId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
Text,
IconButton,
SelectBox,
Button
Button,
ImageModal
} from '@offer-ui/react'
import type { GetServerSideProps } from 'next'
import Link from 'next/link'
Expand Down Expand Up @@ -51,17 +52,10 @@ const PostDetailPage = ({ postId }: Props): ReactElement => {
const tradeStatusDialog = useModal()
const deleteModal = useModal()
const { user } = useAuth()
const imageModal = useModal()

const isSeller = user.id === getPostQuery.data?.seller.id
const totalImages = [
getPostQuery.data?.thumbnailImageUrl || '',
...(getPostQuery.data?.imageUrls || [])
]

const postImages = totalImages.map((url, idx) => ({
id: idx,
src: url
}))
const postImages = getPostQuery.data?.postImages || []

const handleChangeTradeStatus = async (status: TradeStatusType) => {
const nextStatusCode = status.code
Expand All @@ -84,7 +78,7 @@ const PostDetailPage = ({ postId }: Props): ReactElement => {
<>
<Layout>
<Main>
<div>
<div onClick={imageModal.openModal}>
<Carousel images={postImages || []} isArrow name="post-carousel" />
</div>
<Content>
Expand Down Expand Up @@ -170,6 +164,12 @@ const PostDetailPage = ({ postId }: Props): ReactElement => {
<MainDivider size="bold" />
<PriceOfferCard isSeller={isSeller} postId={postId} />
</Layout>
<ImageModal
images={postImages}
isOpen={imageModal.isOpen}
name="post-detail"
onClose={imageModal.closeModal}
/>
<CommonModal
buttons={[
<Button key="delete" size="large" onClick={handleClickDelete}>
Expand Down Expand Up @@ -242,6 +242,8 @@ const MainDivider = styled(Divider)`
`}
`
const Main = styled.div`
width: 100%;
${({ theme }): SerializedStyles => css`
${theme.mediaQuery.tablet} {
margin: 0;
Expand Down Expand Up @@ -294,14 +296,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`
Expand All @@ -312,6 +311,13 @@ const ProductConditionBadge = styled.div`
color: ${theme.colors.white};
${theme.fonts.body02B}
${theme.mediaQuery.tablet} {
margin: 20px 0;
}
${theme.mediaQuery.mobile} {
margin: 20px 0;
}
`}
`

Expand Down

0 comments on commit d773739

Please sign in to comment.