1+ import Badge from "@components/common/Badge" ;
12import { Arrow } from "@components/icons" ;
23import styled from "@emotion/styled" ;
3- import {
4- addDateAndTime ,
5- dateToPattern ,
6- getDayOfWeek ,
7- getDiffDays ,
8- parseStringDateAndCombine ,
9- } from "@lib/days" ;
104import type { FC } from "react" ;
115
126type ComponentProps = {
13- startDate : Date ;
14- endDate : Date ;
157 currentPageIndex : number ;
168 startWeekOfMonday : Date ;
17- endWeekOfSunday : Date ;
189 onClickPageUp : ( ) => void ;
1910 onClickPageDown : ( ) => void ;
11+ totalNumberOfTableDays : number ;
2012} ;
2113
2214type ArrowProps = {
@@ -25,37 +17,17 @@ type ArrowProps = {
2517} ;
2618
2719const Pagination : FC < ComponentProps > = ( {
28- startDate,
29- endDate,
3020 currentPageIndex,
3121 onClickPageDown,
3222 onClickPageUp,
33- endWeekOfSunday,
3423 startWeekOfMonday,
24+ totalNumberOfTableDays,
3525} ) => {
36- const diffDays = getDiffDays ( endWeekOfSunday , startWeekOfMonday ) ;
3726 const firstPageIndex = 0 ;
38- const lastPageIndex = Math . floor ( diffDays / 7 ) ;
27+ const lastPageIndex = Math . floor ( totalNumberOfTableDays / 7 ) ;
3928
4029 const isFirstPage = currentPageIndex === firstPageIndex ;
4130 const isLastPage = currentPageIndex === lastPageIndex ;
42- const currentStartDate = addDateAndTime ( startDate , {
43- days : currentPageIndex * 7 ,
44- } ) ;
45-
46- const currentLastDate =
47- endDate . getTime ( ) > addDateAndTime ( currentStartDate , { days : 6 } ) . getTime ( )
48- ? addDateAndTime ( currentStartDate , { days : 6 } )
49- : endDate ;
50-
51- const parsedCurrentStartDate = parseStringDateAndCombine (
52- dateToPattern ( currentStartDate ) ,
53- "-"
54- ) ;
55- const parsedCurrentLastDate = parseStringDateAndCombine (
56- dateToPattern ( currentLastDate ) ,
57- "-"
58- ) ;
5931
6032 return (
6133 < Container >
@@ -68,29 +40,34 @@ const Pagination: FC<ComponentProps> = ({
6840 </ ArrowWrapper >
6941 < TextWrapper >
7042 < span >
71- { parsedCurrentStartDate } { getDayOfWeek ( currentStartDate ) } 요일
43+ { startWeekOfMonday . getFullYear ( ) } 년 { startWeekOfMonday . getMonth ( ) + 1 }
44+ 월
7245 </ span >
73- { parsedCurrentStartDate !== parsedCurrentLastDate && (
74- < span >
75- { " - " }
76- { parsedCurrentLastDate } { getDayOfWeek ( currentLastDate ) } 요일
77- </ span >
78- ) }
7946 </ TextWrapper >
80- < ArrowWrapper
81- isShown = { ! isLastPage }
82- direction = { "right" }
83- onClick = { onClickPageUp }
84- >
85- < Arrow />
86- </ ArrowWrapper >
47+ < BadgeRightArrowWrapper >
48+ { ! isLastPage && (
49+ < BadgeWrapper >
50+ < Badge > 다음주도 있어요!</ Badge >
51+ </ BadgeWrapper >
52+ ) }
53+ < ArrowWrapper
54+ isShown = { ! isLastPage }
55+ direction = { "right" }
56+ onClick = { onClickPageUp }
57+ >
58+ < Arrow />
59+ </ ArrowWrapper >
60+ </ BadgeRightArrowWrapper >
8761 </ Container >
8862 ) ;
8963} ;
9064
9165export default Pagination ;
9266
9367const ArrowWrapper = styled . div < ArrowProps > `
68+ display: flex;
69+ align-items: center;
70+ justify-content: center;
9471 visibility: ${ ( props ) => ( props . isShown ? "visible" : "hidden" ) } ;
9572 transform: ${ ( props ) =>
9673 props . direction === "left" ? "rotate(-180deg)" : "" } ;
@@ -107,6 +84,12 @@ const ArrowWrapper = styled.div<ArrowProps>`
10784 }
10885` ;
10986
87+ const BadgeRightArrowWrapper = styled . div `
88+ position: relative;
89+ align-items: center;
90+ display: flex;
91+ ` ;
92+
11093const Container = styled . div `
11194 display: flex;
11295 justify-content: space-between;
@@ -118,3 +101,9 @@ const Container = styled.div`
118101const TextWrapper = styled . div `
119102 font-size: 1.1rem;
120103` ;
104+
105+ const BadgeWrapper = styled . div `
106+ position: absolute;
107+ right: 2rem;
108+ font-size: 1.2rem;
109+ ` ;
0 commit comments