1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-07 01:54:16 +01:00

do not display empty categories titles

This commit is contained in:
Sylvain 2021-06-10 16:17:10 +02:00
parent 1f966754d7
commit 817db8b5eb

View File

@ -192,10 +192,11 @@ const PlansList: React.FC<PlansListProps> = ({ onError, onPlanSelection, onLogin
return ( return (
<div className="list-of-categories"> <div className="list-of-categories">
{Array.from(plans).sort(compareCategories).map(([categoryId, plansByCategory]) => { {Array.from(plans).sort(compareCategories).map(([categoryId, plansByCategory]) => {
const categoryPlans = plansByCategory.filter(filterPlan);
return ( return (
<div key={categoryId} className={`plans-per-category ${categoryId ? 'with-category' : 'no-category' }`}> <div key={categoryId} className={`plans-per-category ${categoryId ? 'with-category' : 'no-category' }`}>
{!!categoryId && <h3 className="category-title">{ categoryName(categoryId) }</h3>} {!!categoryId && categoryPlans.length > 0 && <h3 className="category-title">{ categoryName(categoryId) }</h3>}
{renderPlans(plansByCategory)} {renderPlans(categoryPlans)}
</div> </div>
) )
})} })}
@ -209,10 +210,7 @@ const PlansList: React.FC<PlansListProps> = ({ onError, onPlanSelection, onLogin
const renderPlans = (categoryPlans: Array<Plan>): ReactNode => { const renderPlans = (categoryPlans: Array<Plan>): ReactNode => {
return ( return (
<div className="list-of-plans"> <div className="list-of-plans">
{categoryPlans.length === 0 && <span className="no-plans"> {categoryPlans.length > 0 && categoryPlans.sort(comparePlans).map(plan => (
{t('app.public.plans.no_plans')}
</span>}
{categoryPlans.filter(filterPlan).sort(comparePlans).map(plan => (
<PlanCard key={plan.id} <PlanCard key={plan.id}
userId={customer?.id} userId={customer?.id}
subscribedPlanId={subscribedPlanId} subscribedPlanId={subscribedPlanId}