show article count
This commit is contained in:
parent
2f1c64e6f9
commit
0182d6118f
1 changed files with 6 additions and 3 deletions
|
@ -40,6 +40,7 @@ export type ProximoCategoryType = {
|
||||||
icon: string;
|
icon: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
|
nb_articles: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ProximoArticleType = {
|
export type ProximoArticleType = {
|
||||||
|
@ -149,8 +150,7 @@ function ProximoMainScreen() {
|
||||||
shouldFocusSearchBar: false,
|
shouldFocusSearchBar: false,
|
||||||
category: item.id,
|
category: item.id,
|
||||||
};
|
};
|
||||||
// TODO get article number
|
const article_number = item.nb_articles;
|
||||||
const article_number = 1;
|
|
||||||
const subtitle = `${article_number} ${
|
const subtitle = `${article_number} ${
|
||||||
article_number > 1
|
article_number > 1
|
||||||
? i18n.t('screens.proximo.articles')
|
? i18n.t('screens.proximo.articles')
|
||||||
|
@ -201,6 +201,8 @@ function ProximoMainScreen() {
|
||||||
data: CategoriesType | undefined
|
data: CategoriesType | undefined
|
||||||
): SectionListDataType<ProximoCategoryType> => {
|
): SectionListDataType<ProximoCategoryType> => {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
let totalArticles = 0;
|
||||||
|
data.forEach((c) => (totalArticles += c.nb_articles));
|
||||||
const finalData: CategoriesType = [
|
const finalData: CategoriesType = [
|
||||||
{
|
{
|
||||||
id: -1,
|
id: -1,
|
||||||
|
@ -208,13 +210,14 @@ function ProximoMainScreen() {
|
||||||
icon: 'star',
|
icon: 'star',
|
||||||
created_at: '',
|
created_at: '',
|
||||||
updated_at: '',
|
updated_at: '',
|
||||||
|
nb_articles: totalArticles,
|
||||||
},
|
},
|
||||||
...data,
|
...data,
|
||||||
];
|
];
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
title: '',
|
title: '',
|
||||||
data: finalData.sort(sortFinalData),
|
data: finalData.filter((c) => c.nb_articles > 0).sort(sortFinalData),
|
||||||
keyExtractor: getKeyExtractor,
|
keyExtractor: getKeyExtractor,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue