Skip to content

Commit 4d0cafa

Browse files
committed
Filtering listings in home page
1 parent 0c6bf63 commit 4d0cafa

File tree

5 files changed

+46
-80
lines changed

5 files changed

+46
-80
lines changed

client/src/Graphql/SearchListings/index.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@ interface Props {
4949
}
5050

5151
export class SearchListingsQuery extends React.PureComponent<Props> {
52-
// public shouldComponentUpdate(nextProps: Props) {
53-
// const { address, guests, priceMin, priceMax } = this.props
54-
// if (this.props.address !== nextProps.address) {
55-
// return true
56-
// }
57-
58-
// return false
59-
// }
60-
6152
public render() {
6253
const { address, guests, priceMin, priceMax } = this.props
6354

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import * as React from 'react'
2+
import { Link } from 'react-router-dom'
3+
4+
import { GeoSuggest } from 'src/Components/GeoSuggest'
5+
import { Input } from 'src/Components/Input'
6+
import { Button } from 'src/Components/Button'
7+
import { Label } from 'src/Components/Input/style'
8+
import { Container, Wrapper, Title, Right } from './style'
9+
10+
interface Props {
11+
updateState: (newState: object) => void
12+
}
13+
14+
export const FormUI: React.SFC<Props> = ({ updateState }) => (
15+
<Container>
16+
<Wrapper>
17+
<Title>Book unique homes and experiences.</Title>
18+
19+
<Label>Lokalizacja</Label>
20+
21+
<GeoSuggest />
22+
23+
<Input
24+
onChange={(value: string) =>
25+
updateState({ guests: parseInt(value, 10) })
26+
}
27+
label="Goscie"
28+
placeholder="1 gość"
29+
type="number"
30+
/>
31+
32+
<Right>
33+
<Link to="/listings" style={{ textDecoration: 'none' }}>
34+
<Button>Szukaj</Button>
35+
</Link>
36+
</Right>
37+
</Wrapper>
38+
</Container>
39+
)
Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
import * as React from 'react'
2+
import { Subscribe } from 'unstated'
23

3-
import { Input } from 'src/Components/Input'
4-
import { Button } from 'src/Components/Button'
5-
import { Container, Wrapper, Title, Right } from './style'
4+
import { Filter } from 'src/Containers/Filter'
5+
import { FormUI } from './Form'
66

77
export const Form: React.SFC<{}> = () => (
8-
<Container>
9-
<Wrapper>
10-
<Title>Book unique homes and experiences.</Title>
11-
12-
<Input label="GDZIE?" placeholder="Warszaw" onChange={() => null} />
13-
14-
<Input
15-
onChange={() => null}
16-
label="PRZYJAZD"
17-
placeholder="dd-mm-rrrr"
18-
/>
19-
20-
<Input label="GOSĆIE" placeholder="1 gość" onChange={() => null} />
21-
22-
<Right>
23-
<Button>Szukaj</Button>
24-
</Right>
25-
</Wrapper>
26-
</Container>
8+
<Subscribe to={[Filter]}>
9+
{({ updateState }: Filter) => <FormUI updateState={updateState} />}
10+
</Subscribe>
2711
)

client/src/Pages/Listings/Components/ListingsList/Components/ListingItem/index.tsx

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,53 +31,6 @@ interface Props {
3131

3232
const getRoute = (id: number) => `/listing/${id}`
3333

34-
// export const ListingItem: React.SFC<Props> = ({
35-
// id,
36-
// name,
37-
// category,
38-
// description,
39-
// price,
40-
// beds,
41-
// guests,
42-
// lat,
43-
// lng,
44-
// amenities,
45-
// setPostion
46-
// }) => (
47-
// <Link to={getRoute(id)} style={{ textDecoration: 'none' }}>
48-
// <Container onMouseEnter={() => setPostion(lat, lng)}>
49-
// <Image src="https://a0.muscache.com/im/pictures/126e41c4-2a1b-4251-b516-d239351126f7.jpg?aki_policy=large" />
50-
51-
// <Row>
52-
// <Details>
53-
// <Subtitle>CAŁY APARTAMENT</Subtitle>
54-
// <Title>{name}</Title>
55-
56-
// <RoomsDetails>
57-
// <SmallText>{guests} goście •</SmallText>
58-
// <SmallText>1 sypialnia •</SmallText>
59-
// <SmallText>{beds} Łóżko •</SmallText>
60-
// <SmallText>1 Łazienka</SmallText>
61-
// </RoomsDetails>
62-
63-
// <RoomsDetails>
64-
// {amenities.map((amenitie, i) => (
65-
// <SmallText key={i}>{amenitie} •</SmallText>
66-
// ))}
67-
// </RoomsDetails>
68-
// </Details>
69-
70-
// <Pricing>
71-
// <Title>{price} zł</Title>
72-
// <VerySmallText>za dzien</VerySmallText>
73-
74-
// <Stars />
75-
// </Pricing>
76-
// </Row>
77-
// </Container>
78-
// </Link>
79-
// )
80-
8134
export class ListingItem extends React.PureComponent<Props> {
8235
public render() {
8336
const {
@@ -93,7 +46,6 @@ export class ListingItem extends React.PureComponent<Props> {
9346
amenities,
9447
setPostion
9548
} = this.props
96-
console.log('RERENDER LISTING ITEM')
9749
return (
9850
<Link to={getRoute(id)} style={{ textDecoration: 'none' }}>
9951
<Container onMouseEnter={() => setPostion(lat, lng)}>

client/src/Pages/Listings/Components/ListingsList/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import * as React from 'react'
22
import { Subscribe } from 'unstated'
33

44
import { SearchListingsQuery } from 'src/Graphql/SearchListings'
5-
import { ListingItem } from './Components/ListingItem'
65
import { Location } from 'src/Containers/Location'
76
import { Filter } from 'src/Containers/Filter'
7+
import { ListingItem } from './Components/ListingItem'
88

99
import { Container } from './style'
1010

0 commit comments

Comments
 (0)