From acad1a719f2b3592b0342f86adad5e8879eff25f Mon Sep 17 00:00:00 2001 From: masoodafar-web Date: Fri, 7 Aug 2026 18:39:49 +0330 Subject: [PATCH] feat(index): add conditional rendering for testimonials section - Implemented a check to display the testimonials section only when there are testimonials available, enhancing the user experience by preventing empty sections. - Updated the logic for loading testimonials from settings to handle cases where the testimonials list may be null, ensuring robustness in data handling. These changes improve the layout and presentation of the Index page, providing users with relevant content based on available testimonials. --- src/FrontOffice.Main/Pages/Index.razor | 3 +++ src/FrontOffice.Main/Pages/Index.razor.cs | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/FrontOffice.Main/Pages/Index.razor b/src/FrontOffice.Main/Pages/Index.razor index 15d3329..ed08e12 100644 --- a/src/FrontOffice.Main/Pages/Index.razor +++ b/src/FrontOffice.Main/Pages/Index.razor @@ -429,6 +429,8 @@ else @* ═══════════════════════════════════════════════ 6. TESTIMONIALS ═══════════════════════════════════════════════ *@ +@if (_testimonials.Count > 0) +{
@@ -465,6 +467,7 @@ else
+} @* ═══════════════════════════════════════════════ 7. FAQ diff --git a/src/FrontOffice.Main/Pages/Index.razor.cs b/src/FrontOffice.Main/Pages/Index.razor.cs index f688624..a66bc26 100644 --- a/src/FrontOffice.Main/Pages/Index.razor.cs +++ b/src/FrontOffice.Main/Pages/Index.razor.cs @@ -193,9 +193,10 @@ public partial class Index : IDisposable } // ── Testimonials ── - if (_settings?.Testimonials?.Any() == true) + // اگر تنظیمات از CMS لود شده، لیست خالی یعنی ادمین عمداً حذف کرده — بدون fallback hardcode + if (_settings is not null) { - _testimonials = _settings.Testimonials + _testimonials = (_settings.Testimonials ?? []) .Select((t, i) => new TestimonialItem(t.Quote ?? "", t.Name ?? "", t.Role ?? "", i * 150)) .ToList(); }