-
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
22 changed files
with
291 additions
and
68 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
File renamed without changes.
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,32 @@ | ||
/// <reference types="cypress" /> | ||
|
||
export {}; | ||
|
||
context('Given a user is on the Location page', () => { | ||
const baseUrl = Cypress.config('baseUrl'); | ||
context('When the user clicks the "Back to home" link', () => { | ||
specify('Then the user is directed to the Home page', () => { | ||
cy.visit('/'); | ||
cy.findByRole('heading', { | ||
name: /Basil's on Market/, | ||
}).click(); | ||
cy.findByRole('link', { | ||
name: /Back to home/, | ||
}).click(); | ||
cy.url().should('eq', baseUrl); | ||
}); | ||
}); | ||
|
||
context('When the user clicks the "Add a review" link', () => { | ||
specify('Then the user is directed to the Home page', () => { | ||
cy.visit('/'); | ||
cy.findByRole('heading', { | ||
name: /Basil's on Market/, | ||
}).click(); | ||
cy.findByRole('link', { | ||
name: /Add a review/, | ||
}).click(); | ||
cy.url().should('eq', `${baseUrl}reviews/new`); | ||
}); | ||
}); | ||
}); |
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
6 changes: 3 additions & 3 deletions
6
src/components/home/LocationCards.tsx → src/components/HomePage/LocationCards.tsx
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Location } from '../../types/sparkeats'; | ||
|
||
function LocationAddress({ location }: { location: Location }) { | ||
return ( | ||
<> | ||
<address className="review-details__address"> | ||
<p>{location?.address}</p> | ||
</address> | ||
{location?.phone && ( | ||
<p> | ||
<a className="review-details__phone" href={`tel:${location?.phone}`}> | ||
{location?.phone} | ||
</a> | ||
</p> | ||
)} | ||
{location?.url && ( | ||
<p> | ||
<a className="location-card__url" href={`${location?.url}`}> | ||
Visit Site | ||
</a> | ||
</p> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
export function LocationDetails({ location }: { location: Location }) { | ||
return ( | ||
<section className="review-details"> | ||
<header> | ||
<h1 className="review-details__title">{location.reviewCountText}</h1> | ||
<div className="review-details__stars">Average Stars</div> | ||
</header> | ||
<LocationAddress location={location} /> | ||
</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,15 @@ | ||
import { Location } from '../../types/sparkeats'; | ||
|
||
export 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> | ||
); | ||
} |
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,48 @@ | ||
import { Link } from 'react-router-dom'; | ||
import { Location, Review } from '../../types/sparkeats'; | ||
|
||
export function LocationReviews({ | ||
location, | ||
reviews = [], | ||
}: { | ||
location: Location; | ||
reviews: Review[]; | ||
}) { | ||
return ( | ||
<div className="review-container"> | ||
<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> | ||
{review.imageURL && ( | ||
<div className="review-submission__image-container"> | ||
<img | ||
className="review-submission__image" | ||
src={review.imageURL} | ||
alt={review.imageDescription} | ||
/> | ||
</div> | ||
)} | ||
</article> | ||
))} | ||
</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,30 @@ | ||
import { useLocation as useWindowLocation } from 'react-router-dom'; | ||
import { Link } from 'react-router-dom'; | ||
import { LocationHeader } from './LocationHeader'; | ||
import { LocationDetails } from './LocationDetails'; | ||
import { LocationReviews } from './LocationReviews'; | ||
import { useLocations } from '../../useLocations'; | ||
|
||
export function LocationPage() { | ||
const { | ||
state: { id }, | ||
} = useWindowLocation(); | ||
|
||
const { locations } = useLocations(); | ||
|
||
const location = locations[id]; | ||
|
||
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} /> | ||
<LocationDetails location={location} /> | ||
</main> | ||
); | ||
} |
Oops, something went wrong.