a bunch of stuff
This commit is contained in:
111
Components/Pages/admin/EditPages.razor
Normal file
111
Components/Pages/admin/EditPages.razor
Normal file
@@ -0,0 +1,111 @@
|
||||
@page "/admin/editpages"
|
||||
@rendermode InteractiveServer
|
||||
|
||||
<div class="admin-wrapper">
|
||||
<div class="container">
|
||||
<header class="admin-header">
|
||||
<h1>Page Content Management</h1>
|
||||
<p>Update your business details and home page content below.</p>
|
||||
</header>
|
||||
|
||||
@if (HomePageModel == null)
|
||||
{
|
||||
<div class="loading-state">
|
||||
<div class="spinner"></div>
|
||||
<p>Loading your settings...</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="admin-wrapper">
|
||||
<div class="container">
|
||||
<header class="admin-header">
|
||||
<div class="tab-container">
|
||||
<button class="tab-btn @(currentTab == AdminTab.Home ? "active" : "")"
|
||||
@onclick="() => currentTab = AdminTab.Home">
|
||||
Home Page
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@if (currentTab == AdminTab.Home)
|
||||
{
|
||||
<EditForm FormName="HomePageForm" Model="HomePageModel" OnValidSubmit="SaveHomePageModel" On class="admin-form home-page-form">
|
||||
<DataAnnotationsValidator />
|
||||
|
||||
<div class="form-section text-center">
|
||||
<h3><i class="icon">🏠</i> Hero Section</h3>
|
||||
|
||||
<div class="input-group">
|
||||
<label>Main Headline</label>
|
||||
<InputText @bind-Value="HomePageModel.HeaderLine1" class="form-input" />
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label>Highlighted Text (Green)</label>
|
||||
<InputText @bind-Value="HomePageModel.HeaderLine2" class="form-input" />
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label>Description Text</label>
|
||||
<InputTextArea @bind-Value="HomePageModel.HeaderText" class="form-input" rows="3" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-section text-center">
|
||||
<h3><i class="icon">🛠️</i> Services</h3>
|
||||
<div class="cards-grid">
|
||||
@foreach (var card in HomePageModel.ServicesCards)
|
||||
{
|
||||
<div class="content-card">
|
||||
<div class="input-group">
|
||||
<label>Header</label>
|
||||
<InputTextArea @bind-Value="card.Header" class="form-input" />
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label>Text</label>
|
||||
<InputTextArea @bind-Value="card.Text" class="form-input" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<button type="button" class="btn btn-save" @onclick="AddServiceCard">Add Service Card</button>
|
||||
</div>
|
||||
|
||||
<div class="form-section text-center">
|
||||
<h3><i class="icon">🛡️</i> Trust</h3>
|
||||
<div class="cards-grid">
|
||||
@foreach (var card in HomePageModel.TrustCards)
|
||||
{
|
||||
<div class="content-card">
|
||||
<div class="input-group">
|
||||
<label>Header</label>
|
||||
<InputTextArea @bind-Value="card.Header" class="form-input" />
|
||||
</div>
|
||||
|
||||
<div class="input-group">
|
||||
<label>Text</label>
|
||||
<InputTextArea @bind-Value="card.Text" class="form-input" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<button type="button" class="btn btn-save" @onclick="AddTrustCard">Add Trust Card</button>
|
||||
</div>
|
||||
|
||||
<div class="admin-footer">
|
||||
<button type="submit" class="btn btn-save">Save</button>
|
||||
<button type="button" class="btn btn-revert" @onclick="RevertHomePageModel">Revert</button>
|
||||
</div>
|
||||
</EditForm>
|
||||
}
|
||||
else
|
||||
{
|
||||
<h1>Another page</h1>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
64
Components/Pages/admin/EditPages.razor.cs
Normal file
64
Components/Pages/admin/EditPages.razor.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
namespace ApplianceRepair.Components.Pages.admin
|
||||
{
|
||||
public partial class EditPages(HomePageReader homePageReader, ContentCardReader contentCardReader)
|
||||
{
|
||||
public HomePageModel? HomePageModel;
|
||||
|
||||
private enum AdminTab { Home, About }
|
||||
private AdminTab currentTab = AdminTab.Home;
|
||||
|
||||
override
|
||||
protected async void OnInitialized()
|
||||
{
|
||||
HomePageModel = await homePageReader.ReadLatestRecordWithModel(contentCardReader) ?? Defaults.DefaultHomePageContent;
|
||||
}
|
||||
|
||||
private async void RevertHomePageModel()
|
||||
{
|
||||
HomePageModel = await homePageReader.ReadLatestRecordWithModel(contentCardReader) ?? Defaults.DefaultHomePageContent;
|
||||
}
|
||||
|
||||
private async void SaveHomePageModel()
|
||||
{
|
||||
HomePageModel.CreatedAt = DateTime.Now;
|
||||
HomePageModel.UpdatedAt = DateTime.Now;
|
||||
|
||||
foreach (var card in HomePageModel.ServicesCards)
|
||||
{
|
||||
await contentCardReader.UpdateRecord(card);
|
||||
}
|
||||
|
||||
foreach (var card in HomePageModel.TrustCards)
|
||||
{
|
||||
await contentCardReader.UpdateRecord(card);
|
||||
}
|
||||
|
||||
await homePageReader.AddRecord(HomePageModel);
|
||||
}
|
||||
|
||||
private void AddServiceCard()
|
||||
{
|
||||
HomePageModel?.ServicesCards.Add(new ContentCardModel() {
|
||||
CreatedAt = DateTime.Now,
|
||||
UpdatedAt = DateTime.Now,
|
||||
BelongsToPage = HomePageModel.PageName,
|
||||
Group = HomePageModel.ContentCardTypes.Service.ToString(),
|
||||
Header = "Service Name",
|
||||
Text = "Short Description"
|
||||
});
|
||||
}
|
||||
|
||||
private async void AddTrustCard()
|
||||
{
|
||||
HomePageModel?.TrustCards.Add(new ContentCardModel()
|
||||
{
|
||||
CreatedAt = DateTime.Now,
|
||||
UpdatedAt = DateTime.Now,
|
||||
BelongsToPage = HomePageModel.PageName,
|
||||
Group = HomePageModel.ContentCardTypes.Trust.ToString(),
|
||||
Header = "Header",
|
||||
Text = "Short Description"
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
240
Components/Pages/admin/EditPages.razor.css
Normal file
240
Components/Pages/admin/EditPages.razor.css
Normal file
@@ -0,0 +1,240 @@
|
||||
.admin-wrapper {
|
||||
background-color: #f4f7f6;
|
||||
min-height: 100vh;
|
||||
padding: 60px 0;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
}
|
||||
|
||||
.admin-header {
|
||||
text-align: center;
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.admin-footer {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.tab-container {
|
||||
display: inline-flex;
|
||||
background: #e0e6ed;
|
||||
padding: 5px;
|
||||
border-radius: 50px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.tab-btn {
|
||||
padding: 10px 25px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
border-radius: 50px;
|
||||
transition: all 0.3s ease;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.tab-btn.active {
|
||||
background: #2a5298; /* Your Trust Blue */
|
||||
color: white;
|
||||
box-shadow: 0 4px 10px rgba(42, 82, 152, 0.2);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
color: #2a5298;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
background: #fff;
|
||||
padding: 100px;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 10px 30px rgba(0,0,0,0.05);
|
||||
margin-bottom: 30px;
|
||||
border: 1px solid #f0f0f0;
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
}
|
||||
|
||||
.text-center {
|
||||
text-align: center;
|
||||
max-width: 70vw;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.form-section h3 {
|
||||
color: #2a5298;
|
||||
margin-bottom: 20px;
|
||||
font-size: 1.2rem;
|
||||
border-bottom: 2px solid #f4f7f6;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.input-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
font-weight: 600;
|
||||
font-size: 0.85rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: #2a5298;
|
||||
margin-bottom: 8px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.cards-grid {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
column-gap: 2rem;
|
||||
|
||||
padding-top: 2rem;
|
||||
padding-bottom: 2rem;
|
||||
}
|
||||
|
||||
.content-card {
|
||||
background: #fcfcfc;
|
||||
border: 1px solid #e0e6ed;
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
|
||||
transition: transform 0.2s ease;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.content-card:hover {
|
||||
border-color: #2a5298;
|
||||
box-shadow: 0 5px 15px rgba(0,0,0,0.05);
|
||||
}
|
||||
|
||||
.content-card .input-group {
|
||||
max-width: 100%;
|
||||
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
.content-card ::deep .form-input {
|
||||
max-width: 80%;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
::deep .form-input,
|
||||
::deep textarea.form-input {
|
||||
width: 100%;
|
||||
padding: 14px 18px;
|
||||
font-size: 1rem;
|
||||
font-family: 'Open Sans', sans-serif;
|
||||
color: #444;
|
||||
background-color: #ffffff;
|
||||
border: 2px solid #e0e6ed;
|
||||
border-radius: 12px;
|
||||
transition: all 0.2s ease-in-out;
|
||||
display: block;
|
||||
box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
|
||||
}
|
||||
|
||||
::deep .form-input:focus,
|
||||
::deep textarea.form-input:focus {
|
||||
outline: none;
|
||||
border-color: #2a5298;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 0 0 4px rgba(42, 82, 152, 0.1);
|
||||
}
|
||||
|
||||
::deep textarea.form-input {
|
||||
min-height: 120px;
|
||||
resize: vertical;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
background: #4CAF50;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 15px 40px;
|
||||
border-radius: 50px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
|
||||
transition: all 0.3s ease;
|
||||
max-width: 10vw;
|
||||
}
|
||||
|
||||
.btn-save:hover {
|
||||
transform: translateY(-2px);
|
||||
background: #43a047;
|
||||
}
|
||||
|
||||
.btn-revert {
|
||||
background: transparent;
|
||||
color: #666;
|
||||
border: 2px solid #ccc;
|
||||
padding: 15px 30px;
|
||||
border-radius: 50px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
margin-left: 10px;
|
||||
max-width: 30vw;
|
||||
}
|
||||
|
||||
.btn-revert:hover {
|
||||
background: #eee;
|
||||
color: #333;
|
||||
border-color: #999;
|
||||
}
|
||||
|
||||
.status-msg {
|
||||
margin-left: 20px;
|
||||
color: #4CAF50;
|
||||
font-weight: 600;
|
||||
animation: fadeIn 0.5s ease;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.input-row {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.btn-save {
|
||||
max-width: 40vw;
|
||||
}
|
||||
|
||||
.btn-revert {
|
||||
max-width: 40vw;
|
||||
}
|
||||
|
||||
.cards-grid {
|
||||
flex-direction: column;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
row-gap: 2rem;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user