NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import React from 'react';
import {​
Typography, Popover, Button, Paper, Grid,
}​ from '@material-ui/core';
import {​ makeStyles }​ from '@material-ui/core/styles';
import {​ Input }​ from 'rsuite';
import {​ IoSearchSharp, IoPeopleOutline }​ from 'react-icons/io5';
import {​ FaPlusSquare, FaMinusSquare }​ from 'react-icons/fa';
import {​ AiOutlineLeft }​ from 'react-icons/ai';
import {​ useRouter }​ from 'next/router';
import DatePicker from 'react-datepicker';
import {​ translate }​ from 'react-polyglot';
import dayjs from 'dayjs';

const useStyles = makeStyles(() => ({​
btnSearch: {​
width: '100%',
height: '80%',
'&:focus': {​
outline: 'none',
}​,

color: '#FFF',
// width: "15%",
textTransform: 'none',
}​,
selectPeople: {​
background: 'white',
borderRadius: '0px !important',
border: '1px solid #DCDCDC !important',
color: '#707070',
height: 30,
padding: '0 15px',

// boxShadow: "0 3px 5px 2px rgba(0, 105, 135, .3)",
}​,
gridContainer: {​
'&.MuiGrid-container': {​
paddingLeft: '13%',
paddingRight: '8%',
}​,
}​,
widthDatePiker: {​
textAlign: 'center !important',
width: '90%',
}​,
}​));

