integration
This commit is contained in:
@@ -90,6 +90,7 @@ export class MockDataService {
|
||||
priority: 1,
|
||||
quantity: 50,
|
||||
price: 1299,
|
||||
discount: 0,
|
||||
currency: 'USD',
|
||||
imgs: [
|
||||
'https://via.placeholder.com/600x400?text=iPhone+Front',
|
||||
@@ -121,6 +122,7 @@ export class MockDataService {
|
||||
priority: 2,
|
||||
quantity: 35,
|
||||
price: 1199,
|
||||
discount: 10,
|
||||
currency: 'USD',
|
||||
imgs: ['https://via.placeholder.com/600x400?text=Samsung+S24'],
|
||||
tags: ['new', 'android'],
|
||||
@@ -140,6 +142,7 @@ export class MockDataService {
|
||||
priority: 3,
|
||||
quantity: 20,
|
||||
price: 999,
|
||||
discount: 15,
|
||||
currency: 'USD',
|
||||
imgs: ['https://via.placeholder.com/600x400?text=Pixel+8'],
|
||||
tags: ['sale', 'android', 'ai'],
|
||||
@@ -158,6 +161,7 @@ export class MockDataService {
|
||||
priority: 1,
|
||||
quantity: 15,
|
||||
price: 2499,
|
||||
discount: 0,
|
||||
currency: 'USD',
|
||||
imgs: ['https://via.placeholder.com/600x400?text=MacBook'],
|
||||
tags: ['featured', 'professional'],
|
||||
@@ -177,6 +181,7 @@ export class MockDataService {
|
||||
priority: 2,
|
||||
quantity: 0,
|
||||
price: 1799,
|
||||
discount: 5,
|
||||
currency: 'USD',
|
||||
imgs: ['https://via.placeholder.com/600x400?text=Dell+XPS'],
|
||||
tags: ['out-of-stock'],
|
||||
@@ -200,6 +205,7 @@ export class MockDataService {
|
||||
priority: i,
|
||||
quantity: Math.floor(Math.random() * 100),
|
||||
price: Math.floor(Math.random() * 1000) + 100,
|
||||
discount: Math.random() > 0.7 ? Math.floor(Math.random() * 30) + 5 : 0,
|
||||
currency: 'USD',
|
||||
imgs: [`https://via.placeholder.com/600x400?text=Product+${i}`],
|
||||
tags: ['test'],
|
||||
@@ -404,6 +410,7 @@ export class MockDataService {
|
||||
priority: data.priority || 99,
|
||||
quantity: data.quantity || 0,
|
||||
price: data.price || 0,
|
||||
discount: data.discount || 0,
|
||||
currency: data.currency || 'USD',
|
||||
imgs: data.imgs || [],
|
||||
tags: data.tags || [],
|
||||
|
||||
@@ -54,6 +54,15 @@ export class ValidationService {
|
||||
return null;
|
||||
}
|
||||
|
||||
validateDiscount(value: any): string | null {
|
||||
if (value === undefined || value === null || value === '') return null;
|
||||
const num = Number(value);
|
||||
if (isNaN(num)) return 'Discount must be a number';
|
||||
if (num < 0) return 'Discount cannot be negative';
|
||||
if (num > 100) return 'Discount cannot exceed 100%';
|
||||
return null;
|
||||
}
|
||||
|
||||
validateUrl(value: string): string | null {
|
||||
if (!value || value.trim().length === 0) {
|
||||
return null; // Optional field
|
||||
@@ -130,6 +139,11 @@ export class ValidationService {
|
||||
const quantityError = this.validateQuantity(item['quantity']);
|
||||
if (quantityError) errors['quantity'] = quantityError;
|
||||
}
|
||||
|
||||
if (item['discount'] !== undefined) {
|
||||
const discountError = this.validateDiscount(item['discount']);
|
||||
if (discountError) errors['discount'] = discountError;
|
||||
}
|
||||
|
||||
if (item['currency'] !== undefined) {
|
||||
const currencyError = this.validateCurrency(item['currency']);
|
||||
|
||||
Reference in New Issue
Block a user