-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from ivanbatchev/dev
dev: add vans list with details page nested
- Loading branch information
Showing
35 changed files
with
429 additions
and
58 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,30 +1,101 @@ | ||
import { createServer, Model } from "miragejs" | ||
|
||
import { createServer, Model } from 'miragejs' | ||
|
||
createServer({ | ||
models: { | ||
vans: Model, | ||
vans: Model | ||
}, | ||
|
||
seeds(server) { | ||
server.create("van", { id: "1", name: "Modest Explorer", price: 60, description: "The Modest Explorer is a van designed to get you out of the house and into nature. This beauty is equipped with solar panels, a composting toilet, a water tank and kitchenette. The idea is that you can pack up your home and escape for a weekend or even longer!", imageUrl: "https://assets.scrimba.com/advanced-react/react-router/modest-explorer.png", type: "simple" }) | ||
server.create("van", { id: "2", name: "Beach Bum", price: 80, description: "Beach Bum is a van inspired by surfers and travelers. It was created to be a portable home away from home, but with some cool features in it you won't find in an ordinary camper.", imageUrl: "https://assets.scrimba.com/advanced-react/react-router/beach-bum.png", type: "rugged" }) | ||
server.create("van", { id: "3", name: "Reliable Red", price: 100, description: "Reliable Red is a van that was made for travelling. The inside is comfortable and cozy, with plenty of space to stretch out in. There's a small kitchen, so you can cook if you need to. You'll feel like home as soon as you step out of it.", imageUrl: "https://assets.scrimba.com/advanced-react/react-router/reliable-red.png", type: "luxury" }) | ||
server.create("van", { id: "4", name: "Dreamfinder", price: 65, description: "Dreamfinder is the perfect van to travel in and experience. With a ceiling height of 2.1m, you can stand up in this van and there is great head room. The floor is a beautiful glass-reinforced plastic (GRP) which is easy to clean and very hard wearing. A large rear window and large side windows make it really light inside and keep it well ventilated.", imageUrl: "https://assets.scrimba.com/advanced-react/react-router/dreamfinder.png", type: "simple" }) | ||
server.create("van", { id: "5", name: "The Cruiser", price: 120, description: "The Cruiser is a van for those who love to travel in comfort and luxury. With its many windows, spacious interior and ample storage space, the Cruiser offers a beautiful view wherever you go.", imageUrl: "https://assets.scrimba.com/advanced-react/react-router/the-cruiser.png", type: "luxury" }) | ||
server.create("van", { id: "6", name: "Green Wonder", price: 70, description: "With this van, you can take your travel life to the next level. The Green Wonder is a sustainable vehicle that's perfect for people who are looking for a stylish, eco-friendly mode of transport that can go anywhere.", imageUrl: "https://assets.scrimba.com/advanced-react/react-router/green-wonder.png", type: "rugged" }) | ||
server.create('van', { | ||
id: '1', | ||
name: 'Modest Explorer', | ||
price: 60, | ||
description: | ||
'The Modest Explorer is a van designed to get you out of the house and into nature. This beauty is equipped with solar panels, a composting toilet, a water tank and kitchenette. The idea is that you can pack up your home and escape for a weekend or even longer!', | ||
imageUrl: | ||
'https://assets.scrimba.com/advanced-react/react-router/modest-explorer.png', | ||
type: 'simple', | ||
hostId: '123' | ||
}) | ||
server.create('van', { | ||
id: '2', | ||
name: 'Beach Bum', | ||
price: 80, | ||
description: | ||
"Beach Bum is a van inspired by surfers and travelers. It was created to be a portable home away from home, but with some cool features in it you won't find in an ordinary camper.", | ||
imageUrl: | ||
'https://assets.scrimba.com/advanced-react/react-router/beach-bum.png', | ||
type: 'rugged', | ||
hostId: '123' | ||
}) | ||
server.create('van', { | ||
id: '3', | ||
name: 'Reliable Red', | ||
price: 100, | ||
description: | ||
"Reliable Red is a van that was made for travelling. The inside is comfortable and cozy, with plenty of space to stretch out in. There's a small kitchen, so you can cook if you need to. You'll feel like home as soon as you step out of it.", | ||
imageUrl: | ||
'https://assets.scrimba.com/advanced-react/react-router/reliable-red.png', | ||
type: 'luxury', | ||
hostId: '456' | ||
}) | ||
server.create('van', { | ||
id: '4', | ||
name: 'Dreamfinder', | ||
price: 65, | ||
description: | ||
'Dreamfinder is the perfect van to travel in and experience. With a ceiling height of 2.1m, you can stand up in this van and there is great head room. The floor is a beautiful glass-reinforced plastic (GRP) which is easy to clean and very hard wearing. A large rear window and large side windows make it really light inside and keep it well ventilated.', | ||
imageUrl: | ||
'https://assets.scrimba.com/advanced-react/react-router/dreamfinder.png', | ||
type: 'simple', | ||
hostId: '789' | ||
}) | ||
server.create('van', { | ||
id: '5', | ||
name: 'The Cruiser', | ||
price: 120, | ||
description: | ||
'The Cruiser is a van for those who love to travel in comfort and luxury. With its many windows, spacious interior and ample storage space, the Cruiser offers a beautiful view wherever you go.', | ||
imageUrl: | ||
'https://assets.scrimba.com/advanced-react/react-router/the-cruiser.png', | ||
type: 'luxury', | ||
hostId: '789' | ||
}) | ||
server.create('van', { | ||
id: '6', | ||
name: 'Green Wonder', | ||
price: 70, | ||
description: | ||
"With this van, you can take your travel life to the next level. The Green Wonder is a sustainable vehicle that's perfect for people who are looking for a stylish, eco-friendly mode of transport that can go anywhere.", | ||
imageUrl: | ||
'https://assets.scrimba.com/advanced-react/react-router/green-wonder.png', | ||
type: 'rugged', | ||
hostId: '123' | ||
}) | ||
}, | ||
|
||
routes() { | ||
this.namespace = "api" | ||
this.namespace = 'api' | ||
this.logging = false | ||
|
||
this.get("/vans", (schema, request) => { | ||
this.get('/vans', (schema) => { | ||
return schema.vans.all() | ||
}) | ||
|
||
this.get("/vans/:id", (schema, request) => { | ||
this.get('/vans/:id', (schema, request) => { | ||
const id = request.params.id | ||
return schema.vans.find(id) | ||
}) | ||
|
||
this.get('/host/vans', (schema) => { | ||
// Hard-code the hostId for now | ||
return schema.vans.where({ hostId: '123' }) | ||
}) | ||
|
||
this.get('/host/vans/:id', (schema, request) => { | ||
// Hard-code the hostId for now | ||
const id = request.params.id | ||
return schema.vans.where({ id, hostId: '123' }) | ||
}) | ||
} | ||
}) | ||
}) |
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,5 +1,3 @@ | ||
import { Outlet } from 'react-router-dom' | ||
|
||
export const Dashboard = () => { | ||
return ( | ||
<> | ||
|
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,3 @@ | ||
export const HostVanInfo = () => { | ||
return <div>HostVanInfo</div> | ||
} |
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 @@ | ||
export { HostVanInfo as default } from './HostVanInfo' |
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,3 @@ | ||
export const HostVanPhoto = () => { | ||
return <div>HostVanPhoto</div> | ||
} |
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 @@ | ||
export { HostVanPhoto as default } from './HostVanPhoto' |
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,3 @@ | ||
export const HostVanPricing = () => { | ||
return <div>HostVanPricing</div> | ||
} |
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 @@ | ||
export { HostVanPricing as default } from './HostVanPricing' |
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,37 @@ | ||
import { Link } from 'react-router-dom' | ||
import { Loader } from '../../../shared/components' | ||
import { useVans } from '../../../shared/lib/hooks' | ||
import './styles.css' | ||
|
||
export const HostVans = () => { | ||
const { loading, data: vans } = useVans('', true) | ||
|
||
if (loading) { | ||
return <Loader /> | ||
} | ||
|
||
const hostVansEls = vans.map((van) => ( | ||
<Link | ||
to={`/host/vans/${van.id}`} | ||
key={van.id} | ||
className="host-van-link-wrapper" | ||
> | ||
<div className="host-van-single" key={van.id}> | ||
<img src={van.imageUrl} alt={`Photo of ${van.name}`} /> | ||
<div className="host-van-info"> | ||
<h3>{van.name}</h3> | ||
<p>${van.price}/day</p> | ||
</div> | ||
</div> | ||
</Link> | ||
)) | ||
|
||
return ( | ||
<section> | ||
<h1 className="host-vans-title">Your listed vans</h1> | ||
<div className="host-vans-list"> | ||
<section>{hostVansEls}</section> | ||
</div> | ||
</section> | ||
) | ||
} |
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 @@ | ||
export { HostVans as default } from './HostVans' |
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,37 @@ | ||
.host-van-link-wrapper { | ||
color: unset; | ||
text-decoration: unset; | ||
} | ||
|
||
.host-vans-list { | ||
padding-inline: 26px; | ||
} | ||
|
||
.host-vans-title { | ||
padding-inline: 26px; | ||
} | ||
|
||
.host-van-single { | ||
display: flex; | ||
align-items: center; | ||
background-color: white; | ||
margin-bottom: 15px; | ||
padding-block: 18px; | ||
padding-left: 24px; | ||
} | ||
|
||
.host-van-single > img { | ||
height: 70px; | ||
border-radius: 5px; | ||
margin-right: 17px; | ||
} | ||
|
||
.host-van-info h3 { | ||
font-size: 20px; | ||
font-weight: 600; | ||
margin-block: 10px; | ||
} | ||
|
||
.host-van-info p { | ||
margin-block: 10px; | ||
} |
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,34 @@ | ||
import { Link, useParams } from 'react-router-dom' | ||
import { Loader } from '../../../shared/components' | ||
import { useVans } from '../../../shared/lib/hooks' | ||
import './styles.css' | ||
|
||
export const HostVansDetails = () => { | ||
const { id } = useParams() | ||
const { loading, data: currentVan } = useVans(id, true) | ||
|
||
if (loading) { | ||
return <Loader /> | ||
} | ||
|
||
return ( | ||
<section> | ||
<Link to=".." className="back-button"> | ||
← <span>Back to all vans</span> | ||
</Link> | ||
|
||
<div className="host-van-detail-layout-container"> | ||
<div className="host-van-detail"> | ||
<img src={currentVan.imageUrl} /> | ||
<div className="host-van-detail-info-text"> | ||
<i className={`van-type van-type-${currentVan.type}`}> | ||
{currentVan.type} | ||
</i> | ||
<h3>{currentVan.name}</h3> | ||
<h4>${currentVan.price}/day</h4> | ||
</div> | ||
</div> | ||
</div> | ||
</section> | ||
) | ||
} |
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 @@ | ||
export { HostVansDetails as default } from './HostVansDetails' |
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,40 @@ | ||
.host-van-detail-layout-container { | ||
background-color: white; | ||
padding: 24px; | ||
margin: 30px 26px; | ||
} | ||
|
||
.host-van-detail { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.host-van-detail > img { | ||
height: 160px; | ||
border-radius: 5px; | ||
margin-right: 20px; | ||
} | ||
|
||
.host-van-detail-info-text > h3 { | ||
margin-top: 24px; | ||
margin-bottom: 5px; | ||
font-size: 26px; | ||
font-weight: 700; | ||
} | ||
|
||
.host-van-detail-info-text > h4 { | ||
font-size: 20px; | ||
margin-block: 0; | ||
} | ||
|
||
.back-button { | ||
display: block; | ||
color: black; | ||
text-decoration: none; | ||
margin-top: 60px; | ||
margin-left: 26px; | ||
} | ||
|
||
.back-button span:hover { | ||
text-decoration: underline; | ||
} |
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,5 +1,19 @@ | ||
import Reviews from './Reviews' | ||
import Dashboard from './Dashboard' | ||
import Income from './Income' | ||
import HostVans from './HostVans' | ||
import HostVansDetails from './HostVansDetails' | ||
import HostVanInfo from './HostVanInfo' | ||
import HostVanPhoto from './HostVanPhoto' | ||
import HostVanPricing from './HostVanPricing' | ||
|
||
export { Reviews, Dashboard, Income } | ||
export { | ||
Reviews, | ||
Dashboard, | ||
Income, | ||
HostVans, | ||
HostVansDetails, | ||
HostVanInfo, | ||
HostVanPhoto, | ||
HostVanPricing | ||
} |
Oops, something went wrong.