very first commit

This commit is contained in:
sdarbinyan
2026-01-18 18:57:06 +04:00
commit bd80896886
152 changed files with 28211 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
import { Component, OnInit, signal } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterLink } from '@angular/router';
import { CarouselModule } from 'primeng/carousel';
import { ButtonModule } from 'primeng/button';
import { TagModule } from 'primeng/tag';
import { ApiService, CartService } from '../../services';
import { Item } from '../../models';
import { environment } from '../../../environments/environment';
@Component({
selector: 'app-items-carousel',
templateUrl: './items-carousel.component.html',
standalone: true,
imports: [CommonModule, RouterLink, CarouselModule, ButtonModule, TagModule],
styleUrls: ['./items-carousel.component.scss']
})
export class ItemsCarouselComponent implements OnInit {
products = signal<Item[]>([]);
loading = signal(true);
isnovo = environment.theme === 'novo';
responsiveOptions: any[] | undefined;
constructor(
private apiService: ApiService,
private cartService: CartService
) {}
ngOnInit() {
this.apiService.getRandomItems(10).subscribe({
next: (items) => {
this.products.set(items);
this.loading.set(false);
},
error: () => {
this.loading.set(false);
}
});
this.responsiveOptions = [
{
breakpoint: '1400px',
numVisible: 3,
numScroll: 1
},
{
breakpoint: '1199px',
numVisible: 4,
numScroll: 1
},
{
breakpoint: '767px',
numVisible: 2,
numScroll: 1
},
{
breakpoint: '575px',
numVisible: 1,
numScroll: 1
}
];
}
getSeverity(remainings: string) {
switch (remainings) {
case 'high':
return 'success';
case 'low':
return 'warn';
case 'out':
return 'danger';
default:
return 'success';
}
}
getInventoryStatus(remainings: string): string {
switch (remainings) {
case 'high':
return 'INSTOCK';
case 'low':
return 'LOWSTOCK';
case 'out':
return 'OUTOFSTOCK';
default:
return 'INSTOCK';
}
}
getItemImage(item: Item): string {
if (item.photos && item.photos.length > 0 && item.photos[0]?.url) {
return item.photos[0].url;
}
return '/assets/images/placeholder.jpg';
}
getDiscountedPrice(item: Item): number {
if (item.discount > 0) {
return item.price * (1 - item.discount / 100);
}
return item.price;
}
addToCart(item: Item): void {
this.cartService.addItem(item.itemID, 1);
}
}