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 15, 2024
1 parent 68bcf60 commit a09d566
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 31 deletions.
15 changes: 0 additions & 15 deletions src/Angor/Client/Models/ProjectValidationService.cs

This file was deleted.

13 changes: 2 additions & 11 deletions src/Angor/Client/Pages/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,6 @@
private int totalDuration;
private int numberOfStages;
private bool isValid = true;
private int projectCount;
private string errorMessage;

bool createProfileSpinner;
Expand All @@ -595,18 +594,10 @@
{
return;
}

var projects = storage.GetFounderProjects() ?? new List<FounderProject>();
projectCount = projects?.Count ?? 0;

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

var keys = _walletStorage.GetFounderKeys();

if (projects.Count > 14)
{
errorMessage = "You have reached the maximum limit of projects!";
isValid = false;
return;
}

if (projects.Count >= keys.Keys.Count)
{
Expand Down
14 changes: 12 additions & 2 deletions src/Angor/Client/Pages/Invest.razor
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ else
TransactionInfo? signedTransaction;
Transaction unSignedTransaction;
string InvestorPubKey;
private ProjectValidationService validationService = new ProjectValidationService();


private FeeData feeData = new();
Expand All @@ -388,7 +387,7 @@ else

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

if (project == null || !validationService.CanInvest(project))
if (project == null || !CanInvest(project))
{
notificationComponent.ShowNotificationMessage("You cannot invest in this project.", 5);
NavigationManager.NavigateTo($"/view/{ProjectId}");
Expand Down Expand Up @@ -943,4 +942,15 @@ else
{
showTransactionJsonModal = isVisible;
}

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

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;
}
}
16 changes: 13 additions & 3 deletions src/Angor/Client/Pages/View.razor
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ else
}
<button class="btn btn-border mb-3" data-cy="INVEST_BUTTON"
@onclick="InvestInProject"
disabled="@(project == null || !validationService.CanInvest(project))"
title="@(validationService.CanInvest(project) ? null : "Investment is not allowed for this project.")">
disabled="@(project == null || !CanInvest(project))"
title="@(CanInvest(project) ? null : "Investment is not allowed for this project.")">
Invest Now
</button>
</div>
Expand Down Expand Up @@ -434,7 +434,6 @@ else

private bool isGeneratingNsec;
private string errorMessage = string.Empty;
private ProjectValidationService validationService = new ProjectValidationService();


private string error;
Expand Down Expand Up @@ -743,5 +742,16 @@ else
string sanitizedInput = HtmlStripperService.StripHtmlTags(input);
return new MarkupString(sanitizedInput);
}

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

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;
}
}

0 comments on commit a09d566

Please sign in to comment.