diff --git a/src/api-service/points-api-service.js b/src/api-service/points-api-service.js index 2ddb793..0732dec 100644 --- a/src/api-service/points-api-service.js +++ b/src/api-service/points-api-service.js @@ -44,9 +44,9 @@ export default class PointsApiService extends ApiService { #adaptToServer(point) { const adaptedPoint = {...point, - 'base_price': point.basePrice, - 'date_from': point.dateFrom instanceof Date ? point.dueDate.toISOString() : null, - 'date_to': point.dateTo instanceof Date ? point.dueDate.toISOString() : null, + 'base_price': Number(point.basePrice), + 'date_from': new Date(point.dateFrom).toISOString(), + 'date_to': new Date(point.dateTo).toISOString(), 'is_favorite': point.isFavorite, }; diff --git a/src/presenter/new-point-presenter.js b/src/presenter/new-point-presenter.js index 9b96a31..3f4adf2 100644 --- a/src/presenter/new-point-presenter.js +++ b/src/presenter/new-point-presenter.js @@ -30,7 +30,7 @@ export default class NewPointPresenter { this.#pointEditComponent = new EditPointView({ pointDestinations: this.#destinationsModel.destinations, pointOffers: this.#offersModel.allOffers, - onFormSubmit: this.#handleFormSubmit, + onSubmitClick: this.#handleFormSubmit, onDeleteClick: this.#handleDeleteClick, type: EditingType.NEW }); diff --git a/src/presenter/trip-presenter.js b/src/presenter/trip-presenter.js index cde8f35..276a1a1 100644 --- a/src/presenter/trip-presenter.js +++ b/src/presenter/trip-presenter.js @@ -186,25 +186,25 @@ export default class TripPresenter { switch(actionType) { case UserAction.UPDATE_POINT: - this.#pointPresenters.get(update.id).setSaving(); try { - await this.#pointsModel.update(updateType, update); + this.#pointPresenters.get(update.point.id).setSaving(); + await this.#pointsModel.updatePoint(updateType, update.point); } catch (err) { - this.#pointPresenters.get(update.id).setAborting(); + this.#pointPresenters.get(update.point.id).setAborting(); } break; case UserAction.ADD_POINT: - this.#newPointPresenter.setSaving(); try { - await this.#pointsModel.add(updateType, update); + this.#newPointPresenter.setSaving(); + await this.#pointsModel.addPoint(updateType, update.point); } catch (err) { this.#newPointPresenter.setAborting(); } break; case UserAction.DELETE_POINT: - this.#pointPresenters.get(update.point.id).setDeleting(); try { - await this.#pointsModel.remove(updateType, update); + this.#pointPresenters.get(update.point.id).setDeleting(); + await this.#pointsModel.deletePoint(updateType, update.point); } catch (err) { this.#pointPresenters.get(update.point.id).setAborting(); } diff --git a/src/view/editing-form-view.js b/src/view/editing-form-view.js index 4052c9c..7a38cd9 100644 --- a/src/view/editing-form-view.js +++ b/src/view/editing-form-view.js @@ -91,12 +91,12 @@ export default class EditPointView extends AbstractStatefulView { }; #formSubmitHandler = (evt) => { - evt.preventDefalt(); + evt.preventDefault(); this.#handleSubmitClick(EditPointView.parseStateToPoint(this._state)); }; #resetClickHandler = (evt) => { - evt.preventDefalt(); + evt.preventDefault(); this.#handleResetClick(EditPointView.parseStateToPoint(this._state)); };