mirror of
https://github.com/narrrl/holy-flavor-rater.git
synced 2026-11-03 16:41:27 +01:00
Merge branch 'main' into narl.io
This commit is contained in:
commit
4796b2c711
2 files changed
+8
-7
No files matched your search
@@ -69,16 +69,16 @@ const CategoryList: React.FC = () => {
|
||||
try {
|
||||
if (query) {
|
||||
const res = await api.get(`flavors/`);
|
||||
setAllFlavors(res.data);
|
||||
setAllFlavors(Array.isArray(res.data) ? res.data : (res.data.results || []));
|
||||
} else {
|
||||
const [catRes, topRes, recentRes] = await Promise.all([
|
||||
api.get('categories/'),
|
||||
api.get('flavors/top/'),
|
||||
api.get('ratings/recent/')
|
||||
]);
|
||||
setCategories(catRes.data);
|
||||
setTopFlavors(topRes.data);
|
||||
setRecentReviews(recentRes.data);
|
||||
setCategories(Array.isArray(catRes.data) ? catRes.data : (catRes.data.results || []));
|
||||
setTopFlavors(Array.isArray(topRes.data) ? topRes.data : (topRes.data.results || []));
|
||||
setRecentReviews(Array.isArray(recentRes.data) ? recentRes.data : (recentRes.data.results || []));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
@@ -45,9 +45,10 @@ const CategoryFlavors: React.FC = () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await api.get(`flavors/?category__slug=${slug}`);
|
||||
setFlavors(res.data);
|
||||
if (res.data.length > 0) {
|
||||
setCategoryName(res.data[0].category_name);
|
||||
const data = Array.isArray(res.data) ? res.data : (res.data.results || []);
|
||||
setFlavors(data);
|
||||
if (data.length > 0) {
|
||||
setCategoryName(data[0].category_name);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
||||
Reference in new issue
Block a user