mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-22 14:48:13 +02:00
feat: Add Catalogues page for displaying, searching, and filtering promotional catalogues by enseigne.
This commit is contained in:
1 parent
b224c4988a
commit
5c0d5cebf7
1 file changed
+17
-7
@@ -27,7 +27,12 @@ export default function Catalogues() {
|
|||||||
const loadEnseignes = async () => {
|
const loadEnseignes = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`${API_BASE}/enseignes`);
|
const response = await axios.get(`${API_BASE}/enseignes`);
|
||||||
setEnseignes(response.data);
|
if (Array.isArray(response.data)) {
|
||||||
|
setEnseignes(response.data);
|
||||||
|
} else {
|
||||||
|
console.error('API response for enseignes is not an array:', response.data);
|
||||||
|
setEnseignes([]);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading enseignes:', error);
|
console.error('Error loading enseignes:', error);
|
||||||
toast.error('Erreur lors du chargement des enseignes');
|
toast.error('Erreur lors du chargement des enseignes');
|
||||||
@@ -52,8 +57,13 @@ export default function Catalogues() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const response = await axios.get(API_BASE, { params });
|
const response = await axios.get(API_BASE, { params });
|
||||||
setCatalogues(response.data.data);
|
if (response.data && Array.isArray(response.data.data)) {
|
||||||
setPagination(prev => ({ ...prev, total: response.data.pagination.total }));
|
setCatalogues(response.data.data);
|
||||||
|
setPagination(prev => ({ ...prev, total: response.data.pagination.total }));
|
||||||
|
} else {
|
||||||
|
console.error('API response for catalogues is invalid:', response.data);
|
||||||
|
setCatalogues([]);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading catalogues:', error);
|
console.error('Error loading catalogues:', error);
|
||||||
toast.error('Erreur lors du chargement des catalogues');
|
toast.error('Erreur lors du chargement des catalogues');
|
||||||
@@ -130,8 +140,8 @@ export default function Catalogues() {
|
|||||||
setPagination(prev => ({ ...prev, page: 1 }));
|
setPagination(prev => ({ ...prev, page: 1 }));
|
||||||
}}
|
}}
|
||||||
className={`px-4 py-2 rounded-lg whitespace-nowrap transition-colors ${!selectedEnseigne
|
className={`px-4 py-2 rounded-lg whitespace-nowrap transition-colors ${!selectedEnseigne
|
||||||
? 'bg-primary text-primary-foreground'
|
? 'bg-primary text-primary-foreground'
|
||||||
: 'bg-secondary hover:bg-secondary/80'
|
: 'bg-secondary hover:bg-secondary/80'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
Toutes les enseignes
|
Toutes les enseignes
|
||||||
@@ -144,8 +154,8 @@ export default function Catalogues() {
|
|||||||
setPagination(prev => ({ ...prev, page: 1 }));
|
setPagination(prev => ({ ...prev, page: 1 }));
|
||||||
}}
|
}}
|
||||||
className={`px-4 py-2 rounded-lg whitespace-nowrap transition-colors ${selectedEnseigne?.id === enseigne.id
|
className={`px-4 py-2 rounded-lg whitespace-nowrap transition-colors ${selectedEnseigne?.id === enseigne.id
|
||||||
? 'bg-primary text-primary-foreground'
|
? 'bg-primary text-primary-foreground'
|
||||||
: 'bg-secondary hover:bg-secondary/80'
|
: 'bg-secondary hover:bg-secondary/80'
|
||||||
}`}
|
}`}
|
||||||
style={
|
style={
|
||||||
selectedEnseigne?.id === enseigne.id
|
selectedEnseigne?.id === enseigne.id
|
||||||
|
|||||||
Reference in new issue
Block a user