refactor: migrate About & Contact pages to SitePageSettings system
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 6m58s
Build and Deploy to Kubernetes / build-and-deploy (push) Successful in 6m58s
- About.razor: use SitePageSettingsService + GetSettings<AboutSettings>() - About.razor.cs: read values/team from ImageGroups instead of SitePage sections - Contact.razor: use SitePageSettingsService + GetSettings<ContactSettings>() - Contact.razor.cs: read address/phone/email/social from SettingsJson
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
@attribute [Route(RouteConstants.About.Index)]
|
||||
@inject NavigationManager Navigation
|
||||
@inject SitePageService SitePageService
|
||||
@inject SitePageSettingsService PageSettingsService
|
||||
|
||||
<PageTitle>درباره ما | کارا بازار سلامت</PageTitle>
|
||||
|
||||
@@ -66,40 +66,22 @@ else
|
||||
<MudPaper Elevation="2" Class="pa-6 text-center h-100">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Visibility" Size="Size.Large" Color="Color.Primary" Class="mb-4" />
|
||||
<MudText Typo="Typo.h5" Class="mb-3">
|
||||
@(_visionSection?.Title ?? "چشمانداز")
|
||||
@(_settings?.VisionTitle ?? "چشمانداز")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body1" Class="mud-text-secondary">
|
||||
@(_settings?.VisionText ?? "تبدیل شدن به پیشروترین پلتفرم مدیریت تیمهای فروش در منطقه، با ارائه راهکارهای هوشمند و کاربرپسند برای کسبوکارهای کوچک و بزرگ.")
|
||||
</MudText>
|
||||
@if (!string.IsNullOrWhiteSpace(_visionSection?.HtmlContent))
|
||||
{
|
||||
<MudText Typo="Typo.body1" Class="mud-text-secondary">
|
||||
@((MarkupString)_visionSection.HtmlContent)
|
||||
</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body1" Class="mud-text-secondary">
|
||||
تبدیل شدن به پیشروترین پلتفرم مدیریت تیمهای فروش در منطقه، با ارائه راهکارهای هوشمند و کاربرپسند برای کسبوکارهای کوچک و بزرگ.
|
||||
</MudText>
|
||||
}
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudPaper Elevation="2" Class="pa-6 text-center h-100">
|
||||
<MudIcon Icon="@Icons.Material.Filled.TrackChanges" Size="Size.Large" Color="Color.Success" Class="mb-4" />
|
||||
<MudText Typo="Typo.h5" Class="mb-3">
|
||||
@(_missionSection?.Title ?? "مأموریت")
|
||||
@(_settings?.MissionTitle ?? "مأموریت")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body1" Class="mud-text-secondary">
|
||||
@(_settings?.MissionText ?? "توانمندسازی کسبوکارها از طریق فناوریهای نوین، سادهسازی فرآیندهای پیچیده و ایجاد فرصتهای جدید برای رشد و توسعه پایدار.")
|
||||
</MudText>
|
||||
@if (!string.IsNullOrWhiteSpace(_missionSection?.HtmlContent))
|
||||
{
|
||||
<MudText Typo="Typo.body1" Class="mud-text-secondary">
|
||||
@((MarkupString)_missionSection.HtmlContent)
|
||||
</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body1" Class="mud-text-secondary">
|
||||
توانمندسازی کسبوکارها از طریق فناوریهای نوین، سادهسازی فرآیندهای پیچیده و ایجاد کارا بازار سلامتهای جدید برای رشد و توسعه پایدار.
|
||||
</MudText>
|
||||
}
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@@ -111,21 +93,21 @@ else
|
||||
<MudContainer MaxWidth="MaxWidth.Large">
|
||||
<MudText Typo="Typo.h3" Align="Align.Center" Class="mb-8">ارزشهای ما</MudText>
|
||||
<MudGrid Spacing="3" Justify="Justify.Center">
|
||||
@if (_valueSections.Any())
|
||||
@if (_valueImages.Any())
|
||||
{
|
||||
@foreach (var value in _valueSections)
|
||||
@foreach (var value in _valueImages)
|
||||
{
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudPaper Elevation="2" Class="pa-4 rounded-xl text-center">
|
||||
@if (!string.IsNullOrWhiteSpace(value.IconName))
|
||||
{
|
||||
<MudIcon Icon="@value.IconName" Size="Size.Large" Color="Color.Primary" Class="mb-3" />
|
||||
<MudIcon Icon="@($"Icons.Material.Filled.{value.IconName}")" Size="Size.Large" Color="Color.Primary" Class="mb-3" />
|
||||
}
|
||||
<MudText Typo="Typo.h6" Class="mb-2">@value.Title</MudText>
|
||||
@if (!string.IsNullOrWhiteSpace(value.HtmlContent))
|
||||
@if (!string.IsNullOrWhiteSpace(value.Description))
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary">
|
||||
@((MarkupString)value.HtmlContent)
|
||||
@value.Description
|
||||
</MudText>
|
||||
}
|
||||
</MudPaper>
|
||||
@@ -199,9 +181,9 @@ else
|
||||
<MudContainer MaxWidth="MaxWidth.Large">
|
||||
<MudText Typo="Typo.h3" Align="Align.Center" Class="mb-8">تیم ما</MudText>
|
||||
<MudGrid Spacing="4" Justify="Justify.Center">
|
||||
@if (_teamSections.Any())
|
||||
@if (_teamImages.Any())
|
||||
{
|
||||
@foreach (var member in _teamSections)
|
||||
@foreach (var member in _teamImages)
|
||||
{
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudPaper Elevation="2" Class="pa-4 text-center">
|
||||
@@ -222,10 +204,10 @@ else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="mud-text-secondary mb-2">@member.Subtitle</MudText>
|
||||
}
|
||||
@if (!string.IsNullOrWhiteSpace(member.HtmlContent))
|
||||
@if (!string.IsNullOrWhiteSpace(member.Description))
|
||||
{
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||
@((MarkupString)member.HtmlContent)
|
||||
@member.Description
|
||||
</MudText>
|
||||
}
|
||||
</MudPaper>
|
||||
|
||||
@@ -5,24 +5,22 @@ namespace FrontOffice.Main.Pages;
|
||||
public partial class About
|
||||
{
|
||||
private bool _loading = true;
|
||||
private SitePageDto? _page;
|
||||
private SitePageSectionDto? _visionSection;
|
||||
private SitePageSectionDto? _missionSection;
|
||||
private List<SitePageSectionDto> _valueSections = new();
|
||||
private List<SitePageSectionDto> _teamSections = new();
|
||||
private PageSettingsDto? _page;
|
||||
private AboutSettings? _settings;
|
||||
private List<PageSettingsImageDto> _valueImages = new();
|
||||
private List<PageSettingsImageDto> _teamImages = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
_page = await SitePageService.GetByKeyAsync("about");
|
||||
_page = await PageSettingsService.GetPageAsync("about");
|
||||
|
||||
if (_page != null)
|
||||
{
|
||||
_visionSection = _page.GetSection("vision");
|
||||
_missionSection = _page.GetSection("mission");
|
||||
_valueSections = _page.GetSections("value-").ToList();
|
||||
_teamSections = _page.GetSections("team-").ToList();
|
||||
_settings = _page.GetSettings<AboutSettings>();
|
||||
_valueImages = _page.GetImages("values");
|
||||
_teamImages = _page.GetImages("team");
|
||||
}
|
||||
}
|
||||
catch
|
||||
@@ -34,4 +32,16 @@ public partial class About
|
||||
_loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private class AboutSettings
|
||||
{
|
||||
public string? VisionTitle { get; set; }
|
||||
public string? VisionText { get; set; }
|
||||
public string? VisionIcon { get; set; }
|
||||
public string? MissionTitle { get; set; }
|
||||
public string? MissionText { get; set; }
|
||||
public string? MissionIcon { get; set; }
|
||||
public string? ValuesTitle { get; set; }
|
||||
public string? TeamTitle { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
@attribute [Route(RouteConstants.Contact.Index)]
|
||||
@inject SitePageService SitePageService
|
||||
@inject SitePageSettingsService PageSettingsService
|
||||
|
||||
<PageTitle>ارتباط با ما | کارا بازار سلامت</PageTitle>
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
<div>
|
||||
<MudText Typo="Typo.body2" >آدرس</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||
@(_contactAddress ?? "کرج مهرویلا میدان مادر ساختمان بزرگمهر طبقه ۴ واحد ۱۶")
|
||||
@(_settings?.Address ?? "کرج مهرویلا میدان مادر ساختمان بزرگمهر طبقه ۴ واحد ۱۶")
|
||||
</MudText>
|
||||
</div>
|
||||
</MudStack>
|
||||
@@ -142,7 +142,7 @@
|
||||
<MudIcon Icon="@Icons.Material.Filled.Phone" Color="Color.Success" Size="Size.Large" />
|
||||
<div>
|
||||
<MudText Typo="Typo.body2" >تلفن</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@(_contactPhone ?? "026-34233563")</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@(_settings?.Phone ?? "026-34233563")</MudText>
|
||||
</div>
|
||||
</MudStack>
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
<MudIcon Icon="@Icons.Material.Filled.Email" Color="Color.Info" Size="Size.Large" />
|
||||
<div>
|
||||
<MudText Typo="Typo.body2" >ایمیل</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@(_contactEmail ?? "info@kbs1.co")</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">@(_settings?.Email ?? "info@kbs1.co")</MudText>
|
||||
</div>
|
||||
</MudStack>
|
||||
|
||||
@@ -159,7 +159,7 @@
|
||||
<div>
|
||||
<MudText Typo="Typo.body2" >ساعات کاری</MudText>
|
||||
<MudText Typo="Typo.caption" Class="mud-text-secondary">
|
||||
@((MarkupString)(_contactHours ?? "شنبه تا پنجشنبه<br />۹ صبح تا ۶ عصر"))
|
||||
@((MarkupString)(_settings?.WorkingHours ?? "شنبه تا پنجشنبه<br />۹ صبح تا ۶ عصر"))
|
||||
</MudText>
|
||||
</div>
|
||||
</MudStack>
|
||||
@@ -174,7 +174,7 @@
|
||||
<MudButton Variant="Variant.Outlined"
|
||||
Color="Color.Inherit"
|
||||
StartIcon="@Icons.Custom.Brands.Telegram"
|
||||
Href="@(_socialTelegram ?? "https://t.me/kbs1")"
|
||||
Href="@(_settings?.TelegramUrl ?? "https://t.me/kbs1")"
|
||||
Target="_blank"
|
||||
FullWidth="true">
|
||||
تلگرام
|
||||
@@ -183,7 +183,7 @@
|
||||
<MudButton Variant="Variant.Outlined"
|
||||
Color="Color.Inherit"
|
||||
StartIcon="@Icons.Custom.Brands.Instagram"
|
||||
Href="@(_socialInstagram ?? "https://instagram.com/kbs1")"
|
||||
Href="@(_settings?.InstagramUrl ?? "https://instagram.com/kbs1")"
|
||||
Target="_blank"
|
||||
FullWidth="true">
|
||||
اینستاگرام
|
||||
@@ -192,7 +192,7 @@
|
||||
<MudButton Variant="Variant.Outlined"
|
||||
Color="Color.Inherit"
|
||||
StartIcon="@Icons.Custom.Brands.LinkedIn"
|
||||
Href="@(_socialLinkedin ?? "https://linkedin.com/company/kbs1")"
|
||||
Href="@(_settings?.LinkedinUrl ?? "https://linkedin.com/company/kbs1")"
|
||||
Target="_blank"
|
||||
FullWidth="true">
|
||||
لینکدین
|
||||
@@ -201,7 +201,7 @@
|
||||
<MudButton Variant="Variant.Outlined"
|
||||
Color="Color.Inherit"
|
||||
StartIcon="@Icons.Custom.Brands.WhatsApp"
|
||||
Href="@(_socialWhatsapp ?? "https://wa.me/989123456789")"
|
||||
Href="@(_settings?.WhatsappUrl ?? "https://wa.me/989123456789")"
|
||||
Target="_blank"
|
||||
FullWidth="true">
|
||||
واتساپ
|
||||
@@ -226,7 +226,7 @@
|
||||
<MudIcon Icon="@Icons.Material.Filled.Map" Size="Size.Large" Style="color: white;" />
|
||||
<MudText Typo="Typo.h6" Style="color: white;">نقشه موقعیت مکانی</MudText>
|
||||
<MudText Typo="Typo.body2" Style="color: rgba(255,255,255,0.8);" Align="Align.Center">
|
||||
@(_contactAddress ?? "کرج مهرویلا میدان مادر ساختمان بزرگمهر طبقه ۴ واحد ۱۶")
|
||||
@(_settings?.Address ?? "کرج مهرویلا میدان مادر ساختمان بزرگمهر طبقه ۴ واحد ۱۶")
|
||||
</MudText>
|
||||
</MudStack>
|
||||
</div>
|
||||
|
||||
@@ -12,52 +12,19 @@ public partial class Contact
|
||||
private bool _isSubmitting;
|
||||
private readonly ContactFormValidator _contactFormValidator = new();
|
||||
|
||||
// Dynamic CMS data
|
||||
private SitePageDto? _page;
|
||||
private string? _contactAddress;
|
||||
private string? _contactPhone;
|
||||
private string? _contactEmail;
|
||||
private string? _contactHours;
|
||||
private string? _socialTelegram;
|
||||
private string? _socialInstagram;
|
||||
private string? _socialLinkedin;
|
||||
private string? _socialWhatsapp;
|
||||
// Dynamic CMS data (new simplified system)
|
||||
private PageSettingsDto? _page;
|
||||
private ContactSettings? _settings;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
_page = await SitePageService.GetByKeyAsync("contact");
|
||||
_page = await PageSettingsService.GetPageAsync("contact");
|
||||
|
||||
if (_page != null)
|
||||
{
|
||||
// Load contact info from CMS section
|
||||
var contactInfoSection = _page.GetSection("contact-info");
|
||||
if (contactInfoSection != null)
|
||||
{
|
||||
var contactData = contactInfoSection.GetExtraData<ContactInfoData>();
|
||||
if (contactData != null)
|
||||
{
|
||||
_contactAddress = contactData.Address;
|
||||
_contactPhone = contactData.Phone;
|
||||
_contactEmail = contactData.Email;
|
||||
_contactHours = contactData.Hours;
|
||||
}
|
||||
}
|
||||
|
||||
// Load social media links from CMS section
|
||||
var socialSection = _page.GetSection("social-media");
|
||||
if (socialSection != null)
|
||||
{
|
||||
var socialData = socialSection.GetExtraData<SocialMediaData>();
|
||||
if (socialData != null)
|
||||
{
|
||||
_socialTelegram = socialData.Telegram;
|
||||
_socialInstagram = socialData.Instagram;
|
||||
_socialLinkedin = socialData.Linkedin;
|
||||
_socialWhatsapp = socialData.Whatsapp;
|
||||
}
|
||||
}
|
||||
_settings = _page.GetSettings<ContactSettings>();
|
||||
}
|
||||
}
|
||||
catch
|
||||
@@ -111,12 +78,12 @@ public partial class Contact
|
||||
|
||||
private void CallSupport()
|
||||
{
|
||||
Snackbar.Add($"شماره تماس: {_contactPhone ?? "026-34233563"}", Severity.Info);
|
||||
Snackbar.Add($"شماره تماس: {_settings?.Phone ?? "026-34233563"}", Severity.Info);
|
||||
}
|
||||
|
||||
private void SendEmail()
|
||||
{
|
||||
Snackbar.Add($"ایمیل: {_contactEmail ?? "info@kbs1.co"}", Severity.Info);
|
||||
Snackbar.Add($"ایمیل: {_settings?.Email ?? "info@kbs1.co"}", Severity.Info);
|
||||
}
|
||||
|
||||
public class ContactForm
|
||||
@@ -142,20 +109,16 @@ public partial class Contact
|
||||
}
|
||||
}
|
||||
|
||||
// DTO classes for ExtraData JSON deserialization
|
||||
private class ContactInfoData
|
||||
// DTO class for SettingsJson deserialization
|
||||
private class ContactSettings
|
||||
{
|
||||
public string? Address { get; set; }
|
||||
public string? Phone { get; set; }
|
||||
public string? Email { get; set; }
|
||||
public string? Hours { get; set; }
|
||||
}
|
||||
|
||||
private class SocialMediaData
|
||||
{
|
||||
public string? Telegram { get; set; }
|
||||
public string? Instagram { get; set; }
|
||||
public string? Linkedin { get; set; }
|
||||
public string? Whatsapp { get; set; }
|
||||
public string? WorkingHours { get; set; }
|
||||
public string? TelegramUrl { get; set; }
|
||||
public string? InstagramUrl { get; set; }
|
||||
public string? LinkedinUrl { get; set; }
|
||||
public string? WhatsappUrl { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user