Skip to content

Commit e644582

Browse files
committed
feat: add product list management screen with hierarchical filtering, sorting, and CRUD actions for products and variants.
1 parent c767869 commit e644582

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

frontend/src/pages/Products/ProductManager/ProductList.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@ export function ProductListScreen() {
3030
const { user } = useAuth();
3131
const canEditProducts = canManageProducts(user);
3232

33+
const apiBaseUrl = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8081/api';
34+
const apiOrigin = apiBaseUrl.replace(/\/api\/?$/, '');
35+
const resolveProductImageUrl = (imageUrl) => {
36+
if (!imageUrl) return null;
37+
if (imageUrl.startsWith('http://') || imageUrl.startsWith('https://') || imageUrl.startsWith('blob:')) {
38+
return imageUrl;
39+
}
40+
return `${apiOrigin}${imageUrl.startsWith('/') ? '' : '/'}${imageUrl}`;
41+
};
42+
43+
3344
// --- STATE QUẢN LÝ FILTER PHÂN CẤP ---
3445
const [filterCategory, setFilterCategory] = useState(null);
3546
const [filterBrand, setFilterBrand] = useState(null);
@@ -768,7 +779,7 @@ export function ProductListScreen() {
768779
<div className="flex items-center gap-2">
769780
{v.image_url ? (
770781
<img
771-
src={v.image_url.startsWith('http') ? v.image_url : `http://localhost:8081${v.image_url.startsWith('/') ? '' : '/'}${v.image_url}`}
782+
src={resolveProductImageUrl(v.image_url)}
772783
alt={v.name}
773784
className="w-9 h-9 rounded-lg object-cover shadow-sm border border-gray-100"
774785
/>
@@ -875,7 +886,7 @@ export function ProductListScreen() {
875886
<div className="flex items-center gap-2">
876887
{product.image_url ? (
877888
<img
878-
src={product.image_url.startsWith('http') ? product.image_url : `http://localhost:8081${product.image_url.startsWith('/') ? '' : '/'}${product.image_url}`}
889+
src={resolveProductImageUrl(product.image_url)}
879890
alt={product.name}
880891
className="w-10 h-10 rounded-lg object-cover shadow-sm border border-gray-100 bg-white"
881892
/>

0 commit comments

Comments
 (0)