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:
@@ -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