Skip to content

Commit

Permalink
Merge pull request #18 from KseniaTry/master
Browse files Browse the repository at this point in the history
  • Loading branch information
keksobot authored Oct 21, 2024
2 parents ca3c3aa + c844c68 commit 36a6987
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/presenter/main-presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ export default class MainPresenter {
this.#addNewPointButton = new AddNewPointButtonView({
onClick: this.#handleNewPointButtonClick,
});

render(this.#addNewPointButton, this.#mainContainer);

if (this.#pointModel.failedToLoadPoints) {
this.#addNewPointButton.element.disabled = true;
}
}

#renderMain() {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/common-utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const capitalize = (string) => string.charAt(0).toUpperCase() + string.slice(1);
const capitalize = (name) => name.charAt(0).toUpperCase() + name.slice(1);

export { capitalize };
6 changes: 3 additions & 3 deletions src/view/trip-info-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { humanizePointDate } from '../utils/point-utils';
import { TRIP_INFO_DATE_FORMAT } from '../const';

const getFirstPoint = (points) => {
const sortedByDateFromPoints = [...points].sort((a, b) => a.dateFrom - b.dateFrom);
const sortedByDateFromPoints = [...points].sort((pointA, pointB) => pointA.dateFrom - pointB.dateFrom);
const firstPoint = sortedByDateFromPoints[0].dateFrom;
return firstPoint;
};

const getLastPoint = (points) => {
const sortedByDateFromPoints = [...points].sort((a, b) => b.dateTo - a.dateTo);
const sortedByDateFromPoints = [...points].sort((pointA, pointB) => pointB.dateTo - pointA.dateTo);
const lastPoint = sortedByDateFromPoints[0].dateTo;
return lastPoint;
};

const getDestinationsTitle = (points, allDestinations) => {
const sortedByDateFromPoints = [...points].sort((a, b) => a.dateFrom - b.dateFrom);
const sortedByDateFromPoints = [...points].sort((pointA, pointB) => pointA.dateFrom - pointB.dateFrom);

const firstDestinationId = sortedByDateFromPoints[0].destination;
const lastDestinationId = sortedByDateFromPoints[sortedByDateFromPoints.length - 1].destination;
Expand Down

0 comments on commit 36a6987

Please sign in to comment.