From e2acbce007b6b27759ec62119b83c8da44f0cab4 Mon Sep 17 00:00:00 2001 From: Anastasiya Date: Tue, 8 Oct 2024 16:21:35 +0300 Subject: [PATCH] Fix --- package-lock.json | 10 +++++++ package.json | 1 + src/components/card/card.tsx | 39 +++++++++++--------------- src/components/main/main.tsx | 7 +++-- src/data/cardsData.ts | 9 ++++-- src/{types.ts => lib/types.ts/card.ts} | 5 +++- 6 files changed, 43 insertions(+), 28 deletions(-) rename src/{types.ts => lib/types.ts/card.ts} (70%) diff --git a/package-lock.json b/package-lock.json index 5b5ba40..f755ed6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@reduxjs/toolkit": "1.9.5", "axios": "0.27.2", "classnames": "2.3.2", + "clsx": "^2.1.1", "history": "5.3.0", "http-status-codes": "2.2.0", "leaflet": "1.7.1", @@ -2372,6 +2373,15 @@ "node": ">=0.8.0" } }, + "node_modules/clsx": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", + "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", diff --git a/package.json b/package.json index 636c8a3..743e34e 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@reduxjs/toolkit": "1.9.5", "axios": "0.27.2", "classnames": "2.3.2", + "clsx": "^2.1.1", "history": "5.3.0", "http-status-codes": "2.2.0", "leaflet": "1.7.1", diff --git a/src/components/card/card.tsx b/src/components/card/card.tsx index 0efdd0f..5246e56 100644 --- a/src/components/card/card.tsx +++ b/src/components/card/card.tsx @@ -1,24 +1,17 @@ -/* eslint-disable arrow-body-style */ +import { SingleCard } from '../../lib/types.ts/card'; +import clsx from 'clsx'; -type Props = { - isPremium: boolean; - imgPath: string; - price: number; - inBookmarks: boolean; - rating: 1 | 2 | 3 | 4 | 5; - placeName: string; - placeType: string; -}; +const Card = (card: SingleCard) => { + const { + isPremium, + imgPath, + price, + inBookmarks, + rating, + placeName, + placeType, + } = card; -const Card = ({ - isPremium, - imgPath, - price, - inBookmarks, - rating, - placeName, - placeType, -}: Props) => { return (
{isPremium ? ( @@ -46,9 +39,11 @@ const Card = ({ / night