Skip to content

Commit

Permalink
odd: fix rating round
Browse files Browse the repository at this point in the history
  • Loading branch information
rasulov1337 committed Dec 16, 2024
1 parent 282e84e commit 9612a45
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/AdCard/AdCard.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<div class='separator'>·</div>
<div class='housing-card__rating-container'>
<img class='housing-card__star' src='/star.png' alt='star' />
<span class='housing-card__rating'>{{author.rating}}</span>
<span class='housing-card__rating'>{{rating}}</span>
</div>
</div>
</div>
Expand Down
13 changes: 7 additions & 6 deletions src/components/AdCard/AdCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ export default class AdCard extends ReactiveComponent {
// return data.images[state.toShowIndex as number].path;
// },
},
templateData: data,
templateData: {
...data,
rating: ('' + data.author.rating).slice(0, 3),
},
});
this.plannedImageIndex = null;
this.currentImageIndex = 0;
Expand Down Expand Up @@ -203,7 +206,7 @@ export default class AdCard extends ReactiveComponent {
'.js-fill-heart'
) as HTMLButtonElement;

if (response.ok){
if (response.ok) {
this.data.isFavorite = true;
const successMessage = PopupSuccess(
'Объявление добавлено в избранное'
Expand All @@ -214,10 +217,8 @@ export default class AdCard extends ReactiveComponent {
heartButton.classList.add('already-liked');
} else {
this.data.isFavorite = false;
await ApiClient.removeFromFavourites(this.data.id)
const successMessage = PopupSuccess(
'Успешно удалено'
);
await ApiClient.removeFromFavourites(this.data.id);
const successMessage = PopupSuccess('Успешно удалено');
document
.querySelector('.page-container')
?.appendChild(successMessage);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/AdPage/AdPage.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
<dt class='ad-page__author-info__desc__term'>Рейтинг</dt>
<dd
class='ad-page__author-info__desc__definition'
>{{author.rating}}</dd>
>{{rating}}</dd>
</div>
<div class='ad-page__author-info__desc__item'>
<dt class='ad-page__author-info__desc__term'>Пол</dt>
Expand Down
1 change: 1 addition & 0 deletions src/pages/AdPage/AdPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class AdPage extends ReactiveComponent {
templateData: {
...data,
...authorInfo,
rating: ('' + data.author.rating).slice(0, 3),
age: calculateAge(authorInfo.birthdate),
sex: authorInfo.sex === 'M' ? 'Мужской' : 'Женский',
isAuthor: data.authorUUID === globalStore.auth.userId,
Expand Down

0 comments on commit 9612a45

Please sign in to comment.