feat/live-preview #8
@ -114,13 +114,14 @@ public class PaymentController : Controller
|
||||
// Parse do plano atual (mesmo que o Dashboard)
|
||||
var userPlanType = Enum.TryParse<PlanType>(user.CurrentPlan, true, out var planType) ? planType : PlanType.Trial;
|
||||
var currentPlanString = userPlanType.ToString().ToLower();
|
||||
|
||||
var subscription = await _subscriptionRepository.GetByUserIdAsync(user.Id);
|
||||
var viewModel = new ManageSubscriptionViewModel
|
||||
{
|
||||
User = user,
|
||||
StripeSubscription = await _paymentService.GetSubscriptionDetailsAsync(user.Id),
|
||||
PaymentHistory = await _paymentService.GetPaymentHistoryAsync(user.Id),
|
||||
AvailablePlans = GetAvailablePlans(currentPlanString)
|
||||
AvailablePlans = GetAvailablePlans(currentPlanString),
|
||||
CurrentPeriodEnd = (DateTime?) subscription.CurrentPeriodEnd
|
||||
};
|
||||
|
||||
// Pegar assinatura local se existir
|
||||
|
||||
@ -87,7 +87,7 @@ builder.Services.AddAuthentication(options =>
|
||||
{
|
||||
OnRedirectToAuthorizationEndpoint = context =>
|
||||
{
|
||||
context.Response.Redirect(context.RedirectUri + "&prompt=select_account");
|
||||
context.Response.Redirect(context.RedirectUri + "&prompt=login");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
};
|
||||
|
||||
@ -19,7 +19,7 @@ public class ManageSubscriptionViewModel
|
||||
public bool CanDowngrade => HasActiveSubscription && User.CurrentPlan != "basic";
|
||||
public bool WillCancelAtPeriodEnd => StripeSubscription?.CancelAtPeriodEnd == true;
|
||||
|
||||
public DateTime? CurrentPeriodEnd => null;
|
||||
public DateTime? CurrentPeriodEnd { get; set; }
|
||||
public DateTime? NextBillingDate => !WillCancelAtPeriodEnd ? CurrentPeriodEnd : null;
|
||||
|
||||
public decimal? MonthlyAmount => StripeSubscription?.Items?.Data?.FirstOrDefault()?.Price?.UnitAmount / 100m;
|
||||
|
||||
@ -93,13 +93,15 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="d-flex gap-1 align-items-center" data-page-id="@pageItem.Id" data-status="@pageItem.Status">
|
||||
<!-- Botão Ver - sempre presente quando possível -->
|
||||
</div>
|
||||
<!-- Cards com Hover Effect -->
|
||||
<div class="card-footer" data-page-id="@pageItem.Id" data-status="@pageItem.Status">
|
||||
<div class="d-flex gap-2">
|
||||
@if (pageItem.Status == BCards.Web.ViewModels.PageStatus.Active)
|
||||
{
|
||||
<a href="/page/@pageItem.Category/@pageItem.Slug" target="_blank"
|
||||
class="btn btn-sm btn-success">
|
||||
<i class="fas fa-external-link-alt me-1"></i>Ver
|
||||
class="btn btn-success flex-fill">
|
||||
<i class="fas fa-eye me-1"></i>Ver Página
|
||||
</a>
|
||||
}
|
||||
else if (pageItem.Status == BCards.Web.ViewModels.PageStatus.Creating ||
|
||||
@ -107,24 +109,30 @@
|
||||
pageItem.Status == BCards.Web.ViewModels.PageStatus.PendingModeration)
|
||||
{
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-outline-info"
|
||||
class="btn btn-outline-info flex-fill"
|
||||
onclick="openPreview('@pageItem.Id')"
|
||||
data-page-category="@pageItem.Category"
|
||||
data-page-slug="@pageItem.Slug">
|
||||
<i class="fas fa-eye me-1"></i>Testar
|
||||
<i class="fas fa-vial me-1"></i>Testar Página
|
||||
</button>
|
||||
}
|
||||
|
||||
<!-- Dropdown para outras ações -->
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-sm btn-outline-secondary dropdown-toggle"
|
||||
else
|
||||
{
|
||||
<button class="btn btn-secondary flex-fill" disabled>
|
||||
<i class="fas fa-ban me-1"></i>Indisponível
|
||||
</button>
|
||||
}
|
||||
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-outline-secondary dropdown-toggle"
|
||||
type="button"
|
||||
id="dropdownMenuButton@(pageItem.Id)"
|
||||
data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
Ações
|
||||
aria-expanded="false"
|
||||
title="Mais opções">
|
||||
<i class="fas fa-cog"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton@(pageItem.Id)">
|
||||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="dropdownMenuButton@(pageItem.Id)">
|
||||
<!-- Editar - sempre presente -->
|
||||
@if (pageItem.Status == BCards.Web.ViewModels.PageStatus.PendingModeration)
|
||||
{
|
||||
@ -144,7 +152,6 @@
|
||||
</li>
|
||||
}
|
||||
|
||||
|
||||
@if (pageItem.Status == BCards.Web.ViewModels.PageStatus.Creating ||
|
||||
pageItem.Status == BCards.Web.ViewModels.PageStatus.Rejected)
|
||||
{
|
||||
@ -170,36 +177,38 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer bg-transparent">
|
||||
<small class="text-muted">Criada em @(pageItem.CreatedAt.ToString("dd/MM/yyyy"))</small>
|
||||
@if ((pageItem.LastModerationStatus ?? pageItem.Status) == BCards.Web.ViewModels.PageStatus.Rejected && !string.IsNullOrEmpty(pageItem.Motive))
|
||||
{
|
||||
<div class="alert alert-danger alert-dismissible fade show mt-2" role="alert">
|
||||
<div class="d-flex align-items-start">
|
||||
<i class="fas fa-exclamation-triangle me-2 mt-1"></i>
|
||||
<div class="flex-grow-1">
|
||||
<strong>Motivo da rejeição:</strong><br>
|
||||
<small>@(pageItem.Motive)</small>
|
||||
|
||||
<!-- Informações da página movidas para baixo dos botões -->
|
||||
<div class="px-3 pt-2 pb-1">
|
||||
<small class="text-muted">Criada em @(pageItem.CreatedAt.ToString("dd/MM/yyyy"))</small>
|
||||
|
||||
@if ((pageItem.LastModerationStatus ?? pageItem.Status) == BCards.Web.ViewModels.PageStatus.Rejected && !string.IsNullOrEmpty(pageItem.Motive))
|
||||
{
|
||||
<div class="alert alert-danger alert-dismissible fade show mt-2 mb-0" role="alert">
|
||||
<div class="d-flex align-items-start">
|
||||
<i class="fas fa-exclamation-triangle me-2 mt-1"></i>
|
||||
<div class="flex-grow-1">
|
||||
<strong>Motivo da rejeição:</strong><br>
|
||||
<small>@(pageItem.Motive)</small>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
}
|
||||
else if (pageItem.LastModerationStatus == BCards.Web.ViewModels.PageStatus.Active && !string.IsNullOrEmpty(pageItem.Motive))
|
||||
{
|
||||
<div class="alert alert-info alert-dismissible fade show mt-2" role="alert">
|
||||
<div class="d-flex align-items-start">
|
||||
<i class="fas fa-exclamation-triangle me-2 mt-1"></i>
|
||||
<div class="flex-grow-1">
|
||||
<strong>Motivo:</strong><br>
|
||||
<small>@(pageItem.Motive)</small>
|
||||
}
|
||||
else if (pageItem.LastModerationStatus == BCards.Web.ViewModels.PageStatus.Active && !string.IsNullOrEmpty(pageItem.Motive))
|
||||
{
|
||||
<div class="alert alert-info alert-dismissible fade show mt-2 mb-0" role="alert">
|
||||
<div class="d-flex align-items-start">
|
||||
<i class="fas fa-exclamation-triangle me-2 mt-1"></i>
|
||||
<div class="flex-grow-1">
|
||||
<strong>Motivo:</strong><br>
|
||||
<small>@(pageItem.Motive)</small>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -100,7 +100,7 @@
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<div class="btn-group" role="group">
|
||||
<div class="d-flex gap-2 flex-wrap">
|
||||
@if (!Model.WillCancelAtPeriodEnd)
|
||||
{
|
||||
<button type="button" class="btn btn-danger" data-bs-toggle="modal" data-bs-target="#cancelModal">
|
||||
@ -109,7 +109,7 @@
|
||||
</button>
|
||||
}
|
||||
|
||||
<form method="post" action="@Url.Action("OpenStripePortal")" style="display: inline;">
|
||||
<form method="post" action="@Url.Action("OpenStripePortal")" class="d-inline">
|
||||
<button type="submit" class="btn btn-outline-primary">
|
||||
<i class="fas fa-external-link-alt me-1"></i>
|
||||
Portal de Pagamento
|
||||
|
||||
@ -39,8 +39,76 @@
|
||||
<link rel="icon" type="image/x-icon" href="~/favicon.ico" />
|
||||
|
||||
@await RenderSectionAsync("Styles", required: false)
|
||||
|
||||
<!-- Estilos para menu ativo e barra de carregamento -->
|
||||
<style>
|
||||
/* Barra de carregamento moderna */
|
||||
#loading-bar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 0%;
|
||||
height: 3px;
|
||||
background: linear-gradient(90deg, #007bff, #0056b3, #007bff);
|
||||
background-size: 200% 100%;
|
||||
animation: loading-shimmer 1.5s infinite;
|
||||
z-index: 9999;
|
||||
transition: width 0.3s ease, opacity 0.3s ease;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
#loading-bar.active {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@@keyframes loading-shimmer {
|
||||
0% { background-position: -200% 0; }
|
||||
100% { background-position: 200% 0; }
|
||||
}
|
||||
|
||||
/* Destacar item ativo do menu */
|
||||
.nav-link.active {
|
||||
background-color: rgba(0, 123, 255, 0.1) !important;
|
||||
border-radius: 6px !important;
|
||||
font-weight: 600 !important;
|
||||
}
|
||||
|
||||
/* Para homepage (fundo azul) */
|
||||
.bg-home-blue .nav-link.active {
|
||||
background-color: rgba(255, 255, 255, 0.2) !important;
|
||||
}
|
||||
|
||||
/* Smooth transition para links */
|
||||
.nav-link {
|
||||
transition: all 0.2s ease;
|
||||
padding: 8px 12px !important;
|
||||
margin: 0 2px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
background-color: rgba(0, 123, 255, 0.05);
|
||||
}
|
||||
|
||||
.bg-home-blue .nav-link:hover {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
/* Suavizar transições de página */
|
||||
main {
|
||||
opacity: 1;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
main.page-loading {
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- Barra de carregamento -->
|
||||
<div id="loading-bar"></div>
|
||||
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light fixed-top @(ViewBag.IsHomePage == true ? "bg-home-blue" : "bg-dashboard")" id="mainNavbar">
|
||||
<div class="container-fluid">
|
||||
@ -155,6 +223,107 @@
|
||||
<script src="~/lib/jquery/jquery.min.js"></script>
|
||||
<script src="~/lib/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
|
||||
<!-- Scripts para menu ativo e barra de carregamento -->
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
// Destacar item ativo do menu baseado na URL atual
|
||||
highlightActiveMenuItem();
|
||||
|
||||
// Interceptar cliques em links de navegação
|
||||
setupLoadingBar();
|
||||
});
|
||||
|
||||
function highlightActiveMenuItem() {
|
||||
var currentPath = window.location.pathname.toLowerCase();
|
||||
var currentController = '@ViewContext.RouteData.Values["Controller"]?.ToString()?.ToLower()';
|
||||
var currentAction = '@ViewContext.RouteData.Values["Action"]?.ToString()?.ToLower()';
|
||||
|
||||
// Remover classes ativas existentes
|
||||
$('.nav-link').removeClass('active');
|
||||
|
||||
// Lógica para destacar o item correto
|
||||
$('.nav-link').each(function() {
|
||||
var link = $(this);
|
||||
var href = link.attr('href');
|
||||
|
||||
if (href) {
|
||||
var linkPath = href.toLowerCase();
|
||||
|
||||
// Verificar correspondência exata primeiro
|
||||
if (currentPath === linkPath ||
|
||||
(currentPath === '/' && linkPath.includes('/home')) ||
|
||||
(currentController === 'home' && currentAction === 'index' && linkPath.includes('/home')) ||
|
||||
(currentController === 'home' && currentAction === 'pricing' && linkPath.includes('pricing')) ||
|
||||
(currentController === 'admin' && linkPath.includes('dashboard')) ||
|
||||
(currentController === 'moderation' && linkPath.includes('moderation')) ||
|
||||
(currentController === 'auth' && linkPath.includes('login')) ||
|
||||
(currentController === 'payment' && linkPath.includes('managesubscription'))) {
|
||||
link.addClass('active');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setupLoadingBar() {
|
||||
var loadingBar = $('#loading-bar');
|
||||
|
||||
// Interceptar todos os cliques em links que navegam para outras páginas
|
||||
$('a[href]:not([href^="#"]):not([href^="javascript:"]):not([target="_blank"]):not(.no-loading)').click(function(e) {
|
||||
var href = $(this).attr('href');
|
||||
|
||||
// Ignorar links externos, downloads, ou âncoras
|
||||
if (href && !href.startsWith('http') && !href.startsWith('mailto:') && !href.startsWith('tel:')) {
|
||||
showLoadingBar();
|
||||
}
|
||||
});
|
||||
|
||||
// Interceptar submissão de formulários
|
||||
$('form:not(.no-loading)').submit(function() {
|
||||
showLoadingBar();
|
||||
});
|
||||
|
||||
// Ocultar barra quando página carrega
|
||||
$(window).on('load', function() {
|
||||
hideLoadingBar();
|
||||
});
|
||||
|
||||
// Ocultar barra em caso de erro ou volta do histórico
|
||||
$(window).on('pageshow', function() {
|
||||
hideLoadingBar();
|
||||
});
|
||||
}
|
||||
|
||||
function showLoadingBar() {
|
||||
var loadingBar = $('#loading-bar');
|
||||
loadingBar.addClass('active').css('width', '0%');
|
||||
|
||||
// Animação progressiva
|
||||
setTimeout(function() { loadingBar.css('width', '20%'); }, 100);
|
||||
setTimeout(function() { loadingBar.css('width', '40%'); }, 300);
|
||||
setTimeout(function() { loadingBar.css('width', '60%'); }, 600);
|
||||
setTimeout(function() { loadingBar.css('width', '80%'); }, 1000);
|
||||
|
||||
// Adicionar efeito de loading ao conteúdo
|
||||
$('main').addClass('page-loading');
|
||||
}
|
||||
|
||||
function hideLoadingBar() {
|
||||
var loadingBar = $('#loading-bar');
|
||||
loadingBar.css('width', '100%');
|
||||
|
||||
setTimeout(function() {
|
||||
loadingBar.removeClass('active').css('width', '0%');
|
||||
$('main').removeClass('page-loading');
|
||||
}, 200);
|
||||
}
|
||||
|
||||
// Fallback para esconder loading se demorar muito (mais de 5 segundos)
|
||||
setTimeout(function() {
|
||||
hideLoadingBar();
|
||||
}, 5000);
|
||||
</script>
|
||||
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
@ -310,10 +310,10 @@
|
||||
</div>
|
||||
<div class="toast-body">
|
||||
<p class="mb-2"><strong>Você está visualizando uma prévia!</strong></p>
|
||||
<p class="mb-2 small">• Para fazer alterações, volte ao Dashboard</p>
|
||||
<p class="mb-2 small">• Para fazer alterações, volte ao Dashboard e clique <i class="fas fa-cog"></i></p>
|
||||
<p class="mb-2 small">• Esta prévia não é a página final publicada</p>
|
||||
<button type="button" class="btn btn-sm btn-primary w-100" onclick="goBackToDashboard()">
|
||||
<i class="fas fa-edit me-1"></i>
|
||||
<i class="fas fa-cog"></i> >>
|
||||
Editar Página
|
||||
</button>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user