From 2c68c6ac41cd1862b78500dbfa33740eb27a85be Mon Sep 17 00:00:00 2001 From: Gurikov Maxim Date: Sat, 23 Nov 2024 20:32:55 +0500 Subject: [PATCH] fixes --- src/Pages/main-page/main-page.tsx | 2 +- src/components/offer/offer-card.tsx | 3 ++- src/components/offer/offer-gallery.tsx | 2 +- src/components/offer/offer-host.tsx | 14 ++++++++++++-- src/components/rating.tsx | 2 +- src/components/reviews/reviews.tsx | 5 ++++- src/dataTypes/enums/room-type.ts | 2 ++ 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Pages/main-page/main-page.tsx b/src/Pages/main-page/main-page.tsx index a78219c..e3227a1 100644 --- a/src/Pages/main-page/main-page.tsx +++ b/src/Pages/main-page/main-page.tsx @@ -24,7 +24,7 @@ export function MainPage(): React.JSX.Element { : `${pluralizeAndCombine('place', offers.length)} to stay in ${city.name}`; return (
- +
6 cities

Cities

diff --git a/src/components/offer/offer-card.tsx b/src/components/offer/offer-card.tsx index 2fa3889..13184bf 100644 --- a/src/components/offer/offer-card.tsx +++ b/src/components/offer/offer-card.tsx @@ -4,6 +4,7 @@ import { AppRoutes } from '../../dataTypes/enums/app-routes.ts'; import cn from 'classnames'; import { Rating } from '../rating.tsx'; import { BookmarkButton } from '../bookmark-button.tsx'; +import { capitalize } from '../../utils/string-utils.ts'; interface PlaceCardProps { id: string; @@ -82,7 +83,7 @@ export function OfferCard({

{title}

-

{type}

+

{capitalize(type)}

); diff --git a/src/components/offer/offer-gallery.tsx b/src/components/offer/offer-gallery.tsx index a1047be..291b84b 100644 --- a/src/components/offer/offer-gallery.tsx +++ b/src/components/offer/offer-gallery.tsx @@ -10,7 +10,7 @@ export function OfferGallery({ return (
- {imageSources.map((src) => ( + {imageSources.slice(0, 6).map((src) => (
Photo studio
diff --git a/src/components/offer/offer-host.tsx b/src/components/offer/offer-host.tsx index e4c288b..18b0e14 100644 --- a/src/components/offer/offer-host.tsx +++ b/src/components/offer/offer-host.tsx @@ -11,7 +11,17 @@ export function OfferHost({ host }: OfferHostProps): React.JSX.Element { <>

Meet the host

-
+ {host.isPro ? ( +
+ Host avatar +
+ ) : ( Host avatar -
+ )} {getFirstName(host.name)} {host.isPro && Pro}
diff --git a/src/components/rating.tsx b/src/components/rating.tsx index 7db3415..c4c888e 100644 --- a/src/components/rating.tsx +++ b/src/components/rating.tsx @@ -14,7 +14,7 @@ export function Rating({ return (
- + Rating
{isInOffer && ( diff --git a/src/components/reviews/reviews.tsx b/src/components/reviews/reviews.tsx index 3959b45..654da16 100644 --- a/src/components/reviews/reviews.tsx +++ b/src/components/reviews/reviews.tsx @@ -9,6 +9,9 @@ interface ReviewsProps { } export function Reviews({ reviews }: ReviewsProps): React.JSX.Element { + const sortedReviews = reviews + .toSorted((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()) + .slice(0, 10); const isAuthorized = useAppSelector((state) => state.authorizationStatus) === AuthorizationStatus.Authorized; @@ -16,7 +19,7 @@ export function Reviews({ reviews }: ReviewsProps): React.JSX.Element { return (
{reviewsAvailable ? ( - + ) : (