added language routing system
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<div class="items-grid">
|
||||
@for (item of items(); track trackByItemId($index, item)) {
|
||||
<div class="item-card">
|
||||
<a [routerLink]="['/item', item.itemID]" class="item-link">
|
||||
<a [routerLink]="['/item', item.itemID] | langRoute" class="item-link">
|
||||
<div class="item-image">
|
||||
<img [src]="getMainImage(item)" [alt]="item.name" loading="lazy" decoding="async" width="300" height="300" />
|
||||
@if (item.discount > 0) {
|
||||
@@ -77,7 +77,7 @@
|
||||
</div>
|
||||
<h3>Упс! Здесь пока пусто</h3>
|
||||
<p>В этой категории ещё нет товаров, но скоро они появятся</p>
|
||||
<a routerLink="/" class="no-items-btn">На главную</a>
|
||||
<a [routerLink]="'/' | langRoute" class="no-items-btn">На главную</a>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,11 @@ import { ApiService, CartService } from '../../services';
|
||||
import { Item } from '../../models';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { getDiscountedPrice, getMainImage, trackByItemId } from '../../utils/item.utils';
|
||||
import { LangRoutePipe } from '../../pipes/lang-route.pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-category',
|
||||
imports: [DecimalPipe, RouterLink],
|
||||
imports: [DecimalPipe, RouterLink, LangRoutePipe],
|
||||
templateUrl: './category.component.html',
|
||||
styleUrls: ['./category.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
@if (subcategories().length > 0) {
|
||||
<div class="categories-grid">
|
||||
@for (cat of subcategories(); track trackByCategoryId($index, cat)) {
|
||||
<a [routerLink]="['/category', cat.categoryID]" class="category-card">
|
||||
<a [routerLink]="['/category', cat.categoryID] | langRoute" class="category-card">
|
||||
<div class="category-image">
|
||||
@if (cat.icon) {
|
||||
<img [src]="cat.icon" [alt]="cat.name" loading="lazy" decoding="async" />
|
||||
@@ -47,7 +47,7 @@
|
||||
</div>
|
||||
<h3>Упс! Подкатегорий пока нет</h3>
|
||||
<p>В этом разделе ещё нет подкатегорий, но скоро они появятся</p>
|
||||
<a routerLink="/" class="no-subcats-btn">На главную</a>
|
||||
<a [routerLink]="'/' | langRoute" class="no-subcats-btn">На главную</a>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { Component, OnInit, OnDestroy, signal, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { ApiService } from '../../services';
|
||||
import { ApiService, LanguageService } from '../../services';
|
||||
import { Category } from '../../models';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { LangRoutePipe } from '../../pipes/lang-route.pipe';
|
||||
|
||||
@Component({
|
||||
selector: 'app-subcategories',
|
||||
imports: [RouterLink],
|
||||
imports: [RouterLink, LangRoutePipe],
|
||||
templateUrl: './subcategories.component.html',
|
||||
styleUrls: ['./subcategories.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
@@ -23,7 +24,8 @@ export class SubcategoriesComponent implements OnInit, OnDestroy {
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private apiService: ApiService
|
||||
private apiService: ApiService,
|
||||
private langService: LanguageService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -48,7 +50,8 @@ export class SubcategoriesComponent implements OnInit, OnDestroy {
|
||||
|
||||
if (!subs || subs.length === 0) {
|
||||
// No subcategories: redirect to items list for this category
|
||||
this.router.navigate(['/category', parentID, 'items'], { replaceUrl: true });
|
||||
const lang = this.langService.currentLanguage();
|
||||
this.router.navigate([`/${lang}/category`, parentID, 'items'], { replaceUrl: true });
|
||||
} else {
|
||||
this.subcategories.set(subs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user