-
Notifications
You must be signed in to change notification settings - Fork 39
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
[김예준] Sprint10 #261
The head ref may contain hidden characters: "Next-\uAE40\uC608\uC900-sprint10-merge"
[김예준] Sprint10 #261
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 |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
} | ||
|
||
&::placeholder { | ||
color: var(--gray-200); | ||
color: var(--gray-400); | ||
font-size: 16px; | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,4 +1,5 @@ | ||||||||
import { useState } from 'react' | ||||||||
import { useState, useMemo } from 'react' | ||||||||
import Link from 'next/link' | ||||||||
import useFetechData from '@/src/hooks/useFetechData' | ||||||||
import { ArticleListResponse } from '@/src/interfaces/Article.interface' | ||||||||
import Article from './Article' | ||||||||
|
@@ -9,14 +10,19 @@ import Button from '@/src/components/Button/Button' | |||||||
import styles from './Article.module.scss' | ||||||||
|
||||||||
export default function ArticleList() { | ||||||||
const [orderBy, setOrderBy] = useState('recent') | ||||||||
type OrderOption = 'recent' | 'like' | ||||||||
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. 여기서 dropdown으로 내려주는 친구들이있네요! const ODER_OPTION = {
recent: '최신순',
like: '인기순',
} as const
type OrderOption = keyof typeof ODER_OPTION 이렇게 key에 영어를 넣고 value에 한글을 넣으면 드롭다운에서 value로 보여줄 때 한글로 잘보일거에요! 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. 아마 여기를 이렇게 바꾸면 타입에러가 조금씩 발생할 거에요. 그부분은 한번 고쳐서 타입세이프하게 만들어보세요 😃 |
||||||||
const [orderBy, setOrderBy] = useState<OrderOption>('recent') | ||||||||
const [searchTitle, setSearchTitle] = useState('') | ||||||||
const fetechArticles = useFetechData<ArticleListResponse>( | ||||||||
`articles?page=1`, | ||||||||
10, | ||||||||
orderBy, | ||||||||
searchTitle | ||||||||
) | ||||||||
|
||||||||
const url = useMemo(() => { | ||||||||
let baseUrl = `articles?page=1&pageSize=10&orderBy=${orderBy}` | ||||||||
if (searchTitle) { | ||||||||
baseUrl += `&keyword=${searchTitle}` | ||||||||
} | ||||||||
return baseUrl | ||||||||
}, [orderBy, searchTitle]) | ||||||||
Comment on lines
+17
to
+23
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. useMemo를 사용하여 url변화값을 잘 메모해주셨어요! 한가지 종종사용되는 부분을 추가적으로 말씀드리자면 orderByt나 keyword같이 검색에 필요한 파라미터들은 router를 이용하여 실제 url query에 넣기도합니다. |
||||||||
|
||||||||
const fetechArticles = useFetechData<ArticleListResponse>(url) | ||||||||
const { data: ArticleList, isLoading } = fetechArticles | ||||||||
Comment on lines
+25
to
26
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.
Suggested change
하나로 합칠 수 있을 것 같아요! |
||||||||
const orderOptions = { | ||||||||
최신순: 'recent', | ||||||||
|
@@ -34,15 +40,23 @@ export default function ArticleList() { | |||||||
return <Spiner /> | ||||||||
} | ||||||||
if (ArticleList?.totalCount === 0) { | ||||||||
return <>게시글이 없습니다.</> | ||||||||
return ( | ||||||||
<> | ||||||||
<SearchBar keyword={handleSearchTitle} /> | ||||||||
<br /> | ||||||||
게시글이 없습니다. | ||||||||
</> | ||||||||
) | ||||||||
} | ||||||||
|
||||||||
return ( | ||||||||
<div className={styles.container}> | ||||||||
<div className={styles.containerTitleSection}> | ||||||||
<div className={styles.containerTitle}>게시글</div> | ||||||||
|
||||||||
<Button>글쓰기</Button> | ||||||||
<Link href="/boards/create"> | ||||||||
<Button>글쓰기</Button> | ||||||||
</Link> | ||||||||
</div> | ||||||||
|
||||||||
<div className={styles.controlSection}> | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기서 value로 바꿔줬기때문에 지금 dropdown에서 영어로 나오고 있어요!
만약 value로 여기를 바꾸면 내려오는 options도 다 바꿔줘야합니다!