Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 204 - Blocking pages from server side #217

Merged
merged 9 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/Angor/Client/Pages/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
return;
}

@if (!isValid)
{
<div class="alert alert-danger">
<h4>Error</h4>
<p>@errorMessage</p>
</div>
}

<div class="row">
<div class="card card-body">
Expand Down Expand Up @@ -570,6 +577,8 @@

private int totalDuration;
private int numberOfStages;
private bool isValid = true;
private string errorMessage;

bool createProfileSpinner;
bool createApplicationDataSpinner;
Expand All @@ -585,13 +594,15 @@
{
return;
}

var projects = storage.GetFounderProjects()?.Where(p => !string.IsNullOrEmpty(p.CreationTransactionId)).ToList() ?? new List<FounderProject>();

var projects = storage.GetFounderProjects() ?? new List<FounderProject>();
var keys = _walletStorage.GetFounderKeys();

if (projects.Count(p => !string.IsNullOrEmpty(p.CreationTransactionId)) >= keys.Keys.Count)
itailiors marked this conversation as resolved.
Show resolved Hide resolved
if (projects.Count >= keys.Keys.Count)
{
notificationComponent.ShowErrorMessage("All founder keys have been used for this wallet!");
errorMessage = "All founder keys have been used for this wallet!";
isValid = false;
return;
}

Expand Down
21 changes: 21 additions & 0 deletions src/Angor/Client/Pages/Invest.razor
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,13 @@ else

Project? findProject = storage.GetInvestmentProjects().FirstOrDefault(p => p.ProjectInfo.ProjectIdentifier == ProjectId);

if (project == null || !CanInvest(project))
{
notificationComponent.ShowNotificationMessage("You cannot invest in this project.", 5);
NavigationManager.NavigateTo($"/view/{ProjectId}");
return;
}

if (findProject != null)
{
var investmentProject = findProject as InvestorProject;
Expand Down Expand Up @@ -935,4 +942,18 @@ else
{
showTransactionJsonModal = isVisible;
}

public bool CanInvest(Project project)
{
// on testnet we will not disable the ability to invest at all
if (project == null || project.ProjectInfo == null) return false;
if (network.NetworkType == NetworkType.Testnet) return true;

var now = DateTime.UtcNow;

if (now <= project.ProjectInfo.StartDate) return true;

return false;
}

}
31 changes: 19 additions & 12 deletions src/Angor/Client/Pages/View.razor
Original file line number Diff line number Diff line change
Expand Up @@ -306,24 +306,17 @@ else
</p>
@{
var timeLeft = (project.ProjectInfo.StartDate - DateTime.UtcNow).Days;
dangershony marked this conversation as resolved.
Show resolved Hide resolved

if (timeLeft <= 0 && network.NetworkType == NetworkType.Testnet)
{
// on testnet we will not disable the ability to invest at all
timeLeft = 1;
}
}
<button class="btn btn-border mb-3" data-cy="INVEST_BUTTON"
@onclick="InvestInProject"
disabled="@(timeLeft <= 0 ? "disabled" : null)"
title="@(timeLeft <= 0 ? "The investing period is over" : null)">
@if (timeLeft > 0)
disabled="@(project == null || !CanInvest(project))">
@if (project == null || !CanInvest(project))
{
<text>Invest Now</text>
<text>The investing period is over</text>
dangershony marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
<text>The investing period is over</text>
<text>Invest Now</text>
}
</button>
</div>
Expand Down Expand Up @@ -442,6 +435,7 @@ else
private bool isGeneratingNsec;
private string errorMessage = string.Empty;


private string error;

private List<(string Hash, int Amount)> SelectedSeeders = new List<(string hash, int amount)>
Expand Down Expand Up @@ -748,5 +742,18 @@ else
string sanitizedInput = HtmlStripperService.StripHtmlTags(input);
return new MarkupString(sanitizedInput);
}

public bool CanInvest(Project project)
dangershony marked this conversation as resolved.
Show resolved Hide resolved
{
// on testnet we will not disable the ability to invest at all
if (project == null || project.ProjectInfo == null) return false;
if (network.NetworkType == NetworkType.Testnet) return true;

var now = DateTime.UtcNow;

if (now <= project.ProjectInfo.StartDate) return true;

return false;
}
}

}
Loading