Skip to content

Commit

Permalink
change offer stucture
Browse files Browse the repository at this point in the history
  • Loading branch information
hanimohammad committed Nov 16, 2024
1 parent 9385cf0 commit f0060ab
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 132 deletions.
18 changes: 15 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@ type Offer = {
rating: number;
type: string;
isPremium: boolean;
previewImage: string;
isFavorite: boolean;
NumberOfPlaces: number;
latitude: number;
longitude:number;
previewImage: string;
city: {
name: string;
location: {
latitude: number;
longitude: number;
zoom: number;
};
};
location: {
latitude: number;
longitude: number;
zoom: number;
};
};

type AppProps = {
Expand Down
16 changes: 15 additions & 1 deletion src/components/Favorites/Favorite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,22 @@ type Offer = {
rating: number;
type: string;
isPremium: boolean;
previewImage: string;
isFavorite: boolean;
NumberOfPlaces: number;
previewImage: string;
city: {
name: string;
location: {
latitude: number;
longitude: number;
zoom: number;
};
};
location: {
latitude: number;
longitude: number;
zoom: number;
};
};
type FavoriteProps = {
offers: Offer[];
Expand Down
18 changes: 15 additions & 3 deletions src/components/MainPage/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@ type Offer = {
rating: number;
type: string;
isPremium: boolean;
previewImage: string;
isFavorite: boolean;
NumberOfPlaces: number;
latitude: number;
longitude:number;
previewImage: string;
city: {
name: string;
location: {
latitude: number;
longitude: number;
zoom: number;
};
};
location: {
latitude: number;
longitude: number;
zoom: number;
};
};
type MainPageProps = {
offers: Offer[];
Expand Down
22 changes: 17 additions & 5 deletions src/components/Map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,22 @@ type Offer = {
rating: number;
type: string;
isPremium: boolean;
previewImage: string;
isFavorite: boolean;
NumberOfPlaces: number;
latitude: number;
longitude:number;
previewImage: string;
city: {
name: string;
location: {
latitude: number;
longitude: number;
zoom: number;
};
};
location: {
latitude: number;
longitude: number;
zoom: number;
};
};
const defaultCustomIcon = new Icon({
iconUrl: 'https://assets.htmlacademy.ru/content/intensive/javascript-1/demo/interactive-map/pin.svg',
Expand Down Expand Up @@ -41,8 +53,8 @@ function Map(props: MainPageProps): JSX.Element {
const markerLayer = layerGroup().addTo(map);
offers.forEach((offer) => {
const marker = new Marker({
lat: offer.latitude,
lng: offer.longitude
lat: offer.location.latitude,
lng: offer.location.longitude
});
marker
.setIcon(
Expand Down
111 changes: 1 addition & 110 deletions src/components/Offer/Offer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,116 +207,7 @@ export default function Offer () {
</li>
</ul>
<form className="reviews__form form" action="#" method="post">
<label className="reviews__label form__label" htmlFor="review">
Your review
</label>
<div className="reviews__rating-form form__rating">
<input
className="form__rating-input visually-hidden"
name="rating"
value="5"
id="5-stars"
type="radio"
/>
<label
htmlFor="5-stars"
className="reviews__rating-label form__rating-label"
title="perfect"
>
<svg className="form__star-image" width="37" height="33">
<use xlinkHref="#icon-star"></use>
</svg>
</label>

<input
className="form__rating-input visually-hidden"
name="rating"
value="4"
id="4-stars"
type="radio"
/>
<label
htmlFor="4-stars"
className="reviews__rating-label form__rating-label"
title="good"
>
<svg className="form__star-image" width="37" height="33">
<use xlinkHref="#icon-star"></use>
</svg>
</label>

<input
className="form__rating-input visually-hidden"
name="rating"
value="3"
id="3-stars"
type="radio"
/>
<label
htmlFor="3-stars"
className="reviews__rating-label form__rating-label"
title="not bad"
>
<svg className="form__star-image" width="37" height="33">
<use xlinkHref="#icon-star"></use>
</svg>
</label>

<input
className="form__rating-input visually-hidden"
name="rating"
value="2"
id="2-stars"
type="radio"
/>
<label
htmlFor="2-stars"
className="reviews__rating-label form__rating-label"
title="badly"
>
<svg className="form__star-image" width="37" height="33">
<use xlinkHref="#icon-star"></use>
</svg>
</label>

<input
className="form__rating-input visually-hidden"
name="rating"
value="1"
id="1-star"
type="radio"
/>
<label
htmlFor="1-star"
className="reviews__rating-label form__rating-label"
title="terribly"
>
<svg className="form__star-image" width="37" height="33">
<use xlinkHref="#icon-star"></use>
</svg>
</label>
</div>
<textarea
className="reviews__textarea form__textarea"
id="review"
name="review"
placeholder="Tell how was your stay, what you like and what can be improved"
/>
<div className="reviews__button-wrapper">
<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>.
</p>
<button
className="reviews__submit form__submit button"
type="submit"
disabled
>
Submit
</button>
</div>
<SendCommentForm /> {}
</form>
</section>
</div>
Expand Down
16 changes: 15 additions & 1 deletion src/components/Offer/OfferCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,22 @@ type Offer = {
rating: number;
type: string;
isPremium: boolean;
previewImage: string;
isFavorite: boolean;
NumberOfPlaces: number;
previewImage: string;
city: {
name: string;
location: {
latitude: number;
longitude: number;
zoom: number;
};
};
location: {
latitude: number;
longitude: number;
zoom: number;
};
};

type OfferCardProps = {
Expand Down
16 changes: 15 additions & 1 deletion src/components/Offer/OfferList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,22 @@ type Offer = {
rating: number;
type: string;
isPremium: boolean;
previewImage: string;
isFavorite: boolean;
NumberOfPlaces: number;
previewImage: string;
city: {
name: string;
location: {
latitude: number;
longitude: number;
zoom: number;
};
};
location: {
latitude: number;
longitude: number;
zoom: number;
};
};

type OfferListProps = {
Expand Down
64 changes: 56 additions & 8 deletions src/mock/offers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ export const offers = [
isPremium: true,
previewImage: 'img/apartment-01.jpg',
NumberOfPlaces: 1,
latitude: 52.3909553943508,
longitude: 4.85309666406198,
location: {
latitude: 52.3909553943508,
longitude: 4.85309666406198,
zoom: 0,
},
city: {
name: 'Amsterdam',
location: {
latitude: 52.35514938496378,
longitude: 4.673877537499948,
zoom: 8,
},
},
isFavorite: false,
},
{
id: 2,
Expand All @@ -20,8 +32,20 @@ export const offers = [
isPremium: false,
previewImage: 'img/apartment-02.jpg',
NumberOfPlaces: 1,
latitude: 52.3609553943508,
longitude: 4.85309666406198,
location: {
latitude: 52.3609553943508,
longitude: 4.85309666406198,
zoom: 0,
},
city: {
name: 'Amsterdam',
location: {
latitude: 52.35514938496378,
longitude: 4.673877537499948,
zoom: 8,
},
},
isFavorite: false,
},
{
id: 3,
Expand All @@ -32,8 +56,20 @@ export const offers = [
isPremium: false,
previewImage: 'img/studio-01.jpg',
NumberOfPlaces: 1,
latitude: 52.3909553943508,
longitude: 4.929309666406198,
location: {
latitude: 52.3909553943508,
longitude: 4.929309666406198,
zoom: 0,
},
city: {
name: 'Amsterdam',
location: {
latitude: 52.35514938496378,
longitude: 4.673877537499948,
zoom: 8,
},
},
isFavorite: false,
},
{
id: 4,
Expand All @@ -44,7 +80,19 @@ export const offers = [
isPremium: true,
previewImage: 'img/studio-01.jpg',
NumberOfPlaces: 1,
latitude: 52.3809553943508,
longitude: 4.939309666406198,
location: {
latitude: 52.3809553943508,
longitude: 4.939309666406198,
zoom: 0,
},
city: {
name: 'Amsterdam',
location: {
latitude: 52.35514938496378,
longitude: 4.673877537499948,
zoom: 8,
},
},
isFavorite: false,
},
];

0 comments on commit f0060ab

Please sign in to comment.