Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmman committed Nov 23, 2024
1 parent bef2c3f commit 0de1ed0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/components/reviews/review-form.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { useState } from 'react';
import { store, useAppSelector } from '../../store/store.ts';
import { postReview } from '../../store/actions.ts';
import {
MAX_COMMENT_LENGTH,
MIN_COMMENT_LENGTH,
} from '../../consts/reviews.ts';

type UserReview = {
comment?: string;
Expand Down Expand Up @@ -29,7 +33,10 @@ export function ReviewForm(): React.JSX.Element {
);
};
const isValid =
review?.comment && review?.comment?.length >= 50 && review?.rating;
review?.comment &&
review?.comment?.length >= MIN_COMMENT_LENGTH &&
review?.comment?.length <= MAX_COMMENT_LENGTH &&
review?.rating;
return (
<form className="reviews__form form">
<label className="reviews__label form__label" htmlFor="review">
Expand Down Expand Up @@ -138,7 +145,15 @@ export function ReviewForm(): React.JSX.Element {
<p className="reviews__help">
To submit review please make sure to set{' '}
<span className="reviews__star">rating</span> and describe your stay
with at least <b className="reviews__text-amount">50 characters</b>.
with at least{' '}
<b className="reviews__text-amount">
{MIN_COMMENT_LENGTH} characters
</b>{' '}
and no more than{' '}
<b className="reviews__text-amount">
{MAX_COMMENT_LENGTH} characters
</b>
.
</p>
<button
className="reviews__submit form__submit button"
Expand Down
3 changes: 3 additions & 0 deletions src/consts/reviews.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const MIN_COMMENT_LENGTH = 50;

export const MAX_COMMENT_LENGTH = 300;

0 comments on commit 0de1ed0

Please sign in to comment.