feat: implement product configuration and order management with service refactoring and UI updates
This commit is contained in:
31
src/app/services/order.service.ts
Normal file
31
src/app/services/order.service.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { IOrder } from '../models/order.interface';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class OrderService {
|
||||
|
||||
private currentOrder: IOrder = {};
|
||||
|
||||
public getOrder(): IOrder {
|
||||
return this.currentOrder;
|
||||
}
|
||||
|
||||
public updateOrder(partialOrder: Partial<IOrder>): void {
|
||||
this.currentOrder = { ...this.currentOrder, ...partialOrder };
|
||||
}
|
||||
|
||||
public placeOrder(): string {
|
||||
// Logic to send order
|
||||
|
||||
const finalOrder = this.getOrder();
|
||||
|
||||
const shippingID = "SC-" + Math.floor(Math.random() * 1000000).toString().padStart(6, '0');
|
||||
this.updateOrder({ shippingNumber: shippingID });
|
||||
|
||||
console.log('Order placed:', this.getOrder());
|
||||
|
||||
return shippingID;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user