Skip to content

Commit

Permalink
Added Van Info Page
Browse files Browse the repository at this point in the history
  • Loading branch information
Adi-204 committed Dec 16, 2023
1 parent 1945980 commit 797d7bc
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 11 deletions.
11 changes: 10 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { Income } from './pages/host/Income';
import { Review } from './pages/host/Review';
import { HostVans } from './pages/host/HostVans';
import { HostVanDetail } from './pages/host/HostVanDetail';
import { HostVanInfo } from './pages/host/HostVanInfo';
import { HostVanPrice } from './pages/host/HostVanPrice';
import { HostVanPhoto } from './pages/host/HostVanPhoto';

export const App =()=>{
return(
Expand All @@ -28,7 +31,13 @@ export const App =()=>{
<Route path='income' element = {<Income />} />
<Route path='reviews' element = {<Review />} />
<Route path='vans' element={<HostVans />} />
<Route path='vans/:id' element={<HostVanDetail />} />

<Route path='vans/:id' element={<HostVanDetail />} >
<Route index element = {<HostVanInfo />} />
<Route path='pricing' element = {<HostVanPrice />} />
<Route path='photos' element = {<HostVanPhoto />} />
</Route>

</Route>

</Route>
Expand Down
8 changes: 4 additions & 4 deletions src/components/HostLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ export const HostLayout = ()=>{
<>
<nav className="host-nav">
<NavLink
to="/host"
to="."
end
style={({isActive}) => isActive ? styles : null}
>
Dashboard
</NavLink>
<NavLink
to="/host/income"
to="income"
style={({isActive}) => isActive ? styles : null}
>
Income
</NavLink>
<NavLink
to="/host/vans"
to="vans"
style={({isActive}) => isActive ? styles : null}
>
Vans
</NavLink>
<NavLink
to="/host/reviews"
to="reviews"
style={({isActive}) => isActive ? styles : null}
>
Reviews
Expand Down
4 changes: 3 additions & 1 deletion src/components/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export const Layout = ()=>{
return (
<>
<Header />
<Outlet />
<main>
<Outlet />
</main>
<Footer />
</>
)
Expand Down
128 changes: 127 additions & 1 deletion src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
html,body{
background-color: #FFF7ED;
font-family: "Inter", sans-serif;
display: flex;
flex-direction: column;
}
header {
display: flex;
Expand Down Expand Up @@ -350,7 +352,7 @@ i[class*='van-type-'] {
}

/* Footer CSS */
footer {
/* footer {
background-color: #161616;
color: #AAAAAA;
height: 74px;
Expand All @@ -360,6 +362,15 @@ footer {
align-items: center;
margin-top: auto;
font-weight: 500;
} */
footer {
background-color: #161616;
color: #AAAAAA;
height: 74px;
display: flex;
justify-content: center;
align-items: center;
font-weight: 500;
}

/* Host Van Page */
Expand Down Expand Up @@ -421,6 +432,111 @@ footer {
margin-block: 10px;
}

/* Host Van Details Page */


.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;
}

.link-button:hover {
transform: translate(1px, 1px);
}

.host-van-detail-nav {
display: flex;
margin-block: 25px;
}

.host-van-detail-nav a {
text-decoration: none;
color: #4D4D4D;
font-weight: 500;
padding: 5px 20px;
}

.host-van-detail-nav a:first-of-type {
text-decoration: none;
color: #4D4D4D;
font-weight: 500;
padding: 5px 15px;
}

.host-van-detail-nav a:hover {
color: #161616;
text-decoration: underline;
font-weight: 700;
}

.host-van-detail-info > h4 {
font-weight: 700;
font-size: 14px;
line-height: 21px;
}
.host-van-detail-info > h4 > span {
font-weight: 500;
}

.host-van-price {
font-size: 24px;
font-weight: 500;
margin-left: 14px;
}

.host-van-price > span {
font-size: 16px;
color: #4D4D4D;
}

.host-van-detail-image {
height: 110px;
border-radius: 5px;
margin-left: 14px;
}

section.host-van-detail-info {
margin-left: 14px;
}

/* Responsive CSS */

@media screen and (max-width: 760px) {
.menu-toggle {
display: block;
Expand Down Expand Up @@ -539,5 +655,15 @@ footer {
border-radius: 5px;
margin-right: 17px;
}
.host-van-detail > img {
height: 100px;
}

.host-van-detail-info-text > h3 {
font-size: 22px;
}
.host-van-detail-info-text > h4 {
font-size: 17px;
}
}

68 changes: 65 additions & 3 deletions src/pages/host/HostVanDetail.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,71 @@
import React from "react";
import React, { useEffect, useState } from "react";
import { ReactDOM } from "react";
import { useParams,Link, Outlet, NavLink } from "react-router-dom";


export const HostVanDetail = ()=>{
return(
<h1>HostVanDetail here</h1>
const [currentVan, setCurrentVan] = React.useState(null)
const params = useParams();

useEffect(()=>{
fetch(`/api/host/vans/${params.id}`)
.then(res => res.json())
.then(data => setCurrentVan(data.vans))
},[params.id])

if (!currentVan) {
return <h1>Loading...</h1>
}
const activeStyles = {
fontWeight: "bold",
textDecoration: "underline",
color: "#161616"
}

return (
<section>
<Link
to=".."
relative="path"
className="back-button"
>&larr; <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>
<nav className="host-van-detail-nav">
<NavLink
to="."
end
style={({ isActive }) => isActive ? activeStyles : null}
>
Details
</NavLink>
<NavLink
to='pricing'
style={({ isActive }) => isActive ? activeStyles : null}
>
Pricing
</NavLink>
<NavLink
to='photos'
style={({ isActive }) => isActive ? activeStyles : null}
>
Photos
</NavLink>
</nav>
<Outlet context={[currentVan, setCurrentVan]} />
</section>
)
}
16 changes: 16 additions & 0 deletions src/pages/host/HostVanInfo.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import { ReactDOM } from "react";
import { useOutletContext } from "react-router-dom";


export const HostVanInfo = ()=>{
const [currentVan, setCurrentVan] = useOutletContext();
return (
<section className="host-van-detail-info">
<h4>Name: <span>{currentVan.name}</span></h4>
<h4>Category: <span>{currentVan.type}</span></h4>
<h4>Description: <span>{currentVan.description}</span></h4>
<h4>Visibility: <span>Public</span></h4>
</section>
)
}
11 changes: 11 additions & 0 deletions src/pages/host/HostVanPhoto.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";
import { ReactDOM } from "react";
import { useOutletContext } from "react-router-dom";


export const HostVanPhoto = ()=>{
const [currentVan, setCurrentVan] = useOutletContext();
return (
<img src={currentVan.imageUrl} className="host-van-detail-image" />
)
}
10 changes: 10 additions & 0 deletions src/pages/host/HostVanPrice.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react";
import { ReactDOM } from "react";
import { useOutletContext } from "react-router-dom";

export const HostVanPrice = ()=>{
const [currentVan, setCurrentVan] = useOutletContext();
return (
<h3 className="host-van-price">${currentVan.price}<span>/day</span></h3>
)
}
2 changes: 1 addition & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ createServer({
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" })
return schema.vans.findBy({ id, hostId: "123" })
})
}
})

0 comments on commit 797d7bc

Please sign in to comment.