This commit is contained in:
2025-12-26 10:27:02 +07:00
parent fd9b5a3819
commit 7fc0be90b8
48 changed files with 5818 additions and 34 deletions

View File

@@ -0,0 +1,16 @@
import { ProductDetailData } from '@/types';
// Hàm helper để lấy URL an toàn từ các cấu trúc dữ liệu khác nhau
function getSlug(url: string): string {
const parts = url.split('/').filter(Boolean);
return parts[parts.length - 1];
}
export function findProductDetailBySlug(
slug: string,
ProductDetail: ProductDetailData[],
): ProductDetailData | null {
const found = ProductDetail.find((item) => item.product_info.productUrl === slug);
return found ?? null;
}