models enums services

This commit is contained in:
Tizian.Breuch
2025-09-29 16:21:16 +02:00
parent 991d57d183
commit fbca5558ec
33 changed files with 671 additions and 31 deletions

View File

@@ -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';

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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 {

View File

@@ -0,0 +1,10 @@
export interface Category {
id: string;
name?: string;
slug?: string;
description?: string;
parentcategorieId?: string;
imageUrl?: string;
isActive: boolean;
displayOrder: number;
}

View File

@@ -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;
}

View File

@@ -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[];
}

View File

@@ -0,0 +1,3 @@
export interface FileUploadResult {
url?: string;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,7 @@
export interface Setting {
key: string;
value?: string;
description?: string;
isActive: boolean;
group?: string;
}

View File

@@ -0,0 +1,9 @@
export interface ShippingMethod {
id: string;
name?: string;
description?: string;
cost: number;
isActive: boolean;
minDeliveryDays: number;
maxDeliveryDays: number;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,9 @@
export interface Supplier {
id: string;
name?: string;
contactPerson?: string;
email?: string;
phoneNumber?: string;
addressId?: string;
notes?: string;
}

View File

@@ -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[];
}

View File

@@ -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' },

View File

@@ -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<Analytics> {
const params = new HttpParams().set('period', period);
return this.http.get<Analytics>(`${this.apiUrl}${this.endpoint}`, { params });
}
}

View File

@@ -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<Category[]> {
return this.http.get<Category[]>(`${this.apiUrl}${this.endpoint}`);
}
getById(id: string): Observable<Category> {
return this.http.get<Category>(`${this.apiUrl}${this.endpoint}/${id}`);
}
create(data: FormData): Observable<Category> {
return this.http.post<Category>(`${this.apiUrl}${this.endpoint}`, data);
}
update(id: string, data: FormData): Observable<void> {
return this.http.put<void>(`${this.apiUrl}${this.endpoint}/${id}`, data);
}
delete(id: string): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}${this.endpoint}/${id}`);
}
}

View File

@@ -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<Discount[]> {
return this.http.get<Discount[]>(`${this.apiUrl}${this.endpoint}`);
}
getById(id: string): Observable<Discount> {
return this.http.get<Discount>(`${this.apiUrl}${this.endpoint}/${id}`);
}
create(data: Discount): Observable<Discount> {
return this.http.post<Discount>(`${this.apiUrl}${this.endpoint}`, data);
}
update(id: string, data: Discount): Observable<void> {
return this.http.put<void>(`${this.apiUrl}${this.endpoint}/${id}`, data);
}
delete(id: string): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}${this.endpoint}/${id}`);
}
}

View File

@@ -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<OrderSummary[]> {
return this.http.get<OrderSummary[]>(`${this.apiUrl}${this.endpoint}`);
}
getById(id: string): Observable<OrderDetail> {
return this.http.get<OrderDetail>(`${this.apiUrl}${this.endpoint}/${id}`);
}
updateStatus(id: string, request: UpdateOrderStatusRequest): Observable<void> {
return this.http.put<void>(`${this.apiUrl}${this.endpoint}/${id}/status`, request);
}
}

View File

@@ -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<AdminPaymentMethod[]> {
return this.http.get<AdminPaymentMethod[]>(`${this.apiUrl}${this.endpoint}`);
}
getById(id: string): Observable<AdminPaymentMethod> {
return this.http.get<AdminPaymentMethod>(`${this.apiUrl}${this.endpoint}/${id}`);
}
create(data: AdminPaymentMethod): Observable<AdminPaymentMethod> {
return this.http.post<AdminPaymentMethod>(`${this.apiUrl}${this.endpoint}`, data);
}
update(id: string, data: AdminPaymentMethod): Observable<void> {
return this.http.put<void>(`${this.apiUrl}${this.endpoint}/${id}`, data);
}
delete(id: string): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}${this.endpoint}/${id}`);
}
}

View File

@@ -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<AdminProduct[]> {
return this.http.get<AdminProduct[]>(`${this.apiUrl}${this.endpoint}`);
}
getById(id: string): Observable<AdminProduct> {
return this.http.get<AdminProduct>(`${this.apiUrl}${this.endpoint}/${id}`);
}
create(data: FormData): Observable<AdminProduct> {
return this.http.post<AdminProduct>(`${this.apiUrl}${this.endpoint}`, data);
}
update(id: string, data: FormData): Observable<void> {
return this.http.put<void>(`${this.apiUrl}${this.endpoint}/${id}`, data);
}
delete(id: string): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}${this.endpoint}/${id}`);
}
}

View File

@@ -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<Review[]> {
return this.http.get<Review[]>(`${this.apiUrl}${this.endpoint}`);
}
approve(id: string): Observable<void> {
return this.http.post<void>(`${this.apiUrl}${this.endpoint}/${id}/approve`, {});
}
delete(id: string): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}${this.endpoint}/${id}`);
}
}

View File

@@ -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<void> {
return this.http.put<void>(`${this.apiUrl}${this.endpoint}`, settings);
}
}

View File

@@ -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<ShippingMethod[]> {
return this.http.get<ShippingMethod[]>(`${this.apiUrl}${this.endpoint}`);
}
getById(id: string): Observable<ShippingMethod> {
return this.http.get<ShippingMethod>(`${this.apiUrl}${this.endpoint}/${id}`);
}
create(data: ShippingMethod): Observable<ShippingMethod> {
return this.http.post<ShippingMethod>(`${this.apiUrl}${this.endpoint}`, data);
}
update(id: string, data: ShippingMethod): Observable<void> {
return this.http.put<void>(`${this.apiUrl}${this.endpoint}/${id}`, data);
}
delete(id: string): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}${this.endpoint}/${id}`);
}
}

View File

@@ -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<AdminShopInfo> {
return this.http.get<AdminShopInfo>(`${this.apiUrl}${this.endpoint}`);
}
update(data: AdminShopInfo): Observable<void> {
return this.http.put<void>(`${this.apiUrl}${this.endpoint}`, data);
}
}

View File

@@ -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<Supplier[]> {
return this.http.get<Supplier[]>(`${this.apiUrl}${this.endpoint}`);
}
getById(id: string): Observable<Supplier> {
return this.http.get<Supplier>(`${this.apiUrl}${this.endpoint}/${id}`);
}
create(data: Supplier): Observable<Supplier> {
return this.http.post<Supplier>(`${this.apiUrl}${this.endpoint}`, data);
}
update(id: string, data: Supplier): Observable<void> {
return this.http.put<void>(`${this.apiUrl}${this.endpoint}/${id}`, data);
}
delete(id: string): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}${this.endpoint}/${id}`);
}
}

View File

@@ -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<User[]> {
return this.http.get<User[]>(`${this.apiUrl}${this.endpoint}`);
}
getById(userId: string): Observable<User> {
return this.http.get<User>(`${this.apiUrl}${this.endpoint}/${userId}`);
}
updateRoles(userId: string, data: UpdateUserRolesRequest): Observable<void> {
return this.http.put<void>(`${this.apiUrl}${this.endpoint}/${userId}/roles`, data);
}
delete(userId: string): Observable<void> {
return this.http.delete<void>(`${this.apiUrl}${this.endpoint}/${userId}`);
}
}

View File

@@ -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<OrderStatus, string>([