This commit is contained in:
@@ -2280,6 +2280,22 @@ async function loadCars() {
|
||||
}
|
||||
}
|
||||
|
||||
async function applyInitialRoute() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const section = params.get("section");
|
||||
const carId = Number(params.get("car_id") || 0);
|
||||
if (carId && state.cars.some((car) => car.id === carId)) {
|
||||
state.selectedCarId = carId;
|
||||
renderCars();
|
||||
fillCarProfileForm();
|
||||
await loadSelectedCar();
|
||||
}
|
||||
if (section === "carProfile") {
|
||||
await openDrawerSection("carProfileSection");
|
||||
window.history.replaceState({}, "", window.location.pathname);
|
||||
}
|
||||
}
|
||||
|
||||
async function selectCar(carId) {
|
||||
state.selectedCarId = carId;
|
||||
renderCars();
|
||||
@@ -2841,7 +2857,8 @@ Promise.all([loadAuthConfig()])
|
||||
initCarCatalog();
|
||||
return Promise.all([loadMyServiceCenters().catch(() => []), loadCars()]);
|
||||
})
|
||||
.then(() => applyInitialRoute())
|
||||
.catch((error) => {
|
||||
if (error.message === "Требуется вход через Telegram") return;
|
||||
document.body.insertAdjacentHTML("afterbegin", `<div class="error">${error.message}</div>`);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user