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

Add validation to create project #33

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Changes from 1 commit
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
34 changes: 32 additions & 2 deletions src/Angor/Client/Pages/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@
@foreach (var stage in project.Stages)
{
<div class="mb-3">
<label class="form-label">Stage @project.Stages.IndexOf(stage)</label>
<label class="form-label">The mount in % to allocate for stage @(project.Stages.IndexOf(stage) + 1)</label>
dangershony marked this conversation as resolved.
Show resolved Hide resolved
<div class="input-group">
<InputNumber @bind-Value="stage.AmountToRelease" class="form-control" placeholder="Enter amount to release as a percentage" min="1" max="100" step="1"/>
<InputNumber @bind-Value="stage.AmountToRelease" class="form-control" placeholder="Enter amount to release as a percentage" min="1" max="100" step="1" />
<InputDate @bind-Value="stage.ReleaseDate" class="form-control"/>
<button type="button" class="btn btn-danger" @onclick="() => RemoveStage(stage)">Remove</button>
</div>
Expand Down Expand Up @@ -324,6 +324,36 @@

private async Task CreatProject()
{
if (project.TargetAmount < (decimal)0.1)
{
notificationComponent.ShowErrorMessage("Project target amount must be higher then 0.1 BTC");
return;
}

if (project.StartDate < DateTime.UtcNow)
{
notificationComponent.ShowErrorMessage("Project must start in the future");
return;
}

if (project.ExpiryDate < project.StartDate)
{
notificationComponent.ShowErrorMessage("Project must expire after start date");
return;
}

if (project.Stages.Any() && project.ExpiryDate < project.Stages.Last().ReleaseDate)
{
notificationComponent.ShowErrorMessage("Project expire date must be after the last stage date");
return;
}

if (project.PenaltyDays < 10)
{
notificationComponent.ShowErrorMessage("Project penalty must be higher then 10 days");
return;
}

if (project.Stages.Count() < 3)
{
notificationComponent.ShowErrorMessage("There must be at least 3 stages");
Expand Down
Loading