Skip to content

Commit

Permalink
fix add, delete
Browse files Browse the repository at this point in the history
  • Loading branch information
dashuulka committed Jun 8, 2024
1 parent 1cd0f77 commit 72bba19
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/api-service/points-api-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
2 changes: 1 addition & 1 deletion src/presenter/new-point-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down
14 changes: 7 additions & 7 deletions src/presenter/trip-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions src/view/editing-form-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};

Expand Down

0 comments on commit 72bba19

Please sign in to comment.