Skip to content

Commit

Permalink
Add some routing
Browse files Browse the repository at this point in the history
  • Loading branch information
rasulov1337 committed Oct 30, 2024
1 parent b9cbaf1 commit e4855bc
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const headerCallbacks = {
profileList: renderProfileList,
};

function renderMainPage() {
const renderMainPage = () => {
const mainPage = new MainPage(pageContainer);
mainPage.render();
}
};

function renderMapPage() {}

Expand All @@ -49,17 +49,9 @@ const renderAdvertPage = async (id: string) => {
const info = (await ApiClient.getAd(id))['place'];

const page = new AdPage({
images: info['Images'],
author: {
uuid: '3',
avatar: '',
sex: 'М',
age: 32,
score: 5,
name: 'Майкл Джордан',
},
country: info['location_main'],
city: info['location_street'],
images: info['images'],
city: info['city'],
address: info['address'],
desc: 'Всем привет! Давайте жить ко мне!',
roomsCount: 3,
});
Expand Down Expand Up @@ -95,7 +87,7 @@ function renderProfileList() {
}

const renderAdListPage = () => {
const page = AdListPage({});
const page = AdListPage([]);
pageContainer.appendChild(page);
};

Expand All @@ -109,9 +101,6 @@ const main = async () => {
root.appendChild(pageContainer);

renderMainPage();
// renderEditAdvertPage('rIfIn1W');
// renderCreateAdvertPage();
// renderAdListPage();
};

router.addRoute('/', async () => {
Expand All @@ -121,14 +110,13 @@ router.addRoute('/', async () => {
router.addRoute('/ads/', async (params: URLSearchParams) => {
const adId = params.get('id');
const action = params.get('action');
const author = params.get('author');

if (!adId) {
return;
}

if (!action) {
if (author === 'me') {
renderAdListPage();
} else if (!action && adId) {
renderAdvertPage(adId);
} else if (action === 'edit') {
} else if (action === 'edit' && adId) {
renderEditAdvertPage(adId);
} else if (action === 'create') {
renderCreateAdvertPage();
Expand Down

0 comments on commit e4855bc

Please sign in to comment.