-
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
a1f13f9
commit edf0913
Showing
6 changed files
with
74 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
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,12 @@ | ||
import { Link } from 'react-router-dom'; | ||
|
||
interface Props { | ||
children: any; | ||
to: string; | ||
condition: boolean; | ||
} | ||
|
||
const ConditionalLink = ({ children, to, condition }: Props) => | ||
!!condition && to ? <Link to={to}>{children}</Link> : <>{children}</>; | ||
|
||
export default ConditionalLink; |
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,23 +1,32 @@ | ||
import { dateToString, getDateByTime } from '../components/header/form/calendar/calendarDateFn'; | ||
|
||
interface reserveInfoType { | ||
address: string; | ||
checkIn: number; | ||
checkOut: number; | ||
minCharge: number; | ||
maxCharge: number; | ||
guests: number; | ||
} | ||
|
||
interface apiType { | ||
url: string; | ||
getRooms: ( | ||
checkIn: number, | ||
checkOut: number, | ||
minCharge: number, | ||
maxCharge: number, | ||
guests: number, | ||
location?: string | ||
) => string; | ||
getRooms: ({ | ||
address, | ||
checkIn, | ||
checkOut, | ||
minCharge, | ||
maxCharge, | ||
guests, | ||
}: reserveInfoType) => string; | ||
} | ||
export const API: apiType = { | ||
url: 'http://13.125.35.62', | ||
getRooms: (checkIn, checkOut, minCharge, maxCharge, guests, location) => { | ||
getRooms: ({ address, checkIn, checkOut, minCharge, maxCharge, guests }) => { | ||
const url = API.url; | ||
const checkInDate = dateToString(getDateByTime(checkIn)); | ||
const checkOutDate = dateToString(getDateByTime(checkOut)); | ||
const query = `check_in=${checkInDate}&check_out=${checkOutDate}&min_charge=${minCharge}&max_charge=${maxCharge}&guests=${guests}`; | ||
const query = `address=${address}&check_in=${checkInDate}&check_out=${checkOutDate}&min_charge=${minCharge}&max_charge=${maxCharge}&guests=${guests}`; | ||
return url + '/accommodations?' + query; | ||
}, | ||
}; |
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,6 @@ | ||
const go = (arg, ...fns) => fns.reduce((res, fn) => fn(res), arg); | ||
|
||
export const pipe = | ||
(fn, ...fns) => | ||
(...args) => | ||
go(fn(...args), ...fns); |