models enums services
This commit is contained in:
6
src/app/core/enums/shared.enum.ts
Normal file
6
src/app/core/enums/shared.enum.ts
Normal 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';
|
||||||
28
src/app/core/models/address.model.ts
Normal file
28
src/app/core/models/address.model.ts
Normal 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;
|
||||||
|
}
|
||||||
32
src/app/core/models/analytics.model.ts
Normal file
32
src/app/core/models/analytics.model.ts
Normal 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;
|
||||||
|
}
|
||||||
@@ -5,19 +5,21 @@ export interface LoginRequest {
|
|||||||
password: string;
|
password: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RegisterRequest extends LoginRequest {
|
export interface RegisterRequest {
|
||||||
|
email: string;
|
||||||
|
password: string;
|
||||||
|
confirmPassword: string;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
lastName: string;
|
lastName: string;
|
||||||
confirmPassword: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthResponse {
|
export interface AuthResponse {
|
||||||
isAuthSuccessful: boolean;
|
isAuthSuccessful: boolean;
|
||||||
|
errorMessage?: string;
|
||||||
token?: string;
|
token?: string;
|
||||||
userId?: string;
|
userId?: string;
|
||||||
email?: string;
|
email?: string;
|
||||||
roles?: string[];
|
roles?: string[];
|
||||||
errorMessage?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChangePasswordRequest {
|
export interface ChangePasswordRequest {
|
||||||
|
|||||||
10
src/app/core/models/category.model.ts
Normal file
10
src/app/core/models/category.model.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
export interface Category {
|
||||||
|
id: string;
|
||||||
|
name?: string;
|
||||||
|
slug?: string;
|
||||||
|
description?: string;
|
||||||
|
parentcategorieId?: string;
|
||||||
|
imageUrl?: string;
|
||||||
|
isActive: boolean;
|
||||||
|
displayOrder: number;
|
||||||
|
}
|
||||||
19
src/app/core/models/customer.model.ts
Normal file
19
src/app/core/models/customer.model.ts
Normal 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;
|
||||||
|
}
|
||||||
19
src/app/core/models/discount.model.ts
Normal file
19
src/app/core/models/discount.model.ts
Normal 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[];
|
||||||
|
}
|
||||||
3
src/app/core/models/file.model.ts
Normal file
3
src/app/core/models/file.model.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export interface FileUploadResult {
|
||||||
|
url?: string;
|
||||||
|
}
|
||||||
65
src/app/core/models/order.model.ts
Normal file
65
src/app/core/models/order.model.ts
Normal 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;
|
||||||
|
}
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
20
src/app/core/models/payment.model.ts
Normal file
20
src/app/core/models/payment.model.ts
Normal 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;
|
||||||
|
}
|
||||||
44
src/app/core/models/product.model.ts
Normal file
44
src/app/core/models/product.model.ts
Normal 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;
|
||||||
|
}
|
||||||
18
src/app/core/models/review.model.ts
Normal file
18
src/app/core/models/review.model.ts
Normal 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;
|
||||||
|
}
|
||||||
7
src/app/core/models/setting.model.ts
Normal file
7
src/app/core/models/setting.model.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export interface Setting {
|
||||||
|
key: string;
|
||||||
|
value?: string;
|
||||||
|
description?: string;
|
||||||
|
isActive: boolean;
|
||||||
|
group?: string;
|
||||||
|
}
|
||||||
9
src/app/core/models/shipping.model.ts
Normal file
9
src/app/core/models/shipping.model.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export interface ShippingMethod {
|
||||||
|
id: string;
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
cost: number;
|
||||||
|
isActive: boolean;
|
||||||
|
minDeliveryDays: number;
|
||||||
|
maxDeliveryDays: number;
|
||||||
|
}
|
||||||
29
src/app/core/models/shop.model.ts
Normal file
29
src/app/core/models/shop.model.ts
Normal 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;
|
||||||
|
}
|
||||||
9
src/app/core/models/supplier.model.ts
Normal file
9
src/app/core/models/supplier.model.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export interface Supplier {
|
||||||
|
id: string;
|
||||||
|
name?: string;
|
||||||
|
contactPerson?: string;
|
||||||
|
email?: string;
|
||||||
|
phoneNumber?: string;
|
||||||
|
addressId?: string;
|
||||||
|
notes?: string;
|
||||||
|
}
|
||||||
15
src/app/core/models/user.model.ts
Normal file
15
src/app/core/models/user.model.ts
Normal 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[];
|
||||||
|
}
|
||||||
@@ -2,8 +2,7 @@ import { Component } from '@angular/core';
|
|||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { KpiCardComponent } from '../kpi-card/kpi-card.component';
|
import { KpiCardComponent } from '../kpi-card/kpi-card.component';
|
||||||
import { OrdersTableComponent } from '../../../../shared/components/data-display/orders-table/orders-table.component';
|
import { OrdersTableComponent } from '../../../../shared/components/data-display/orders-table/orders-table.component';
|
||||||
import { Kpi } from '../../../../core/models/dashboard';
|
import { Kpi } from '../../../../core/models/dashboard.model';
|
||||||
import { Order } from '../../../../core/models/order';
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -42,7 +41,7 @@ export class DashboardPageComponent {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
mockOrders: Order[] = [
|
mockOrders: any[] = [
|
||||||
{
|
{
|
||||||
id: 'a2d4b',
|
id: 'a2d4b',
|
||||||
user: { name: 'Max Mustermann', email: 'max@test.de', avatarUrl: 'https://i.pravatar.cc/150?u=max' },
|
user: { name: 'Max Mustermann', email: 'max@test.de', avatarUrl: 'https://i.pravatar.cc/150?u=max' },
|
||||||
|
|||||||
18
src/app/features/services/analytics.service.ts
Normal file
18
src/app/features/services/analytics.service.ts
Normal 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 });
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/app/features/services/category.service.ts
Normal file
32
src/app/features/services/category.service.ts
Normal 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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/app/features/services/discount.service.ts
Normal file
32
src/app/features/services/discount.service.ts
Normal 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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/app/features/services/order.service.ts
Normal file
24
src/app/features/services/order.service.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/app/features/services/payment-method.service.ts
Normal file
32
src/app/features/services/payment-method.service.ts
Normal 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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/app/features/services/product.service.ts
Normal file
32
src/app/features/services/product.service.ts
Normal 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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/app/features/services/review.service.ts
Normal file
24
src/app/features/services/review.service.ts
Normal 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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/app/features/services/setting.service.ts
Normal file
20
src/app/features/services/setting.service.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/app/features/services/shipping-method.service.ts
Normal file
32
src/app/features/services/shipping-method.service.ts
Normal 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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/app/features/services/shop-info.service.ts
Normal file
20
src/app/features/services/shop-info.service.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
32
src/app/features/services/supplier.service.ts
Normal file
32
src/app/features/services/supplier.service.ts
Normal 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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
src/app/features/services/user.service.ts
Normal file
28
src/app/features/services/user.service.ts
Normal 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}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,8 +10,7 @@ import { StatusPillComponent } from '../../ui/status-pill/status-pill.component'
|
|||||||
import { ButtonComponent } from '../../ui/button/button.component';
|
import { ButtonComponent } from '../../ui/button/button.component';
|
||||||
import { PaginatorComponent } from '../paginator/paginator.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 { OrderStatus } from '../../../../core/types/order';
|
||||||
import { SearchBarComponent } from '../../layout/search-bar/search-bar.component';
|
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 {
|
export class OrdersTableComponent {
|
||||||
// Nimmt die anzuzeigenden Bestelldaten entgegen
|
// Nimmt die anzuzeigenden Bestelldaten entgegen
|
||||||
@Input() data: Order[] = [];
|
@Input() data: any[] = [];
|
||||||
@Input() itemsPerPage = 5;
|
@Input() itemsPerPage = 5;
|
||||||
|
|
||||||
// Gibt Events für die Aktionen aus, mit der ID der betroffenen Bestellung
|
// Gibt Events für die Aktionen aus, mit der ID der betroffenen Bestellung
|
||||||
@@ -41,7 +40,7 @@ export class OrdersTableComponent {
|
|||||||
public searchTerm = '';
|
public searchTerm = '';
|
||||||
public selectedStatus: OrderStatus | 'all' = 'all';
|
public selectedStatus: OrderStatus | 'all' = 'all';
|
||||||
|
|
||||||
public statusOptions: StatusOption[] = [
|
public statusOptions: any[] = [
|
||||||
{ value: 'all', label: 'Alle' },
|
{ value: 'all', label: 'Alle' },
|
||||||
{ value: 'info', label: 'Info' },
|
{ value: 'info', label: 'Info' },
|
||||||
{ value: 'completed', label: 'Abgeschlossen' },
|
{ value: 'completed', label: 'Abgeschlossen' },
|
||||||
@@ -49,8 +48,8 @@ export class OrdersTableComponent {
|
|||||||
{ value: 'cancelled', label: 'Storniert' },
|
{ value: 'cancelled', label: 'Storniert' },
|
||||||
];
|
];
|
||||||
|
|
||||||
public filteredData: Order[] = [];
|
public filteredData: any[] = [];
|
||||||
public displayedOrders: Order[] = [];
|
public displayedOrders: any[] = [];
|
||||||
public currentPage = 1;
|
public currentPage = 1;
|
||||||
|
|
||||||
private statusTextMap = new Map<OrderStatus, string>([
|
private statusTextMap = new Map<OrderStatus, string>([
|
||||||
|
|||||||
Reference in New Issue
Block a user