-
Notifications
You must be signed in to change notification settings - Fork 42
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
1 parent
d4ddc9a
commit 40721e1
Showing
4 changed files
with
171 additions
and
29 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
FE/airbnb/src/components/reserveRoomList/reserveForm/ReserveBtn.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,24 @@ | ||
import styled from 'styled-components'; | ||
|
||
interface Props { | ||
className: string; | ||
} | ||
|
||
const ReserveBtn = ({ className }: Props) => { | ||
return <StyledReserveBtn className={className}>예약하기</StyledReserveBtn>; | ||
}; | ||
|
||
export default ReserveBtn; | ||
|
||
const StyledReserveBtn = styled.button` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100%; | ||
height: 55px; | ||
border: none; | ||
border-radius: 10px; | ||
background-color: ${({ theme }) => theme.colors.black}; | ||
color: ${({ theme }) => theme.colors.white}; | ||
font-weight: 700; | ||
`; |
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
87 changes: 87 additions & 0 deletions
87
FE/airbnb/src/components/reserveRoomList/reserveForm/ReserveFromPrice.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,87 @@ | ||
import { useRecoilValue } from 'recoil'; | ||
import styled from 'styled-components'; | ||
import { selectDateState } from '../../../recoil/calendarAtom'; | ||
import { getBetweenDays } from '../../header/form/calendar/calendarDateFn'; | ||
|
||
interface Props { | ||
chargePerNight: number; | ||
} | ||
|
||
const ReserveFromPrice = ({ chargePerNight }: Props) => { | ||
const selectDate = useRecoilValue(selectDateState); | ||
|
||
const getCleanCharge = (totalPrice: number): number => Math.floor(totalPrice * 0.03); | ||
const getServiceCharge = (totalPrice: number): number => Math.floor(totalPrice * 0.15); | ||
const getTaxCharge = (totalPrice: number): number => Math.floor(totalPrice * 0.01); | ||
|
||
const betweenDays = getBetweenDays(selectDate.checkIn, selectDate.checkOut); | ||
const totalPrice = chargePerNight * betweenDays; | ||
|
||
const cleanCharge = getCleanCharge(totalPrice); | ||
const serviceCharge = getServiceCharge(totalPrice); | ||
const taxCharge = getTaxCharge(totalPrice); | ||
|
||
const totalCharge = totalPrice + cleanCharge + serviceCharge + taxCharge; | ||
|
||
return ( | ||
<StyledReservePriceWrapper> | ||
<StyledReserveFormPrice> | ||
<div className='reserve-price__column'> | ||
<div className='reserve-price__title'> | ||
₩{chargePerNight.toLocaleString()} x {betweenDays}박 | ||
</div> | ||
<div className='reserve-price__price'>₩{totalPrice.toLocaleString()}</div> | ||
</div> | ||
<div className='reserve-price__column'> | ||
<div className='reserve-price__title'>청소비</div> | ||
<div className='reserve-price__price'>₩{cleanCharge.toLocaleString()}</div> | ||
</div> | ||
<div className='reserve-price__column'> | ||
<div className='reserve-price__title'>서비스 수수료</div> | ||
<div className='reserve-price__price'>₩{serviceCharge.toLocaleString()}</div> | ||
</div> | ||
<div className='reserve-price__column'> | ||
<div className='reserve-price__title'>숙박세와 수수료</div> | ||
<div className='reserve-price__price'>₩{taxCharge.toLocaleString()}</div> | ||
</div> | ||
</StyledReserveFormPrice> | ||
<StyledReserveCharge> | ||
<div className='reserve-price__column'> | ||
<div className='reserve-price__title'>총 합계</div> | ||
<div className='reserve-price__price'>₩{totalCharge.toLocaleString()}</div> | ||
</div> | ||
</StyledReserveCharge> | ||
</StyledReservePriceWrapper> | ||
); | ||
}; | ||
|
||
export default ReserveFromPrice; | ||
|
||
const StyledReservePriceWrapper = styled.div` | ||
.reserve-price__column { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-bottom: 8px; | ||
} | ||
.reserve-price__title { | ||
text-decoration: underline; | ||
} | ||
`; | ||
|
||
const StyledReserveFormPrice = styled.div` | ||
padding-bottom: 1rem; | ||
border-bottom: ${({ theme }) => `2px solid ${theme.colors.gray5}`}; | ||
margin-bottom: 1rem; | ||
`; | ||
|
||
const StyledReserveCharge = styled.div` | ||
font-weight: 700; | ||
.reserve-price__column { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-bottom: 8px; | ||
} | ||
.reserve-price__title { | ||
text-decoration: underline; | ||
} | ||
`; |