Skip to content

Commit

Permalink
offers fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ssftvyn committed May 22, 2024
1 parent 7a7e83f commit a25c51c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/view/edit-point-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,18 @@ export default class EditingPointView extends AbstractStatefulView{

#changeOfferHandler = (event) => {
event.preventDefault();
const offerId = Number(event.target.id.slice(-1));
const arrayOffersIds = this._state.offers.filter((n) => n !== offerId);
let currentOfferIds = [...this._state.offers];
if (arrayOffersIds.length !== this._state.offers.length) {
currentOfferIds = arrayOffersIds;
const offerId = event.target.id.replace('event-offer-', '');
const newOffers = [...this._state.offers];
const offerIndex = newOffers.findIndex((id) => id === offerId);
if (offerIndex > -1) {
newOffers.splice(offerIndex, 1);
} else {
currentOfferIds.push(offerId);
newOffers.push(offerId);
}
this._setState({
offers: currentOfferIds,
offers: newOffers,
});
this.updateElement(this._state);
};

#setStartDatepicker() {
Expand Down

0 comments on commit a25c51c

Please sign in to comment.