const BannerSearch = (props) => {​
const classes = useStyles();
const router = useRouter();
const {​ t }​ = props;
const {​
name, checkin, checkout, children, room, adult,
}​ = props.data;

const [anchorEl, setAnchorEl] = React.useState(null);
const handleClick = (event) => {​
setAnchorEl(event.currentTarget);
}​;
const handleClose = () => {​
setAnchorEl(null);
}​;
const openDialog = Boolean(anchorEl);
const id = openDialog ? 'simple-popover' : undefined;

const [count, setCount] = React.useState({​
room: parseInt(room),
adult: parseInt(adult),
children: parseInt(children),
}​);
const date = new Date();
const [startDate, setStartDate] = React.useState(
date.setDate(date.getDate()),
);
// const [endDate, setEndDate] = React.useState(startDate.getDate() + 14);
const [endDate, setEndDate] = React.useState(date.setDate(date.getDate()));

React.useEffect(() => {​
setCount({​
adult: parseInt(adult),
children: parseInt(children),
room: parseInt(room),
}​);
if (checkin && checkout) {​
setStartDate(new Date(checkin));
setEndDate(new Date(checkout));
}​
}​, [props.data]);
const [search, setSearch] = React.useState('');
const handleChangeDate = (date) => {​
const startDate = new Date(date);
const endDate = new Date(startDate);
const finalEndDate = endDate.setDate(endDate.getDate() + 14);
setStartDate(date);
setEndDate(finalEndDate);
}​;

const handleSubmit = () => {​
console.log('123');
const start = dayjs(startDate).format('MM/DD/YYYY');
const end = dayjs(endDate).format('MM/DD/YYYY');
router.push({​
pathname: '/search',
query: {​
keyword: count._id,
name: count.name,
checkin: start,
checkout: end,
room: count.room,
adult: count.adult,
children: count.children,
}​,
}​);
}​;
return (
<div className="bg-light-green p-3 flex-center ">
<Grid
className="w-75 flex-center"
container
justify="space-between"
direction="row"
// style={​{​ paddingLeft: "13%", paddingRight: "3%" }​}​
>
<div className="position-absolute" style={​{​ marginLeft: '-10vh' }​}​>
<Button className="none-border" onClick={​() => router.back()}​>
<AiOutlineLeft size={​30}​ color="white" />
</Button>
</div>
<Grid item xs={​2}​>
<IoSearchSharp
className="position-absolute mt-1 ml-1"
style={​{​ width: 20, height: 20 }​}​
/>
<Input
className="pl-5 w-100 none-border"
onChange={​(event) => setSearch(event.target)}​
value={​search}​
/>
</Grid>
<Grid item xs={​2}​>
<img
alt="check-in"
style={​{​ zIndex: 2, marginTop: -6 }​}​
className="img-contain position-absolute ml-2 "
width="2%"
height="5%"
src="../../images/home-check-in.png"
/>
<DatePicker
className="text-center w-100 none-border"
selected={​startDate}​
showNextMonths
dateFormat="dd/MM/yyyy"
monthsShown={​2}​
onChange={​(date) => handleChangeDate(date)}​
selectStart
minDate={​new Date()}​
startDate={​startDate}​
endDate={​endDate}​
/>
</Grid>
<Grid item xs={​2}​>
<img
alt="check-out"
style={​{​ zIndex: 2, marginTop: -6 }​}​
className="img-contain position-absolute ml-2 "
width="2%"
height="5%"
src="../../images/home-check-out.png"
/>
<DatePicker
style={​{​ backgroundColor: '#FFF' }​}​
className="w-100 text-center non-border"
dateFormat="dd/MM/yyyy"
selected={​endDate}​
disabled
/>
</Grid>
<Grid item xs={​12}​ sm={​3}​>
<Button
color="default"
variant="contained"
onClick={​handleClick}​
className={​classes.selectPeople}​
startIcon={​<IoPeopleOutline />}​
style={​{​ textTransform: 'none', width: '100%' }​}​
>
<Typography variant="subtitle2">
{​count.room}​
{​t('room')}​
{​count.adult}​
{​t('adult')}​
{​count.children}​
{​t('children')}​
</Typography>
</Button>

<Popover
id={​id}​
open={​openDialog}​
anchorEl={​anchorEl}​
onClose={​handleClose}​
anchorOrigin={​{​
vertical: 'bottom',
horizontal: 'center',
}​}​
transformOrigin={​{​
vertical: 'top',
horizontal: 'center',
}​}​
>
<Paper className="p-1" style={​{​ width: 270 }​}​>
<div className="d-flex p-3 align-items-center">
<Typography variant="subtitle1" className="w-50">
{​t('room')}​
</Typography>
<Button
disabled={​count.room < 1}​
className="none-border"
onClick={​() => setCount({​ ...count, room: count.room - 1 }​)}​
>
<FaMinusSquare
className="mx-auto"
size={​36}​
color="#60AF92"
/>
</Button>
<Typography variant="subtitle1" className="mx-auto">
{​count.room}​
</Typography>
<Button
className="none-border"
onClick={​() => setCount({​ ...count, room: count.room + 1 }​)}​
>
<FaPlusSquare className="mx-auto" size={​36}​ color="#60AF92" />
</Button>
</div>
<div className="d-flex p-3 align-items-center">
<Typography className="w-50">{​t('adult')}​</Typography>
<Button
disabled={​count.adult < 1}​
className="none-border"
onClick={​() => setCount({​ ...count, adult: count.adult - 1 }​)}​
>
<FaMinusSquare
className="mx-auto"
size={​36}​
color="#60AF92"
/>
</Button>
<Typography variant="subtitle1" className="mx-auto">
{​count.adult}​
</Typography>
<Button
className="none-border"
onClick={​() => setCount({​ ...count, adult: count.adult + 1 }​)}​
>
<FaPlusSquare className="mx-auto" size={​36}​ color="#60AF92" />
</Button>
</div>
<div className="d-flex p-3 align-items-center">
<Typography className="w-50">{​t('children')}​</Typography>
<Button
className="none-border"
disabled={​count.children < 1}​
onClick={​() => setCount({​ ...count, children: count.children - 1 }​)}​
>
<FaMinusSquare
className="mx-auto"
size={​36}​
color="#60AF92"
/>
</Button>
<Typography variant="subtitle1" className="mx-auto">
{​count.children}​
</Typography>
<Button
className="none-border"
onClick={​() => setCount({​ ...count, children: count.children + 1 }​)}​
>
<FaPlusSquare className="mx-auto" size={​36}​ color="#60AF92" />
</Button>
</div>
</Paper>
</Popover>
</Grid>
<Grid item xs={​12}​ sm={​2}​>
<Button
className={​classes.btnSearch}​
style={​{​ backgroundColor: '#F5C158' }​}​
variant="contained"
onClick={​handleSubmit}​
>
{​t('Search')}​
</Button>
</Grid>
</Grid>
</div>
);
}​;

export default translate()(BannerSearch);
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.