diff --git a/src/FrontOffice.Main/ConfigureServices.cs b/src/FrontOffice.Main/ConfigureServices.cs index 0f1c61a..702733a 100644 --- a/src/FrontOffice.Main/ConfigureServices.cs +++ b/src/FrontOffice.Main/ConfigureServices.cs @@ -22,6 +22,7 @@ using CMSMicroservice.Protobuf.Protos.NetworkMembership; using CMSMicroservice.Protobuf.Protos.Commission; using CMSMicroservice.Protobuf.Protos.AppVersion; using CMSMicroservice.Protobuf.Protos.SitePage; +using CMSMicroservice.Protobuf.Protos.SitePageSettings; using CMSMicroservice.Protobuf.Protos.BlogPost; using CMSMicroservice.Protobuf.Protos.BlogCategory; using CMSMicroservice.Protobuf.Protos.DiscountProduct; @@ -83,6 +84,8 @@ public static class ConfigureServices services.AddScoped(); services.AddScoped(); services.AddScoped(); + // Site Page Settings Service (simplified page management) + services.AddScoped(); // Device detection: very light, dependency-free services.AddTransient(); // PDF generation (Chromium only) @@ -133,6 +136,7 @@ public static class ConfigureServices services.AddScoped(CreateAuthenticatedClient); services.AddScoped(CreateAuthenticatedClient); services.AddScoped(CreateAuthenticatedClient); + services.AddScoped(CreateAuthenticatedClient); services.AddScoped(CreateAuthenticatedClient); services.AddScoped(CreateAuthenticatedClient); // Image Resolver Service diff --git a/src/FrontOffice.Main/FrontOffice.Main.csproj b/src/FrontOffice.Main/FrontOffice.Main.csproj index 7339178..a4662dc 100644 --- a/src/FrontOffice.Main/FrontOffice.Main.csproj +++ b/src/FrontOffice.Main/FrontOffice.Main.csproj @@ -11,7 +11,7 @@ - + diff --git a/src/FrontOffice.Main/Pages/Licenses.razor b/src/FrontOffice.Main/Pages/Licenses.razor new file mode 100644 index 0000000..bef2351 --- /dev/null +++ b/src/FrontOffice.Main/Pages/Licenses.razor @@ -0,0 +1,99 @@ +@attribute [Route(RouteConstants.Licenses.Index)] +@inject SitePageSettingsService PageSettingsService + +مجوزها و گواهینامه‌ها | کارا بازار سلامت + +@if (_loading) +{ + + + +} +else +{ + +
+ + + مجوزها و گواهینامه‌ها + + @(_pageData?.HeroTitle ?? "مجوزها و گواهینامه‌های رسمی") + + + @(_pageData?.HeroSubtitle ?? "ما با دریافت مجوزهای رسمی و تأییدیه‌های معتبر، اطمینان شما را در استفاده از خدمات خود جلب کرده‌ایم.") + + + +
+ + + + +
+ + مجوزهای ما + @if (_licenseImages.Any()) + { + + @foreach (var license in _licenseImages) + { + + + + + @if (!string.IsNullOrWhiteSpace(license.Title)) + { + @license.Title + } + @if (!string.IsNullOrWhiteSpace(license.Description)) + { + @license.Description + } + + @if (!string.IsNullOrWhiteSpace(license.LinkUrl)) + { + + + مشاهده جزئیات + + + } + + + } + + } + else + { + + اطلاعات مجوزها به‌زودی بارگذاری خواهد شد. + + } + +
+ + +
+ + + + نیاز به اطلاعات بیشتر دارید؟ + + برای دریافت اطلاعات بیشتر درباره مجوزها و گواهینامه‌های ما، با ما تماس بگیرید. + + + تماس با ما + + + +
+ +
+} diff --git a/src/FrontOffice.Main/Pages/Licenses.razor.cs b/src/FrontOffice.Main/Pages/Licenses.razor.cs new file mode 100644 index 0000000..89f8fa0 --- /dev/null +++ b/src/FrontOffice.Main/Pages/Licenses.razor.cs @@ -0,0 +1,31 @@ +using FrontOffice.Main.Utilities; + +namespace FrontOffice.Main.Pages; + +public partial class Licenses +{ + private bool _loading = true; + private PageSettingsDto? _pageData; + private List _licenseImages = new(); + + protected override async Task OnInitializedAsync() + { + try + { + _pageData = await PageSettingsService.GetPageAsync("licenses"); + + if (_pageData != null) + { + _licenseImages = _pageData.GetImages("licenses"); + } + } + catch + { + // Fallback: page remains null → hardcoded content will render + } + finally + { + _loading = false; + } + } +} diff --git a/src/FrontOffice.Main/Shared/Footer.razor b/src/FrontOffice.Main/Shared/Footer.razor index 4b88d89..71f1637 100644 --- a/src/FrontOffice.Main/Shared/Footer.razor +++ b/src/FrontOffice.Main/Shared/Footer.razor @@ -55,6 +55,7 @@ سوالات متداول ارتباط با ما درباره ما + مجوزها diff --git a/src/FrontOffice.Main/Shared/MainLayout.razor b/src/FrontOffice.Main/Shared/MainLayout.razor index 8766d9d..0f0f72d 100644 --- a/src/FrontOffice.Main/Shared/MainLayout.razor +++ b/src/FrontOffice.Main/Shared/MainLayout.razor @@ -73,6 +73,7 @@ بلاگ ارتباط با ما درباره ما + مجوزها
@@ -191,6 +192,9 @@ ارتباط با ما + + مجوزها + @if (_isAuthenticated) diff --git a/src/FrontOffice.Main/Utilities/RouteConstants.cs b/src/FrontOffice.Main/Utilities/RouteConstants.cs index f83d29c..7fd1f65 100644 --- a/src/FrontOffice.Main/Utilities/RouteConstants.cs +++ b/src/FrontOffice.Main/Utilities/RouteConstants.cs @@ -67,6 +67,11 @@ public static class RouteConstants public const string Index = "/contact"; } + public static class Licenses + { + public const string Index = "/licenses"; + } + public static class Blog { public const string Index = "/blog"; diff --git a/src/FrontOffice.Main/Utilities/SitePageSettingsService.cs b/src/FrontOffice.Main/Utilities/SitePageSettingsService.cs new file mode 100644 index 0000000..86b5b29 --- /dev/null +++ b/src/FrontOffice.Main/Utilities/SitePageSettingsService.cs @@ -0,0 +1,125 @@ +using System.Text.Json; +using CMSMicroservice.Protobuf.Protos.SitePageSettings; + +namespace FrontOffice.Main.Utilities; + +/// +/// سرویس ساده‌شده مدیریت صفحات سایت +/// ۴ صفحه ثابت: landing, about, contact, licenses +/// +public class SitePageSettingsService +{ + private readonly SitePageSettingsContract.SitePageSettingsContractClient _client; + + public SitePageSettingsService(SitePageSettingsContract.SitePageSettingsContractClient client) + { + _client = client; + } + + /// + /// دریافت تنظیمات صفحه با کلید + /// + public async Task GetPageAsync(string pageKey) + { + try + { + var response = await _client.GetPageSettingsAsync( + new GetPageSettingsRequest { PageKey = pageKey }); + + if (response == null || response.Id <= 0) return null; + + return MapToDto(response); + } + catch (Exception ex) + { +#if DEBUG + Console.WriteLine($"SitePageSettingsService.GetPageAsync error: {ex.Message}"); +#endif + return null; + } + } + + private static PageSettingsDto MapToDto(PageSettingsResponse response) => new() + { + Id = response.Id, + PageKey = response.PageKey, + Title = response.Title, + MetaDescription = response.MetaDescription, + HeroTitle = response.HeroTitle, + HeroSubtitle = response.HeroSubtitle, + HeroImagePath = response.HeroImagePath, + IsActive = response.IsActive, + SettingsJson = response.SettingsJson, + Images = response.Images.Select(i => new PageSettingsImageDto + { + Id = i.Id, + ImageGroup = i.ImageGroup, + Title = i.Title, + Subtitle = i.Subtitle, + Description = i.Description, + ImagePath = i.ImagePath, + ThumbnailPath = i.ThumbnailPath, + LinkUrl = i.LinkUrl, + IconName = i.IconName, + SortOrder = i.SortOrder, + IsActive = i.IsActive + }).OrderBy(i => i.SortOrder).ToList() + }; +} + +// ── DTOs ── + +public class PageSettingsDto +{ + public long Id { get; set; } + public string PageKey { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public string? MetaDescription { get; set; } + public string? HeroTitle { get; set; } + public string? HeroSubtitle { get; set; } + public string? HeroImagePath { get; set; } + public bool IsActive { get; set; } + public string? SettingsJson { get; set; } + public List Images { get; set; } = new(); + + /// + /// دریافت تصاویر یک گروه خاص + /// + public List GetImages(string group) => + Images.Where(i => i.ImageGroup == group && i.IsActive) + .OrderBy(i => i.SortOrder).ToList(); + + /// + /// دریافت تنظیمات JSON به عنوان یک نوع مشخص + /// + public T? GetSettings() where T : class + { + if (string.IsNullOrWhiteSpace(SettingsJson)) return null; + try + { + return JsonSerializer.Deserialize(SettingsJson, new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }); + } + catch + { + return null; + } + } +} + +public class PageSettingsImageDto +{ + public long Id { get; set; } + public string ImageGroup { get; set; } = string.Empty; + public string? Title { get; set; } + public string? Subtitle { get; set; } + public string? Description { get; set; } + public string ImagePath { get; set; } = string.Empty; + public string? ThumbnailPath { get; set; } + public string? LinkUrl { get; set; } + public string? IconName { get; set; } + public int SortOrder { get; set; } + public bool IsActive { get; set; } +}