From fbca5558ec04d8e281e1726e324dd1786fc7157e Mon Sep 17 00:00:00 2001 From: "Tizian.Breuch" Date: Mon, 29 Sep 2025 16:21:16 +0200 Subject: [PATCH] models enums services --- src/app/core/enums/shared.enum.ts | 6 ++ src/app/core/models/address.model.ts | 28 ++++++++ src/app/core/models/analytics.model.ts | 32 +++++++++ src/app/core/models/auth.models.ts | 8 ++- src/app/core/models/category.model.ts | 10 +++ src/app/core/models/customer.model.ts | 19 ++++++ .../{dashboard.ts => dashboard.model.ts} | 0 src/app/core/models/discount.model.ts | 19 ++++++ src/app/core/models/file.model.ts | 3 + src/app/core/models/order.model.ts | 65 +++++++++++++++++++ src/app/core/models/order.ts | 19 ------ src/app/core/models/payment.model.ts | 20 ++++++ src/app/core/models/product.model.ts | 44 +++++++++++++ src/app/core/models/review.model.ts | 18 +++++ src/app/core/models/setting.model.ts | 7 ++ src/app/core/models/shipping.model.ts | 9 +++ src/app/core/models/shop.model.ts | 29 +++++++++ src/app/core/models/supplier.model.ts | 9 +++ src/app/core/models/user.model.ts | 15 +++++ .../dashboard-page.component.ts | 5 +- .../features/services/analytics.service.ts | 18 +++++ src/app/features/services/category.service.ts | 32 +++++++++ src/app/features/services/discount.service.ts | 32 +++++++++ src/app/features/services/order.service.ts | 24 +++++++ .../services/payment-method.service.ts | 32 +++++++++ src/app/features/services/product.service.ts | 32 +++++++++ src/app/features/services/review.service.ts | 24 +++++++ src/app/features/services/setting.service.ts | 20 ++++++ .../services/shipping-method.service.ts | 32 +++++++++ .../features/services/shop-info.service.ts | 20 ++++++ src/app/features/services/supplier.service.ts | 32 +++++++++ src/app/features/services/user.service.ts | 28 ++++++++ .../orders-table/orders-table.component.ts | 11 ++-- 33 files changed, 671 insertions(+), 31 deletions(-) create mode 100644 src/app/core/enums/shared.enum.ts create mode 100644 src/app/core/models/address.model.ts create mode 100644 src/app/core/models/analytics.model.ts create mode 100644 src/app/core/models/category.model.ts create mode 100644 src/app/core/models/customer.model.ts rename src/app/core/models/{dashboard.ts => dashboard.model.ts} (100%) create mode 100644 src/app/core/models/discount.model.ts create mode 100644 src/app/core/models/file.model.ts create mode 100644 src/app/core/models/order.model.ts delete mode 100644 src/app/core/models/order.ts create mode 100644 src/app/core/models/payment.model.ts create mode 100644 src/app/core/models/product.model.ts create mode 100644 src/app/core/models/review.model.ts create mode 100644 src/app/core/models/setting.model.ts create mode 100644 src/app/core/models/shipping.model.ts create mode 100644 src/app/core/models/shop.model.ts create mode 100644 src/app/core/models/supplier.model.ts create mode 100644 src/app/core/models/user.model.ts create mode 100644 src/app/features/services/analytics.service.ts create mode 100644 src/app/features/services/category.service.ts create mode 100644 src/app/features/services/discount.service.ts create mode 100644 src/app/features/services/order.service.ts create mode 100644 src/app/features/services/payment-method.service.ts create mode 100644 src/app/features/services/product.service.ts create mode 100644 src/app/features/services/review.service.ts create mode 100644 src/app/features/services/setting.service.ts create mode 100644 src/app/features/services/shipping-method.service.ts create mode 100644 src/app/features/services/shop-info.service.ts create mode 100644 src/app/features/services/supplier.service.ts create mode 100644 src/app/features/services/user.service.ts diff --git a/src/app/core/enums/shared.enum.ts b/src/app/core/enums/shared.enum.ts new file mode 100644 index 0000000..48844aa --- /dev/null +++ b/src/app/core/enums/shared.enum.ts @@ -0,0 +1,6 @@ +export type AddressType = 'Billing' | 'Shipping' | 'CustomerDefault'; +export type AnalyticsPeriod = 'Last7Days' | 'Last30Days' | 'AllTime'; +export type DiscountType = 'Percentage' | 'FixedAmount'; +export type OrderStatus = 'Pending' | 'Processing' | 'Shipped' | 'Delivered' | 'Cancelled' | 'Refunded'; +export type PaymentGatewayType = 'BankTransfer' | 'PayPal' | 'Stripe' | 'CashOnDelivery' | 'Invoice'; +export type PaymentStatus = 'Pending' | 'Paid' | 'Failed' | 'Refunded'; \ No newline at end of file diff --git a/src/app/core/models/address.model.ts b/src/app/core/models/address.model.ts new file mode 100644 index 0000000..143a138 --- /dev/null +++ b/src/app/core/models/address.model.ts @@ -0,0 +1,28 @@ +import { AddressType } from "../enums/shared.enum"; + +export interface Address { + id: string; + street?: string; + houseNumber?: string; + city?: string; + postalCode?: string; + country?: string; + type: AddressType; + firstName?: string; + lastName?: string; +} + +export interface CreateAddress { + street: string; + houseNumber: string; + city: string; + postalCode: string; + country: string; + type: AddressType; +} + +export interface UpdateAddress extends CreateAddress { + id: string; + firstName: string; + lastName: string; +} \ No newline at end of file diff --git a/src/app/core/models/analytics.model.ts b/src/app/core/models/analytics.model.ts new file mode 100644 index 0000000..1a60bc0 --- /dev/null +++ b/src/app/core/models/analytics.model.ts @@ -0,0 +1,32 @@ +export interface KpiSummary { + totalRevenue: number; + totalOrders: number; + totalCustomers: number; + newCustomersThisPeriod: number; + averageOrderValue: number; +} + +export interface SalesDataPoint { + date?: string; + revenue: number; +} + +export interface TopProduct { + productId: string; + name?: string; + sku?: string; + unitsSold: number; + totalRevenue: number; +} + +export interface InventoryStatus { + productsWithLowStock: number; + overallStockAvailabilityPercentage: number; +} + +export interface Analytics { + kpiSummary: KpiSummary; + salesOverTime?: SalesDataPoint[]; + topPerformingProducts?: TopProduct[]; + inventoryStatus: InventoryStatus; +} \ No newline at end of file diff --git a/src/app/core/models/auth.models.ts b/src/app/core/models/auth.models.ts index 69d6080..9f3be46 100644 --- a/src/app/core/models/auth.models.ts +++ b/src/app/core/models/auth.models.ts @@ -5,19 +5,21 @@ export interface LoginRequest { password: string; } -export interface RegisterRequest extends LoginRequest { +export interface RegisterRequest { + email: string; + password: string; + confirmPassword: string; firstName: string; lastName: string; - confirmPassword: string; } export interface AuthResponse { isAuthSuccessful: boolean; + errorMessage?: string; token?: string; userId?: string; email?: string; roles?: string[]; - errorMessage?: string; } export interface ChangePasswordRequest { diff --git a/src/app/core/models/category.model.ts b/src/app/core/models/category.model.ts new file mode 100644 index 0000000..420172e --- /dev/null +++ b/src/app/core/models/category.model.ts @@ -0,0 +1,10 @@ +export interface Category { + id: string; + name?: string; + slug?: string; + description?: string; + parentcategorieId?: string; + imageUrl?: string; + isActive: boolean; + displayOrder: number; +} \ No newline at end of file diff --git a/src/app/core/models/customer.model.ts b/src/app/core/models/customer.model.ts new file mode 100644 index 0000000..41e8eb2 --- /dev/null +++ b/src/app/core/models/customer.model.ts @@ -0,0 +1,19 @@ +export interface Customer { + id: string; + userId?: string; + firstName?: string; + lastName?: string; + email?: string; + phoneNumber?: string; + defaultShippingAddressId?: string; + defaultBillingAddressId?: string; +} + +export interface UpdateCustomer { + firstName: string; + lastName: string; + phoneNumber?: string; + currentPassword: string; + defaultShippingAddressId?: string; + defaultBillingAddressId?: string; +} \ No newline at end of file diff --git a/src/app/core/models/dashboard.ts b/src/app/core/models/dashboard.model.ts similarity index 100% rename from src/app/core/models/dashboard.ts rename to src/app/core/models/dashboard.model.ts diff --git a/src/app/core/models/discount.model.ts b/src/app/core/models/discount.model.ts new file mode 100644 index 0000000..49b41f0 --- /dev/null +++ b/src/app/core/models/discount.model.ts @@ -0,0 +1,19 @@ +import { DiscountType } from "../enums/shared.enum"; + +export interface Discount { + id: string; + name?: string; + discountType: DiscountType; + discountValue: number; + startDate: string; // ISO 8601 date string + endDate?: string; // ISO 8601 date string + isActive: boolean; + requiresCouponCode: boolean; + couponCode?: string; + minimumOrderAmount?: number; + maximumUsageCount?: number; + currentUsageCount: number; + description?: string; + assignedProductIds?: string[]; + assignedCategoryIds?: string[]; +} \ No newline at end of file diff --git a/src/app/core/models/file.model.ts b/src/app/core/models/file.model.ts new file mode 100644 index 0000000..2444e74 --- /dev/null +++ b/src/app/core/models/file.model.ts @@ -0,0 +1,3 @@ +export interface FileUploadResult { + url?: string; +} \ No newline at end of file diff --git a/src/app/core/models/order.model.ts b/src/app/core/models/order.model.ts new file mode 100644 index 0000000..92fb53e --- /dev/null +++ b/src/app/core/models/order.model.ts @@ -0,0 +1,65 @@ +import { Address } from './address.model'; +import { OrderStatus, PaymentStatus } from '../enums/shared.enum'; + +export interface OrderItem { + id: string; + orderId: string; + productId?: string; + productVariantId?: string; + productName?: string; + productSKU?: string; + quantity: number; + unitPrice: number; + totalPrice: number; +} + +export interface OrderSummary { + id: string; + orderNumber?: string; + orderDate: string; + status: OrderStatus; + totalAmount: number; + paymentStatus: PaymentStatus; + customerName?: string; + paymentMethodName?: string; + shippingMethodName?: string; +} + +export interface OrderDetail { + id: string; + orderNumber?: string; + customerId?: string; + orderDate: string; + status: OrderStatus; + totalAmount: number; + shippingAddress: Address; + billingAddress: Address; + paymentMethod?: string; + shippingTrackingNumber?: string; + shippedDate?: string; + deliveredDate?: string; + paymentStatus: PaymentStatus; + orderItems?: OrderItem[]; +} + +export interface CreateOrderItem { + productId: string; + productVariantId?: string; + quantity: number; +} + +export interface CreateOrder { + customerId?: string; + guestEmail?: string; + guestPhoneNumber?: string; + shippingAddressId: string; + billingAddressId: string; + paymentMethodId: string; + shippingMethodId: string; + couponCode?: string; + items?: CreateOrderItem[]; +} + +export interface UpdateOrderStatusRequest { + newStatus: OrderStatus; +} \ No newline at end of file diff --git a/src/app/core/models/order.ts b/src/app/core/models/order.ts deleted file mode 100644 index 7c1d72f..0000000 --- a/src/app/core/models/order.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { OrderStatus } from "../types/order"; - -export interface OrderUser { - name: string; - email: string; - avatarUrl: string; -} - -export interface Order { - id: string; - user: OrderUser; - amount: string; - status: OrderStatus; -} - -export interface StatusOption { - value: OrderStatus | 'all'; - label: string; -} \ No newline at end of file diff --git a/src/app/core/models/payment.model.ts b/src/app/core/models/payment.model.ts new file mode 100644 index 0000000..78cec8f --- /dev/null +++ b/src/app/core/models/payment.model.ts @@ -0,0 +1,20 @@ +import { PaymentGatewayType } from "../enums/shared.enum"; + +export interface PublicPaymentMethod { + id: string; + name?: string; + description?: string; + paymentGatewayType: PaymentGatewayType; + processingFee?: number; + publicConfiguration?: any; +} + +export interface AdminPaymentMethod { + id: string; + name?: string; + description?: string; + isActive: boolean; + paymentGatewayType: PaymentGatewayType; + configuration?: any; + processingFee?: number; +} \ No newline at end of file diff --git a/src/app/core/models/product.model.ts b/src/app/core/models/product.model.ts new file mode 100644 index 0000000..76f8141 --- /dev/null +++ b/src/app/core/models/product.model.ts @@ -0,0 +1,44 @@ +import { Category } from './category.model'; + +export interface ProductImage { + id: string; + url?: string; + isMainImage: boolean; + displayOrder: number; +} + +export interface PublicProduct { + id: string; + name?: string; + description?: string; + sku?: string; + price: number; + oldPrice?: number; + isInStock: boolean; + stockQuantity: number; + slug?: string; + categories?: Category[]; + images?: ProductImage[]; +} + +export interface AdminProduct { + id: string; + name?: string; + description?: string; + sku?: string; + price: number; + oldPrice?: number; + isActive: boolean; + isInStock: boolean; + stockQuantity: number; + weight?: number; + slug?: string; + createdDate: string; + lastModifiedDate?: string; + supplierId?: string; + purchasePrice?: number; + categorieIds?: string[]; + images?: ProductImage[]; + isFeatured: boolean; + featuredDisplayOrder: number; +} \ No newline at end of file diff --git a/src/app/core/models/review.model.ts b/src/app/core/models/review.model.ts new file mode 100644 index 0000000..1a680d7 --- /dev/null +++ b/src/app/core/models/review.model.ts @@ -0,0 +1,18 @@ +export interface Review { + id: string; + productId: string; + productName?: string; + customerName?: string; + rating: number; + title?: string; + comment?: string; + reviewDate: string; + isApproved: boolean; +} + +export interface CreateReview { + productId: string; + rating: number; + title: string; + comment?: string; +} \ No newline at end of file diff --git a/src/app/core/models/setting.model.ts b/src/app/core/models/setting.model.ts new file mode 100644 index 0000000..ccd05eb --- /dev/null +++ b/src/app/core/models/setting.model.ts @@ -0,0 +1,7 @@ +export interface Setting { + key: string; + value?: string; + description?: string; + isActive: boolean; + group?: string; +} \ No newline at end of file diff --git a/src/app/core/models/shipping.model.ts b/src/app/core/models/shipping.model.ts new file mode 100644 index 0000000..eb97874 --- /dev/null +++ b/src/app/core/models/shipping.model.ts @@ -0,0 +1,9 @@ +export interface ShippingMethod { + id: string; + name?: string; + description?: string; + cost: number; + isActive: boolean; + minDeliveryDays: number; + maxDeliveryDays: number; +} \ No newline at end of file diff --git a/src/app/core/models/shop.model.ts b/src/app/core/models/shop.model.ts new file mode 100644 index 0000000..f2aed0c --- /dev/null +++ b/src/app/core/models/shop.model.ts @@ -0,0 +1,29 @@ +export interface AdminShopInfo { + shopName: string; + slogan?: string; + contactEmail: string; + phoneNumber?: string; + street?: string; + city?: string; + postalCode?: string; + country?: string; + vatNumber?: string; + companyRegistrationNumber?: string; + facebookUrl?: string; + instagramUrl?: string; + twitterUrl?: string; +} + +export interface PublicShopInfo { + shopName?: string; + slogan?: string; + contactEmail?: string; + phoneNumber?: string; + street?: string; + city?: string; + postalCode?: string; + country?: string; + facebookUrl?: string; + instagramUrl?: string; + twitterUrl?: string; +} \ No newline at end of file diff --git a/src/app/core/models/supplier.model.ts b/src/app/core/models/supplier.model.ts new file mode 100644 index 0000000..8c8a580 --- /dev/null +++ b/src/app/core/models/supplier.model.ts @@ -0,0 +1,9 @@ +export interface Supplier { + id: string; + name?: string; + contactPerson?: string; + email?: string; + phoneNumber?: string; + addressId?: string; + notes?: string; +} \ No newline at end of file diff --git a/src/app/core/models/user.model.ts b/src/app/core/models/user.model.ts new file mode 100644 index 0000000..62c9e93 --- /dev/null +++ b/src/app/core/models/user.model.ts @@ -0,0 +1,15 @@ +export interface User { + id?: string; + email?: string; + userName?: string; + roles?: string[]; + createdDate: string; + emailConfirmed: boolean; + lastActive?: string; + firstName?: string; + lastName?: string; +} + +export interface UpdateUserRolesRequest { + newRoles?: string[]; +} \ No newline at end of file diff --git a/src/app/features/components/dashboard/dashboard-page/dashboard-page.component.ts b/src/app/features/components/dashboard/dashboard-page/dashboard-page.component.ts index a213179..cdfc937 100644 --- a/src/app/features/components/dashboard/dashboard-page/dashboard-page.component.ts +++ b/src/app/features/components/dashboard/dashboard-page/dashboard-page.component.ts @@ -2,8 +2,7 @@ import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { KpiCardComponent } from '../kpi-card/kpi-card.component'; import { OrdersTableComponent } from '../../../../shared/components/data-display/orders-table/orders-table.component'; -import { Kpi } from '../../../../core/models/dashboard'; -import { Order } from '../../../../core/models/order'; +import { Kpi } from '../../../../core/models/dashboard.model'; @Component({ @@ -42,7 +41,7 @@ export class DashboardPageComponent { }, ]; - mockOrders: Order[] = [ + mockOrders: any[] = [ { id: 'a2d4b', user: { name: 'Max Mustermann', email: 'max@test.de', avatarUrl: 'https://i.pravatar.cc/150?u=max' }, diff --git a/src/app/features/services/analytics.service.ts b/src/app/features/services/analytics.service.ts new file mode 100644 index 0000000..895c0f1 --- /dev/null +++ b/src/app/features/services/analytics.service.ts @@ -0,0 +1,18 @@ +import { Injectable, inject } from '@angular/core'; +import { HttpClient, HttpParams } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { API_URL } from '../../core/tokens/api-url.token'; +import { Analytics } from '../../core/models/analytics.model'; +import { AnalyticsPeriod } from '../../core/enums/shared.enum'; + +@Injectable({ providedIn: 'root' }) +export class AnalyticsService { + private http = inject(HttpClient); + private apiUrl = inject(API_URL); + private readonly endpoint = '/AdminAnalytics'; + + get(period: AnalyticsPeriod): Observable { + const params = new HttpParams().set('period', period); + return this.http.get(`${this.apiUrl}${this.endpoint}`, { params }); + } +} \ No newline at end of file diff --git a/src/app/features/services/category.service.ts b/src/app/features/services/category.service.ts new file mode 100644 index 0000000..d248e6b --- /dev/null +++ b/src/app/features/services/category.service.ts @@ -0,0 +1,32 @@ +import { Injectable, inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { API_URL } from '../../core/tokens/api-url.token'; +import { Category } from '../../core/models/category.model'; + +@Injectable({ providedIn: 'root' }) +export class CategoryService { + private http = inject(HttpClient); + private apiUrl = inject(API_URL); + private readonly endpoint = '/AdminCategories'; + + getAll(): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}`); + } + + getById(id: string): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}/${id}`); + } + + create(data: FormData): Observable { + return this.http.post(`${this.apiUrl}${this.endpoint}`, data); + } + + update(id: string, data: FormData): Observable { + return this.http.put(`${this.apiUrl}${this.endpoint}/${id}`, data); + } + + delete(id: string): Observable { + return this.http.delete(`${this.apiUrl}${this.endpoint}/${id}`); + } +} \ No newline at end of file diff --git a/src/app/features/services/discount.service.ts b/src/app/features/services/discount.service.ts new file mode 100644 index 0000000..553d1ca --- /dev/null +++ b/src/app/features/services/discount.service.ts @@ -0,0 +1,32 @@ +import { Injectable, inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { API_URL } from '../../core/tokens/api-url.token'; +import { Discount } from '../../core/models/discount.model'; + +@Injectable({ providedIn: 'root' }) +export class DiscountService { + private http = inject(HttpClient); + private apiUrl = inject(API_URL); + private readonly endpoint = '/AdminDiscounts'; + + getAll(): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}`); + } + + getById(id: string): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}/${id}`); + } + + create(data: Discount): Observable { + return this.http.post(`${this.apiUrl}${this.endpoint}`, data); + } + + update(id: string, data: Discount): Observable { + return this.http.put(`${this.apiUrl}${this.endpoint}/${id}`, data); + } + + delete(id: string): Observable { + return this.http.delete(`${this.apiUrl}${this.endpoint}/${id}`); + } +} \ No newline at end of file diff --git a/src/app/features/services/order.service.ts b/src/app/features/services/order.service.ts new file mode 100644 index 0000000..91515b0 --- /dev/null +++ b/src/app/features/services/order.service.ts @@ -0,0 +1,24 @@ +import { Injectable, inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { API_URL } from '../../core/tokens/api-url.token'; +import { OrderDetail, OrderSummary, UpdateOrderStatusRequest } from '../../core/models/order.model'; + +@Injectable({ providedIn: 'root' }) +export class OrderService { + private http = inject(HttpClient); + private apiUrl = inject(API_URL); + private readonly endpoint = '/AdminOrders'; + + getAll(): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}`); + } + + getById(id: string): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}/${id}`); + } + + updateStatus(id: string, request: UpdateOrderStatusRequest): Observable { + return this.http.put(`${this.apiUrl}${this.endpoint}/${id}/status`, request); + } +} \ No newline at end of file diff --git a/src/app/features/services/payment-method.service.ts b/src/app/features/services/payment-method.service.ts new file mode 100644 index 0000000..5441c9c --- /dev/null +++ b/src/app/features/services/payment-method.service.ts @@ -0,0 +1,32 @@ +import { Injectable, inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { API_URL } from '../../core/tokens/api-url.token'; +import { AdminPaymentMethod } from '../../core/models/payment.model'; + +@Injectable({ providedIn: 'root' }) +export class PaymentMethodService { + private http = inject(HttpClient); + private apiUrl = inject(API_URL); + private readonly endpoint = '/AdminPaymentMethods'; + + getAll(): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}`); + } + + getById(id: string): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}/${id}`); + } + + create(data: AdminPaymentMethod): Observable { + return this.http.post(`${this.apiUrl}${this.endpoint}`, data); + } + + update(id: string, data: AdminPaymentMethod): Observable { + return this.http.put(`${this.apiUrl}${this.endpoint}/${id}`, data); + } + + delete(id: string): Observable { + return this.http.delete(`${this.apiUrl}${this.endpoint}/${id}`); + } +} \ No newline at end of file diff --git a/src/app/features/services/product.service.ts b/src/app/features/services/product.service.ts new file mode 100644 index 0000000..7332a4e --- /dev/null +++ b/src/app/features/services/product.service.ts @@ -0,0 +1,32 @@ +import { Injectable, inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { API_URL } from '../../core/tokens/api-url.token'; +import { AdminProduct } from '../../core/models/product.model'; + +@Injectable({ providedIn: 'root' }) +export class ProductService { + private http = inject(HttpClient); + private apiUrl = inject(API_URL); + private readonly endpoint = '/AdminProducts'; + + getAll(): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}`); + } + + getById(id: string): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}/${id}`); + } + + create(data: FormData): Observable { + return this.http.post(`${this.apiUrl}${this.endpoint}`, data); + } + + update(id: string, data: FormData): Observable { + return this.http.put(`${this.apiUrl}${this.endpoint}/${id}`, data); + } + + delete(id: string): Observable { + return this.http.delete(`${this.apiUrl}${this.endpoint}/${id}`); + } +} \ No newline at end of file diff --git a/src/app/features/services/review.service.ts b/src/app/features/services/review.service.ts new file mode 100644 index 0000000..3860b19 --- /dev/null +++ b/src/app/features/services/review.service.ts @@ -0,0 +1,24 @@ +import { Injectable, inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { API_URL } from '../../core/tokens/api-url.token'; +import { Review } from '../../core/models/review.model'; + +@Injectable({ providedIn: 'root' }) +export class ReviewService { + private http = inject(HttpClient); + private apiUrl = inject(API_URL); + private readonly endpoint = '/AdminReviews'; + + getAll(): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}`); + } + + approve(id: string): Observable { + return this.http.post(`${this.apiUrl}${this.endpoint}/${id}/approve`, {}); + } + + delete(id: string): Observable { + return this.http.delete(`${this.apiUrl}${this.endpoint}/${id}`); + } +} \ No newline at end of file diff --git a/src/app/features/services/setting.service.ts b/src/app/features/services/setting.service.ts new file mode 100644 index 0000000..702f2a7 --- /dev/null +++ b/src/app/features/services/setting.service.ts @@ -0,0 +1,20 @@ +import { Injectable, inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { API_URL } from '../../core/tokens/api-url.token'; +import { Setting } from '../../core/models/setting.model'; + +@Injectable({ providedIn: 'root' }) +export class SettingService { + private http = inject(HttpClient); + private apiUrl = inject(API_URL); + private readonly endpoint = '/AdminSettings'; + + getAllGrouped(): Observable<{ [group: string]: Setting[] }> { + return this.http.get<{ [group: string]: Setting[] }>(`${this.apiUrl}${this.endpoint}`); + } + + update(settings: Setting[]): Observable { + return this.http.put(`${this.apiUrl}${this.endpoint}`, settings); + } +} \ No newline at end of file diff --git a/src/app/features/services/shipping-method.service.ts b/src/app/features/services/shipping-method.service.ts new file mode 100644 index 0000000..1c84c62 --- /dev/null +++ b/src/app/features/services/shipping-method.service.ts @@ -0,0 +1,32 @@ +import { Injectable, inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { API_URL } from '../../core/tokens/api-url.token'; +import { ShippingMethod } from '../../core/models/shipping.model'; + +@Injectable({ providedIn: 'root' }) +export class ShippingMethodService { + private http = inject(HttpClient); + private apiUrl = inject(API_URL); + private readonly endpoint = '/AdminShippingMethods'; + + getAll(): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}`); + } + + getById(id: string): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}/${id}`); + } + + create(data: ShippingMethod): Observable { + return this.http.post(`${this.apiUrl}${this.endpoint}`, data); + } + + update(id: string, data: ShippingMethod): Observable { + return this.http.put(`${this.apiUrl}${this.endpoint}/${id}`, data); + } + + delete(id: string): Observable { + return this.http.delete(`${this.apiUrl}${this.endpoint}/${id}`); + } +} \ No newline at end of file diff --git a/src/app/features/services/shop-info.service.ts b/src/app/features/services/shop-info.service.ts new file mode 100644 index 0000000..e4b305d --- /dev/null +++ b/src/app/features/services/shop-info.service.ts @@ -0,0 +1,20 @@ +import { Injectable, inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { API_URL } from '../../core/tokens/api-url.token'; +import { AdminShopInfo } from '../../core/models/shop.model'; + +@Injectable({ providedIn: 'root' }) +export class ShopInfoService { + private http = inject(HttpClient); + private apiUrl = inject(API_URL); + private readonly endpoint = '/AdminShopInfo'; + + get(): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}`); + } + + update(data: AdminShopInfo): Observable { + return this.http.put(`${this.apiUrl}${this.endpoint}`, data); + } +} \ No newline at end of file diff --git a/src/app/features/services/supplier.service.ts b/src/app/features/services/supplier.service.ts new file mode 100644 index 0000000..40ed6bd --- /dev/null +++ b/src/app/features/services/supplier.service.ts @@ -0,0 +1,32 @@ +import { Injectable, inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { API_URL } from '../../core/tokens/api-url.token'; +import { Supplier } from '../../core/models/supplier.model'; + +@Injectable({ providedIn: 'root' }) +export class SupplierService { + private http = inject(HttpClient); + private apiUrl = inject(API_URL); + private readonly endpoint = '/AdminSuppliers'; + + getAll(): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}`); + } + + getById(id: string): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}/${id}`); + } + + create(data: Supplier): Observable { + return this.http.post(`${this.apiUrl}${this.endpoint}`, data); + } + + update(id: string, data: Supplier): Observable { + return this.http.put(`${this.apiUrl}${this.endpoint}/${id}`, data); + } + + delete(id: string): Observable { + return this.http.delete(`${this.apiUrl}${this.endpoint}/${id}`); + } +} \ No newline at end of file diff --git a/src/app/features/services/user.service.ts b/src/app/features/services/user.service.ts new file mode 100644 index 0000000..fa00714 --- /dev/null +++ b/src/app/features/services/user.service.ts @@ -0,0 +1,28 @@ +import { Injectable, inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; +import { API_URL } from '../../core/tokens/api-url.token'; +import { User, UpdateUserRolesRequest } from '../../core/models/user.model'; + +@Injectable({ providedIn: 'root' }) +export class UserService { + private http = inject(HttpClient); + private apiUrl = inject(API_URL); + private readonly endpoint = '/AdminUsers'; + + getAll(): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}`); + } + + getById(userId: string): Observable { + return this.http.get(`${this.apiUrl}${this.endpoint}/${userId}`); + } + + updateRoles(userId: string, data: UpdateUserRolesRequest): Observable { + return this.http.put(`${this.apiUrl}${this.endpoint}/${userId}/roles`, data); + } + + delete(userId: string): Observable { + return this.http.delete(`${this.apiUrl}${this.endpoint}/${userId}`); + } +} \ No newline at end of file diff --git a/src/app/shared/components/data-display/orders-table/orders-table.component.ts b/src/app/shared/components/data-display/orders-table/orders-table.component.ts index a461d99..e37d68e 100644 --- a/src/app/shared/components/data-display/orders-table/orders-table.component.ts +++ b/src/app/shared/components/data-display/orders-table/orders-table.component.ts @@ -10,8 +10,7 @@ import { StatusPillComponent } from '../../ui/status-pill/status-pill.component' import { ButtonComponent } from '../../ui/button/button.component'; import { PaginatorComponent } from '../paginator/paginator.component'; -import { Order } from '../../../../core/models/order'; -import { StatusOption } from '../../../../core/models/order'; + import { OrderStatus } from '../../../../core/types/order'; import { SearchBarComponent } from '../../layout/search-bar/search-bar.component'; @@ -30,7 +29,7 @@ import { SearchBarComponent } from '../../layout/search-bar/search-bar.component }) export class OrdersTableComponent { // Nimmt die anzuzeigenden Bestelldaten entgegen - @Input() data: Order[] = []; + @Input() data: any[] = []; @Input() itemsPerPage = 5; // Gibt Events für die Aktionen aus, mit der ID der betroffenen Bestellung @@ -41,7 +40,7 @@ export class OrdersTableComponent { public searchTerm = ''; public selectedStatus: OrderStatus | 'all' = 'all'; - public statusOptions: StatusOption[] = [ + public statusOptions: any[] = [ { value: 'all', label: 'Alle' }, { value: 'info', label: 'Info' }, { value: 'completed', label: 'Abgeschlossen' }, @@ -49,8 +48,8 @@ export class OrdersTableComponent { { value: 'cancelled', label: 'Storniert' }, ]; - public filteredData: Order[] = []; - public displayedOrders: Order[] = []; + public filteredData: any[] = []; + public displayedOrders: any[] = []; public currentPage = 1; private statusTextMap = new Map([