+
+
+
+
+ `
+ );
}
-
export default class OffersView {
- constructor({point, offers, destination}) {
+ constructor({point, allOffers, allDestination, pointDestination}) {
this.point = point;
- this.offers = offers;
- this.destination = destination;
+ this.allOffers = allOffers;
+ this.allDestination = allDestination;
+ this.pointDestination = pointDestination;
}
getTemplate() {
- return createAddPointTemplate(this.point, this.offers, this.destination);
+ return createAddPointTemplate(this.point, this.allOffers, this.allDestination, this.pointDestination);
}
getElement() {
diff --git a/src/view/trip-point-view.js b/src/view/trip-point-view.js
index ad5a308..840f51e 100644
--- a/src/view/trip-point-view.js
+++ b/src/view/trip-point-view.js
@@ -1,17 +1,32 @@
import {createElement} from '../render.js';
-import { getRandomInteger } from '../utils.js';
+//import { getRandomInteger } from '../utils.js';
+const createListTemplate = (point, offers, destination) => {
+ const { basePrice, type, isFavorite} = point;
+ const typeName = type[0].toUpperCase() + type.slice(1, type.length);
+
+ const createEventOfferTemplate = (title, price) => (`
+
+ ${title}
+
+ ${price}
+
+ `);
+
+ const createEventOffers = offers
+ .map((offer) => createEventOfferTemplate(offer.title, offer.price)).join('');
+
+ const favoriteClassName = isFavorite
+ ? 'event__favorite-btn event__favorite-btn--active'
+ : 'event__favorite-btn';
-function createListTemplate(point, offers, destination) {
- const {type, basePrice} = point;
return (
- `
- -
+ `
-
-
${type}
+
${typeName} ${destination.name}
@@ -25,13 +40,9 @@ function createListTemplate(point, offers, destination) {
Offers:
- -
- WWWWWWW
- +€
- ${getRandomInteger(10, 100)}
-
+ ${createEventOffers}
-
- `);
-}
-
+ `);
+};
export default class PointView {
constructor({point, offers, destination}) {
this.point = point;