From 4c03d8b69d23c0a26855c21f320fc73ef1ddea07 Mon Sep 17 00:00:00 2001 From: Gurikov Maxim Date: Wed, 11 Dec 2024 20:55:55 +0500 Subject: [PATCH] more fixes --- src/Pages/login-page/login-page.tsx | 6 ++---- src/components/offer/offer-card.tsx | 2 +- src/components/reviews/review-component.tsx | 3 ++- src/components/reviews/review-form.tsx | 3 ++- src/consts/cities.ts | 2 +- src/utils/date-utils.ts | 22 +++++++++++++++++++++ 6 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 src/utils/date-utils.ts diff --git a/src/Pages/login-page/login-page.tsx b/src/Pages/login-page/login-page.tsx index 7482064..26a5633 100644 --- a/src/Pages/login-page/login-page.tsx +++ b/src/Pages/login-page/login-page.tsx @@ -46,8 +46,7 @@ export function LoginPage(): React.JSX.Element { name="email" placeholder="Email" onChange={(event) => - setLoginInfo({ ...loginInfo, email: event.target.value }) - } + setLoginInfo({ ...loginInfo, email: event.target.value })} required /> @@ -62,8 +61,7 @@ export function LoginPage(): React.JSX.Element { setLoginInfo({ ...loginInfo, password: event.target.value, - }) - } + })} required /> diff --git a/src/components/offer/offer-card.tsx b/src/components/offer/offer-card.tsx index 71c150c..5950e6b 100644 --- a/src/components/offer/offer-card.tsx +++ b/src/components/offer/offer-card.tsx @@ -38,7 +38,7 @@ export function OfferCardImpl({ onMouseLeave={handleMouseLeave} className={cn( 'place-card', - { cities__card: isOnMainPage }, + { 'cities__card': isOnMainPage }, { 'near-places__card': !isOnMainPage }, )} > diff --git a/src/components/reviews/review-component.tsx b/src/components/reviews/review-component.tsx index 1e72ef5..32d3263 100644 --- a/src/components/reviews/review-component.tsx +++ b/src/components/reviews/review-component.tsx @@ -1,5 +1,6 @@ import { getFirstName } from '../../utils/username-utils.ts'; import { Rating } from '../rating.tsx'; +import { formatDate } from '../../utils/date-utils.ts'; interface ReviewProps { comment: string; @@ -34,7 +35,7 @@ export function ReviewComponent({

{comment}

diff --git a/src/components/reviews/review-form.tsx b/src/components/reviews/review-form.tsx index 4c2df7b..a527aca 100644 --- a/src/components/reviews/review-form.tsx +++ b/src/components/reviews/review-form.tsx @@ -170,7 +170,8 @@ export function ReviewForm(): React.JSX.Element { value={review?.comment || ''} onChange={onCommentChange} disabled={reviewPostingStatus === ReviewStatus.Pending} - > + > +

To submit review please make sure to set{' '} diff --git a/src/consts/cities.ts b/src/consts/cities.ts index dfee7ec..f28474b 100644 --- a/src/consts/cities.ts +++ b/src/consts/cities.ts @@ -61,4 +61,4 @@ export const CITIES: City[] = [ AMSTERDAM, HAMBURG, DUSSELDORF, -]; +] as const; diff --git a/src/utils/date-utils.ts b/src/utils/date-utils.ts new file mode 100644 index 0000000..5ab91a0 --- /dev/null +++ b/src/utils/date-utils.ts @@ -0,0 +1,22 @@ +export function formatDate(dateString: Date): string { + const monthsInEnglish = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December', + ]; + + const date = new Date(dateString); + const month = monthsInEnglish[date.getMonth()]; + const year = date.getFullYear(); + + return `${month} ${year}`; +}