-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
287 additions
and
408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { GetPostOffersReq, GetPostOffersRes } from './types' | ||
import { http } from '@utils/http' | ||
|
||
export const getPostOffers = (postId: number) => | ||
http.get<GetPostOffersReq, GetPostOffersRes>(`/posts/${postId}/offers`, { | ||
postId | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './types' | ||
export * from './queries' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { useQuery } from '@tanstack/react-query' | ||
import { getPostOffers } from './apis' | ||
|
||
export const useGetPostOffersQuery = (postId: number) => | ||
useQuery({ | ||
queryKey: ['getPostOffers', postId], | ||
queryFn: () => getPostOffers(postId) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './types' | ||
export * from './queries' | ||
export * from './types' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
src/components/post/PostFieldList/PostFieldList.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { PostFieldList as PostFieldListComponent } from './index' | ||
|
||
type PostFieldList = typeof PostFieldListComponent | ||
|
||
const meta: Meta<PostFieldList> = { | ||
component: PostFieldListComponent, | ||
title: 'Post/PostFieldList' | ||
} | ||
|
||
export default meta | ||
|
||
export const Default: StoryObj<PostFieldList> = { | ||
args: { | ||
date: '1시간 전', | ||
productCondition: '새상품', | ||
tradeType: '직거래', | ||
location: '관악구' | ||
}, | ||
render: args => <PostFieldListComponent {...args} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Divider, Text } from '@offer-ui/react' | ||
import type { ReactElement } from 'react' | ||
import { Styled } from './styled' | ||
import type { PostFieldListProps } from './types' | ||
|
||
const PostFieldList = ({ | ||
productCondition, | ||
tradeType, | ||
date, | ||
location, | ||
height = 50 | ||
}: PostFieldListProps): ReactElement => { | ||
const fields = [ | ||
{ | ||
label: '작성일', | ||
value: date | ||
}, | ||
{ | ||
label: '상품 상태', | ||
value: productCondition | ||
}, | ||
{ | ||
label: '거래 방식', | ||
value: tradeType | ||
}, | ||
{ label: '거래 지역', value: location } | ||
] | ||
|
||
return ( | ||
<> | ||
{fields.map(({ label, value }) => ( | ||
<Styled.PostFieldList key={label}> | ||
<Divider direction="vertical" length={`${height}px`} /> | ||
<Styled.TextWrapper height={height}> | ||
<Text color="grayScale70" styleType="body02M"> | ||
{label} | ||
</Text> | ||
<Text styleType="subtitle01B">{value}</Text> | ||
</Styled.TextWrapper> | ||
</Styled.PostFieldList> | ||
))} | ||
</> | ||
) | ||
} | ||
|
||
export { PostFieldListProps, PostFieldList } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export type PostField = { | ||
label: string | ||
value: string | ||
} | ||
|
||
export type PostFieldListProps = { | ||
date: string | ||
location: string | ||
productCondition: string | ||
tradeType: string | ||
height?: number | ||
} | ||
|
||
export type StyledTextWrapperProps = StyledProps<PostFieldListProps, 'height'> |
Oops, something went wrong.