Skip to content

Commit

Permalink
Merge pull request #4 from InsomniaRolodex/module2-task1
Browse files Browse the repository at this point in the history
  • Loading branch information
keksobot authored Jul 1, 2024
2 parents 55f15fe + 6db002c commit 48f2e2e
Show file tree
Hide file tree
Showing 18 changed files with 492 additions and 192 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
webpack.config.js
src/mock/*
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
"eslint": "8.38.0",
"eslint-config-htmlacademy": "9.0.0",
"html-webpack-plugin": "5.5.1",
"lodash": "4.17.21",
"webpack": "5.92.0",
"webpack-cli": "5.1.4",
"webpack-dev-server": "4.13.3"
},
"engines": {
"node": "20"
},
"dependencies": {
"dayjs": "1.11.6"
}
}
31 changes: 31 additions & 0 deletions src/mock/destinations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export const destinations = [
{
id: 'bfa5cb75-a1fe-4b77-a83c-0e528e910e04',
description: 'St. Petersburg, is a beautiful city, a true asian pearl, with crowded streets.',
name: 'St. Petersburg',
pictures: [
{
src: 'http://picsum.photos/300/200?r=0.0762563005163317',
description: 'Chamonix parliament building'
}]
},
{
id: 'bfa5cb75-a1fe-4b77-a83c-0e528e910e05',
description: 'Paris is a major railway, highway, and air-transport hub served by two international airports.',
name: 'Paris',
pictures: [
{
src: 'http://picsum.photos/300/200?r=0.0762563005163317',
description: 'Chamonix parliament building'
}]
},
{
id: 'bfa5cb75-a1fe-4b77-a83c-0e528e910e06',
description: 'Moscow is a very green city, if compared to other cities of comparable size in Western Europe and North America.',
name: 'Moscow',
pictures: [
{
src: 'http://picsum.photos/300/200?r=0.0762563005163317',
description: 'Chamonix parliament building'
}]
}];
153 changes: 153 additions & 0 deletions src/mock/offers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
export const offers = [
{
type: 'taxi',
offers: [
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa31',
title: 'taxi offer 1',
price: 120
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa32',
title: 'taxi offer 2',
price: 130
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa33',
title: 'taxi offer 3',
price: 140
}]
},
{
type: 'bus',
offers: [
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa34',
title: 'bus offer 1',
price: 150
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa35',
title: 'bus offer 2',
price: 160
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa36',
title: 'bus offer 3',
price: 170
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa37',
title: 'bus offer 4',
price: 180
}]
},
{
type: 'train',
offers: [
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa38',
title: 'train offer 1',
price: 190
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa39',
title: 'train offer 2',
price: 200
}]
},
{
type: 'ship',
offers: [
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa30',
title: 'ship offer 1',
price: 210
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa41',
title: 'ship offer 2',
price: 220
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa42',
title: 'ship offer 3',
price: 230
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa43',
title: 'ship offer 4',
price: 240
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa44',
title: 'ship offer 5',
price: 250
}]
},
{
type: 'drive',
offers: [
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa45',
title: 'drive offer 1',
price: 260
}]
},
{
type: 'flight',
offers: [
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa46',
title: 'flight offer 1',
price: 270
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa47',
title: 'flight offer 2',
price: 280
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa48',
title: 'flight offer 3',
price: 290
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa49',
title: 'flight offer 4',
price: 300
}]
},
{
type: 'check-in',
offers: [
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa40',
title: 'chick-in offer 1',
price: 312
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa51',
title: 'chick-in offer 2',
price: 320
},
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa52',
title: 'chick-in offer 3',
price: 330
}]
},
{
type: 'sightseeing',
offers: []
},
{
type: 'restaurant',
offers: [
{
id: 'b4c3e4e6-9053-42ce-b747-e281314baa53',
title: 'restaurant offer 1',
price: 340
}]
}
];
52 changes: 52 additions & 0 deletions src/mock/points.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { toCamelCase } from '../util.js'

export const points = [
{
id: 'f4b62099-293f-4c3d-a702-94eec4a2808c',
basePrice: 11300,
dateFrom: '2019-07-10T00:55:56.845Z',
dateTo: '2019-07-11T11:01:13.375Z',
destination: 'bfa5cb75-a1fe-4b77-a83c-0e528e910e04',
isFavorite: false,
offers: [
'b4c3e4e6-9053-42ce-b747-e281314baa31'
],
type: 'taxi'
},
{
id: 'f4b62099-293f-4c3d-a702-94eec4a2808d',
basePrice: 11200,
dateFrom: '2019-07-12T22:02:56.845Z',
dateTo: '2019-07-13T11:03:13.375Z',
destination: 'bfa5cb75-a1fe-4b77-a83c-0e528e910e05',
isFavorite: true,
offers: [
'b4c3e4e6-9053-42ce-b747-e281314baa34',
'b4c3e4e6-9053-42ce-b747-e281314baa35',
'b4c3e4e6-9053-42ce-b747-e281314baa36'
],
type: 'bus'
},
{
id: 'f4b62099-293f-4c3d-a702-94eec4a2808e',
basePrice: 11100,
dateFrom: '2019-07-14T22:55:56.845Z',
dateTo: '2019-07-15T11:22:13.375Z',
destination: 'bfa5cb75-a1fe-4b77-a83c-0e528e910e06',
isFavorite: false,
offers: [],
type: 'ship'
}];

export const defaultPoint = [
{
id: '000',
basePrice: '000',
dateFrom: '2001-01-01T00:00:00.845Z',
dateTo: '2001-01-01T00:00:00.845Z',
destination: '',
isFavorite: false,
offers: [],
type: 'flight'
}
]
35 changes: 35 additions & 0 deletions src/model/point-model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { points, defaultPoint } from '../mock/points.js';
import { destinations } from '../mock/destinations.js';
import { offers } from '../mock/offers.js';

export default class PointModel {
constructor() {
this.points = [];
this.destinations = [];
this.offers = [];
this.defaultPoint = [];
}

init() {
this.points = points;
this.destinations = destinations;
this.offers = offers;
this.defaultPoint = defaultPoint;
}

getPoints() {
return this.points;
}

getDestinations() {
return this.destinations;
}

getOffers() {
return this.offers;
}

getDefaultPoint() {
return this.defaultPoint;
}
}
8 changes: 4 additions & 4 deletions src/presenter/header-presenter.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { render, RenderPosition } from '../render.js';
import Filters from '../view/filters.js';
import TripInfo from '../view/trip-info.js';
import FiltersView from '../view/filters-view.js';
import TripInfoView from '../view/trip-info-view.js';

export default class HeaderPresenter {
constructor ({ container }) {
this.container = container;
}

initInfo () {
render (new TripInfo, this.container, RenderPosition.AFTERBEGIN);
render (new TripInfoView, this.container, RenderPosition.AFTERBEGIN);
}

initFilters () {
render(new Filters, this.container);
render(new FiltersView, this.container);
}
}
34 changes: 21 additions & 13 deletions src/presenter/trip-presenter.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
import { render } from '../render.js';
import CreateForm from '../view/create-form.js';
import EditForm from '../view/edit-form.js';
import Sorting from '../view/sorting.js';
import TripList from '../view/trip-list.js';
import TripPoint from '../view/trip-point.js';
import CreateFormView from '../view/create-form-view.js';
import EditFormView from '../view/edit-form-view.js';
import SortingView from '../view/sorting-view.js';
import TripListView from '../view/trip-list-view.js';
import TripPointView from '../view/trip-point-view.js';
import PointModel from '../model/point-model.js';

export default class TripPresenter {
tripList = new TripList();
tripList = new TripListView();

constructor ({ container }) {
constructor ({ container, pointModel = new PointModel }) {
this.container = container;
this.pointModel = pointModel;
}

init () {
render(new Sorting, this.container);
this.pointModel.init();
const points = this.pointModel.getPoints();
const destinations = this.pointModel.getDestinations();
const offers = this.pointModel.getOffers();
const defaultPoint = this.pointModel.getDefaultPoint();

render(new SortingView, this.container);
render(this.tripList, this.container);
render(new EditForm, this.tripList.getElement());
render(new CreateForm, this.tripList.getElement());
render(new EditFormView(points[0], destinations, offers), this.tripList.getElement());
render(new CreateFormView(defaultPoint[0], destinations, offers), this.tripList.getElement());

for (let i = 0; i < 3; i++) {
render (new TripPoint, this.tripList.getElement());
}
points.forEach((point) => {
render(new TripPointView(point, destinations, offers), this.tripList.getElement());
});
}
}
Loading

0 comments on commit 48f2e2e

Please sign in to comment.