Skip to content

6411 Асцатрян Л.Ш. Лаб 2, Вар 2#107

Open
LiliaASt wants to merge 3 commits intoitsecd:mainfrom
LiliaASt:main
Open

6411 Асцатрян Л.Ш. Лаб 2, Вар 2#107
LiliaASt wants to merge 3 commits intoitsecd:mainfrom
LiliaASt:main

Conversation

@LiliaASt
Copy link
Copy Markdown

@LiliaASt LiliaASt commented Apr 6, 2026

Веб-версия "Прибывалки для электричек"

Возможности:

  • находить желаемую ЖД-станцию поиском по названию и по карте
  • отображать расписания всех проходящих поездов через выбранную станцию
  • отображать расписания для поездов между двумя станциями
  • работа через АПИ Яндекс.Расписаний https://yandex.ru/dev/rasp/doc/ru/

@AvtoBBus AvtoBBus self-requested a review April 9, 2026 14:43
Comment on lines +13 to +41
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.

Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.

You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Комментарии в целом можно удалить и тег <noscript>

const [routeSchedule, setRouteSchedule] = useState(null);
const [loading, setLoading] = useState(false);
const [activeTab, setActiveTab] = useState('station');
const mapRef = useRef(null);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mapRef должен храниться только в компоненте карты

const popupRef = useRef(null);
const [popupContent, setPopupContent] = useState('');

const samaraCenter = fromLonLat([50.15, 53.2]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Координаты нужно вынести отдельно в конфиг или .env

import { fromLonLat } from 'ol/proj';
import { Style, Icon, Text, Fill, Stroke } from 'ol/style';
import Overlay from 'ol/Overlay';
import { stationsData } from '../data/stations';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Забыли добавить файл в гит

}
});

window.selectStationFromMap = (code) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если я всё правильно увидел, то вы нигде не используете эту функцию как минимум, а как максимум записываете это в объект window, единственное применение такому подходу это дебаг через консоль разработчика разве что, но проверить не могу, так как приложение у меня не запускается

Comment on lines +120 to +122
if (mapInstanceRef.current) {
mapInstanceRef.current.setTarget(null);
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этого можно не делать

}
};

const defaultDate = new Date().toISOString().split('T')[0];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше в useState запихнуть или useRef, чтобы не выполнять лишние операции при каждом обновлении компоненты

Или если хотите сделать прям обновляющуюся в реальном времени дату, то это делается через простые манипуляции довольно

Comment on lines +22 to +47
const formatTime = (date) => {
if (!date) return 'Время уточняется';
try {
const dateObj = typeof date === 'string' ? new Date(date) : date;
if (isNaN(dateObj.getTime())) return 'Время уточняется';
return dateObj.toLocaleTimeString('ru-RU', { hour: '2-digit', minute: '2-digit' });
} catch {
return 'Время уточняется';
}
};

const formatFullDate = (date) => {
if (!date) return null;
try {
const dateObj = typeof date === 'string' ? new Date(date) : date;
if (isNaN(dateObj.getTime())) return null;
return dateObj.toLocaleString('ru-RU', {
day: '2-digit',
month: '2-digit',
hour: '2-digit',
minute: '2-digit'
});
} catch {
return null;
}
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это функции утилиты их в папку utils/

const app = express();
const port = 3001;

const API_KEY = process.env.REACT_APP_API_KEY || '5c35214b-1ca9-4216-a86e-d852deeecfaf';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше вот так

const API_KEY = process.env.REACT_APP_API_KEY ?? null;

if (!API_KEY) {
    console.error("Invalid API_KEY")
    return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants