fix: resolve footer email typo, unify assistant naming, add German scientific team context, add tooltips definitions, and optimize homepage featured products category diversity
This commit is contained in:
1 parent
67d6f71d7a
commit
a92b1a61ff
5 files changed
+39
-7
No files matched your search
@@ -127,8 +127,28 @@ export class ProductService {
|
||||
|
||||
public async getFeaturedProducts(): Promise<Product[]> {
|
||||
try {
|
||||
const response = await api.get('/products');
|
||||
return response.data.data.slice(0, 4).map((item: any) => this.mapBackendToFrontend(item));
|
||||
const response = await api.get('/products?limit=30');
|
||||
const all = response.data.data.map((item: any) => this.mapBackendToFrontend(item));
|
||||
const featured: Product[] = [];
|
||||
const categoriesSeen = new Set<string>();
|
||||
|
||||
for (const p of all) {
|
||||
if (p.category && !categoriesSeen.has(p.category)) {
|
||||
featured.push(p);
|
||||
categoriesSeen.add(p.category);
|
||||
}
|
||||
if (featured.length === 4) break;
|
||||
}
|
||||
|
||||
if (featured.length < 4) {
|
||||
for (const p of all) {
|
||||
if (!featured.some(f => f.id === p.id)) {
|
||||
featured.push(p);
|
||||
}
|
||||
if (featured.length === 4) break;
|
||||
}
|
||||
}
|
||||
return featured;
|
||||
} catch (error) {
|
||||
console.error("[ProductService] Failed to fetch featured products:", error);
|
||||
return [];
|
||||
|
||||
Reference in new issue
Block a user