-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #359 from ttaerrim/355-pagination-improve
[Modify] 페이지네이션 없는 페이지에 접근 시 게시물 없음 처리
- Loading branch information
Showing
10 changed files
with
130 additions
and
15 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,21 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const background = style({ | ||
width: '80%', | ||
height: '80%', | ||
opacity: '0.1', | ||
}); | ||
|
||
export const container = style({ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
width: '100%', | ||
maxWidth: '80rem', | ||
position: 'relative', | ||
}); | ||
|
||
export const wrapper = style({ | ||
position: 'absolute', | ||
width: '80%', | ||
}); |
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,19 @@ | ||
import BackgroundImage from '@/assets/images/main.png'; | ||
|
||
import * as styles from './index.css'; | ||
|
||
type MessageWrapperProps = { | ||
children: React.ReactNode; | ||
}; | ||
export function MessageWrapper({ children }: MessageWrapperProps) { | ||
return ( | ||
<div className={styles.container}> | ||
<img | ||
src={BackgroundImage} | ||
alt="morak background" | ||
className={styles.background} | ||
/> | ||
<div className={styles.wrapper}>{children}</div> | ||
</div> | ||
); | ||
} |
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
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,25 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
import { vars } from '@/styles'; | ||
import { sansBold16, sansRegular16 } from '@/styles/font.css'; | ||
|
||
const { morakGreen } = vars.color; | ||
|
||
export const back = style([ | ||
sansBold16, | ||
{ | ||
textDecorationLine: 'underline', | ||
marginTop: '0.6rem', | ||
color: morakGreen, | ||
cursor: 'pointer', | ||
}, | ||
]); | ||
|
||
export const text = style([ | ||
sansRegular16, | ||
{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
textAlign: 'center', | ||
}, | ||
]); |
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 { useNavigate } from 'react-router-dom'; | ||
|
||
import { MessageWrapper } from '@/components'; | ||
|
||
import * as styles from './EmptyPage.css'; | ||
|
||
export function EmptyPage() { | ||
const navigate = useNavigate(); | ||
const onClickBack = () => navigate(-1); | ||
|
||
return ( | ||
<MessageWrapper> | ||
<p className={styles.text}> | ||
게시물이 없습니다. | ||
<button type="button" className={styles.back} onClick={onClickBack}> | ||
이전 페이지로 돌아가기 | ||
</button> | ||
</p> | ||
</MessageWrapper> | ||
); | ||
} |
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,24 +1,39 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { Pagination } from '@/components'; | ||
import { usePagination } from '@/hooks'; | ||
import { queryKeys } from '@/queries'; | ||
|
||
import * as styles from './index.css'; | ||
import { MogacoList } from './MogacoList'; | ||
import { MogacoListHeader } from './MogacoListHeader'; | ||
|
||
const PAGE_UNIT = 10; | ||
export function MogacoPage() { | ||
const { currentPage, onClickItem, onClickNext, onClickPrev } = | ||
usePagination(); | ||
|
||
const { data: mogacoList } = useQuery( | ||
queryKeys.mogaco.list({ page: currentPage.toString() }), | ||
); | ||
const { data: allMogacoList } = useQuery(queryKeys.mogaco.list()); | ||
|
||
const maxPage = Math.floor((allMogacoList?.length || 0) / PAGE_UNIT + 1); | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<MogacoListHeader /> | ||
<MogacoList currentPage={currentPage} /> | ||
<Pagination | ||
className={styles.pagination} | ||
currentPage={currentPage} | ||
onClickItem={onClickItem} | ||
onClickNext={onClickNext} | ||
onClickPrev={onClickPrev} | ||
/> | ||
{mogacoList?.length !== 0 && ( | ||
<Pagination | ||
className={styles.pagination} | ||
currentPage={currentPage} | ||
pageCount={maxPage} | ||
onClickItem={onClickItem} | ||
onClickNext={onClickNext} | ||
onClickPrev={onClickPrev} | ||
/> | ||
)} | ||
</div> | ||
); | ||
} |