Skip to content

Commit

Permalink
act on review
Browse files Browse the repository at this point in the history
  • Loading branch information
itailiors committed Dec 18, 2024
1 parent a09d566 commit 91ce890
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
12 changes: 7 additions & 5 deletions src/Angor/Client/Pages/Invest.razor
Original file line number Diff line number Diff line change
Expand Up @@ -942,15 +942,17 @@ else
{
showTransactionJsonModal = isVisible;
}

public bool CanInvest(Project project)
{
if (project == null) return false;
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 false; // Investing period hasn't started
if (now > project.ProjectInfo.ExpiryDate) return false; // Investing period has ended

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

return false;
}

}
29 changes: 15 additions & 14 deletions src/Angor/Client/Pages/View.razor
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,18 @@ else
</p>
@{
var timeLeft = (project.ProjectInfo.StartDate - DateTime.UtcNow).Days;

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="@(project == null || !CanInvest(project))"
title="@(CanInvest(project) ? null : "Investment is not allowed for this project.")">
Invest Now
disabled="@(project == null || !CanInvest(project))">
@if (project == null || !CanInvest(project))
{
<text>The investing period is over</text>
}
else
{
<text>Invest Now</text>
}
</button>
</div>
}
Expand Down Expand Up @@ -745,13 +745,14 @@ else

public bool CanInvest(Project project)
{
if (project == null) return false;

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 false; // Investing period hasn't started
if (now > project.ProjectInfo.ExpiryDate) return false; // Investing period has ended

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

return false;
}
}

0 comments on commit 91ce890

Please sign in to comment.