-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves #414
- Loading branch information
Showing
11 changed files
with
152 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import { useLocation as useWindowLocation } from 'react-router-dom'; | ||
import { Link } from 'react-router-dom'; | ||
import type { Location, Review } from '../../types/sparkeats'; | ||
|
||
function LocationAddress({ location }: { location: Location }) { | ||
return ( | ||
<> | ||
<address className="review-overview__address"> | ||
<p>{location?.address}</p> | ||
</address> | ||
{location?.phone && ( | ||
<p> | ||
<a className="review-overview__phone" href={`tel:${location?.phone}`}> | ||
{location?.phone} | ||
</a> | ||
</p> | ||
)} | ||
{location?.url && ( | ||
<p> | ||
<a className="location-card__url" href={`${location?.url}`}> | ||
Visit Site | ||
</a> | ||
</p> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
function LocationOverview({ location }: { location: Location }) { | ||
return ( | ||
<section className="review-overview"> | ||
<header> | ||
<h1 className="review-overview__title"> | ||
{location?.reviews.length !== 1 | ||
? `${location.reviewCount} Reviews` | ||
: `${location.reviewCount} Review`} | ||
</h1> | ||
<div className="review-overview__stars">Average Stars</div> | ||
</header> | ||
<LocationAddress location={location} /> | ||
</section> | ||
); | ||
} | ||
function LocationReviews({ | ||
location, | ||
reviews = [], | ||
}: { | ||
location: Location; | ||
reviews: Review[]; | ||
}) { | ||
return ( | ||
<div className="review-container"> | ||
{/* TODO Only add location if review matches account */} | ||
<Link | ||
className="button__full-width" | ||
to={'/reviews/new'} | ||
state={{ location }} | ||
> | ||
Add a review | ||
</Link> | ||
|
||
{reviews.map((review: Review) => ( | ||
<article key={review.id} className="review-submission"> | ||
<h3 className="review-submission__reviewer">{review.reviewerName}</h3> | ||
<div className="review-submission__date"> | ||
{/* Created year/month/day*/} | ||
</div> | ||
<div | ||
className="location-card__star-rating" | ||
aria-label={`${review.starRating}`} | ||
> | ||
Stars | ||
</div> | ||
<h4 className="review-submission__title">Comments</h4> | ||
<p className="review-submission__review">{review.text}</p> | ||
{/* Refactor to not render a placeholder if there is no review image */} | ||
{/* {review.imageURL && ( | ||
<div className="review-submission__image-container"> | ||
<img | ||
className="review-submission__image" | ||
src={review.imageURL} | ||
alt={review.imageDescription} | ||
/> | ||
</div> | ||
)} */} | ||
</article> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
function LocationHeader({ location }: { location: Location }) { | ||
return ( | ||
<div className="review-header"> | ||
<div className="review-header__title"> | ||
<h2 className="review-header__name">{location.name}</h2> | ||
<p className="review-header__city"> | ||
{location.city}, {location.region} | ||
</p> | ||
</div> | ||
<div className="review-header__backdrop"></div> | ||
</div> | ||
); | ||
} | ||
|
||
type LocationState = { | ||
state: { | ||
location: Location; | ||
}; | ||
}; | ||
|
||
export function LocationPage() { | ||
const { | ||
state: { location }, | ||
} = useWindowLocation() as LocationState; | ||
|
||
return ( | ||
<main className="review-page"> | ||
<div className="review-nav"> | ||
<Link className="review-nav__link" to={'/'}> | ||
<span className="review-nav__svg"></span> | ||
Back to home | ||
</Link> | ||
</div> | ||
<LocationHeader location={location} /> | ||
<LocationReviews location={location} reviews={location.reviews} /> | ||
{/* TODO rename to LocationDetails */} | ||
<LocationOverview location={location} /> | ||
</main> | ||
); | ||
} |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
body { | ||
font-family: $roboto-condensed-stack; | ||
color: $primary-color; | ||
background: url('./img/background-img.png'); | ||
background: url('/img/background-img.png'); | ||
background-blend-mode: darken; | ||
} |
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 |
---|---|---|
|
@@ -4,4 +4,6 @@ declare global { | |
interface Window { | ||
__SPARKEATS_VERSION__: string; | ||
} | ||
|
||
type WindowLocation = Location; | ||
} |
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