From 2304e24c4f0ef76cf799c43e37bab47bb4248746 Mon Sep 17 00:00:00 2001 From: Antoine PRONNIER Date: Wed, 7 Feb 2024 11:26:18 +0100 Subject: [PATCH] wip new shop --- .../shop-categories.component.html | 20 ++++++--- .../shop-categories.component.ts | 45 ++++++++++++++++--- src/app/pages/shop/shop.component.html | 11 +++-- src/app/pages/shop/shop.module.ts | 2 + 4 files changed, 60 insertions(+), 18 deletions(-) diff --git a/src/app/pages/shop/components/shop-categories/shop-categories.component.html b/src/app/pages/shop/components/shop-categories/shop-categories.component.html index 8396cbb..e20fe03 100644 --- a/src/app/pages/shop/components/shop-categories/shop-categories.component.html +++ b/src/app/pages/shop/components/shop-categories/shop-categories.component.html @@ -2,12 +2,18 @@

Catégories

- - - +
+
+

{{ category.name }}

+

{{ category.description }}

+
+
+ +
+

{{ category.name }}

+

{{ category.description }}

+
+
+
diff --git a/src/app/pages/shop/components/shop-categories/shop-categories.component.ts b/src/app/pages/shop/components/shop-categories/shop-categories.component.ts index 9282eaa..d1f48a0 100644 --- a/src/app/pages/shop/components/shop-categories/shop-categories.component.ts +++ b/src/app/pages/shop/components/shop-categories/shop-categories.component.ts @@ -1,20 +1,51 @@ -import {Component} from '@angular/core'; -import {PacifistaShopCategoryDTO} from "@funixproductions/funixproductions-requests"; +import {Component, EventEmitter, OnInit, Output} from '@angular/core'; +import { + PacifistaShopCategoryDTO, + PacifistaShopCategoryService, + PageOption, + QueryBuilder +} from "@funixproductions/funixproductions-requests"; +import {HttpClient} from "@angular/common/http"; +import {environment} from "../../../../../environments/environment"; +import NotificationService from "../../../../services/notifications/services/NotificationService"; @Component({ selector: 'app-shop-categories', templateUrl: './shop-categories.component.html', styleUrls: ['./shop-categories.component.scss'] }) -export class ShopCategoriesComponent { +export class ShopCategoriesComponent implements OnInit { + + private categoriesService: PacifistaShopCategoryService; + @Output() onCategorySelected = new EventEmitter(); categoriesList: PacifistaShopCategoryDTO[] = []; + categorySelected?: PacifistaShopCategoryDTO; + + constructor(httpClient: HttpClient, + private notificationService: NotificationService) { + this.categoriesService = new PacifistaShopCategoryService(httpClient, environment.production); + } - constructor() { - const gradesCategory = new PacifistaShopCategoryDTO(); - gradesCategory.name = "Grades"; + ngOnInit(): void { + const pageOption: PageOption = new PageOption(); + pageOption.elemsPerPage = 100; + pageOption.page = 0; + pageOption.sort = 'name:asc'; + + this.categoriesService.find(pageOption, new QueryBuilder()).subscribe({ + next: (categories) => { + this.categoriesList = categories.content; + }, + error: err => { + this.notificationService.onErrorRequest(err); + } + }); + } - this.categoriesList.push(gradesCategory); + selectCategory(category: PacifistaShopCategoryDTO): void { + this.categorySelected = category; + this.onCategorySelected.emit(category); } } diff --git a/src/app/pages/shop/shop.component.html b/src/app/pages/shop/shop.component.html index 8070842..9faaf7b 100644 --- a/src/app/pages/shop/shop.component.html +++ b/src/app/pages/shop/shop.component.html @@ -1,20 +1,22 @@

Boutique

-

La boutique officielle de Pacifista.

+

La boutique officielle de Pacifista pour acheter des avantages uniques et soutenir le serveur Minecraft et son équipe.

- +
- +
@@ -22,7 +24,8 @@

Boutique

- +
diff --git a/src/app/pages/shop/shop.module.ts b/src/app/pages/shop/shop.module.ts index c2e1992..41ec8e8 100644 --- a/src/app/pages/shop/shop.module.ts +++ b/src/app/pages/shop/shop.module.ts @@ -10,6 +10,7 @@ import {ShopArticleComponent} from './components/shop-articles/shop-article/shop import {ShopArticleModalComponent} from './components/shop-articles/shop-article-modal/shop-article-modal.component'; import {ShopCheckoutComponent} from './shop-checkout/shop-checkout.component'; import {ShopBasketLittleComponent} from './components/shop-basket-little/shop-basket-little.component'; +import {HttpClientModule} from "@angular/common/http"; @NgModule({ declarations: [ @@ -23,6 +24,7 @@ import {ShopBasketLittleComponent} from './components/shop-basket-little/shop-ba ], imports: [ CommonModule, + HttpClientModule, ShopRoutingModule, FontAwesomeModule ]