Skip to content

Commit

Permalink
Исправление ошибок
Browse files Browse the repository at this point in the history
  • Loading branch information
MaksimRozov committed Jun 23, 2024
1 parent c87e290 commit f93d1a0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 23 deletions.
3 changes: 1 addition & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ const filterPresenter = new PresenterFilter({

const presenterInfoPanel = new PresenterInfoPanel({
tripInfoContainer: tripMainElement,
pointsModel,
presenter: presenter
pointsModel
});

function handleNewPointButtonClick() {
Expand Down
8 changes: 4 additions & 4 deletions src/model/points-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class PointsModel extends Observable {

this.#offers = offers;
this.#destinations = destinations;
} catch (err) {
} catch (error) {
this.#points = [];
this.#offers = [];
this.#destinations = [];
Expand All @@ -73,7 +73,7 @@ export default class PointsModel extends Observable {
];

this._notify(updateType, updatedPoint);
} catch (err) {
} catch (error) {
throw new Error('Can\'t update point');
}
}
Expand All @@ -89,7 +89,7 @@ export default class PointsModel extends Observable {
];

this._notify(updateType, newPoint);
} catch (err) {
} catch (error) {
throw new Error('Can\'t add point');
}

Expand All @@ -109,7 +109,7 @@ export default class PointsModel extends Observable {
];

this._notify(updateType);
} catch (err) {
} catch (error) {
throw new Error('Can\'t delete point');
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/presenter/presenter-info-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@ export default class PresenterInfoPanel {
#tripInfoContainer = null;
#pointsModel = null;
#tripInfoComponent = null;
#presenter = null;

constructor({ tripInfoContainer, pointsModel, presenter }) {
constructor({ tripInfoContainer, pointsModel }) {
this.#tripInfoContainer = tripInfoContainer;
this.#presenter = presenter;
this.#pointsModel = pointsModel;


this.#pointsModel.addObserver(this.#handleModelEvent);
}

init() {
// const points = this.#presenter.points;
const points = this.#pointsModel.events;
const offers = this.#pointsModel.offers;
const destinations = this.#pointsModel.destinations;
Expand Down
8 changes: 3 additions & 5 deletions src/presenter/presenter-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,23 @@ export default class PresenterMain {
this.#pointPresenterItems.get(update.id).setSaving();
await this.#pointsModel.updatePoint(updateType, update);

} catch (err) {
} catch (error) {
this.#pointPresenterItems.get(update.id).setAborting();
}
break;
case UserAction.ADD_POINT:
try {
this.#presenterNewPoint.setSaving();
await this.#pointsModel.addPoint(updateType, update);
} catch (err) {
} catch (error) {
this.#presenterNewPoint.setAborting();
}
break;
case UserAction.DELETE_POINT:
this.#pointPresenterItems.get(update.id).setDeleting();
try {
await this.#pointsModel.deletePoint(updateType, update);
} catch (err) {
} catch (error) {
this.#pointPresenterItems.get(update.id).setAborting();
}
break;
Expand Down Expand Up @@ -259,6 +259,4 @@ export default class PresenterMain {
this.#listEmptyMessage();
}
};


}
4 changes: 2 additions & 2 deletions src/view/list-empty.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AbstractView from '../framework/view/abstract-view.js';
import { tripMessagesEmpty } from '../utils/filter.js';

const createtListempty = (filterType) => `<p class="trip-events__msg">${tripMessagesEmpty[filterType]}</p>`;
const createListEmpty = (filterType) => `<p class="trip-events__msg">${tripMessagesEmpty[filterType]}</p>`;

export default class ListEmpty extends AbstractView {
#filterType = null;
Expand All @@ -12,6 +12,6 @@ export default class ListEmpty extends AbstractView {
}

get template() {
return createtListempty(this.#filterType);
return createListEmpty(this.#filterType);
}
}
6 changes: 1 addition & 5 deletions src/view/waypoint-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ const createWaypointForm = (waypoint, destinations, offers, pointsModel) => {

const { type, dateFrom, dateTo, basePrice, offers: offersPoint, isDisabled, isSaving, isDeleting } = waypoint;

// const offerCurrent = offers.find((item) => item.type === waypoint.type);
const destinationCurrent = destinations.find((item) => item.id === waypoint.destination);

const createPointDestinationList = createPointDestination(destinationCurrent);
const createPointOffersList = createPointOffers(offers, offersPoint);
const cityList = createCityList(destinations);
Expand Down Expand Up @@ -159,17 +157,15 @@ export default class WaypointEdit extends AbstractStatefulView {
#onEditFormRollupButtonClick = null;
#onDeleteForm = null;
#destinations = null;
#offers = null;
#datepickerFrom = null;
#datepickerTo = null;
#onEditFormSave = null;
#pointsModel = null;
#getOffersByType = null;

constructor({ waypoint = BLANK_POINT, onEditFormSave, onEditFormRollupButtonClick, onDeleteForm, offers, pointsModel, destinations, getOffersByType }) {
constructor({ waypoint = BLANK_POINT, onEditFormSave, onEditFormRollupButtonClick, onDeleteForm, pointsModel, destinations, getOffersByType }) {
super();
this._setState(WaypointEdit.parsePointToState(waypoint));
this.#offers = offers;
this.#destinations = destinations;
this.#onEditFormRollupButtonClick = onEditFormRollupButtonClick;
this.#onEditFormSave = onEditFormSave;
Expand Down

0 comments on commit f93d1a0

Please sign in to comment.