Skip to content

Commit

Permalink
fix: some typos
Browse files Browse the repository at this point in the history
  • Loading branch information
djoufson committed Dec 29, 2024
1 parent 79fc94f commit 64edb88
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 67 deletions.
64 changes: 35 additions & 29 deletions app.client/Components/NewActivityPopup.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,39 @@
<div id="activity-popup" class="activity-popup absolute top-0 left-0 w-full h-full z-10">
<div class="relative top-0 left-0 w-full h-full z-10">
<div class="fixed w-full h-full top-0 left-0 bg-black bg-opacity-30"></div>
<EditForm id="new-activity-form" OnValidSubmit="@Add" FormName="NewActivityForm" Model="@ActivityModel" class="absolute flex flex-col gap-4 p-4 justify-between items-center top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-10 w-[80%] h-[80%] bg-white rounded-lg">
<EditForm id="new-activity-form" OnValidSubmit="@Add" FormName="NewActivityForm" Model="@ActivityModel"
class="absolute flex flex-col gap-4 p-4 justify-between items-center top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-10 w-[80%] h-[80%] bg-white rounded-lg">
<div class="w-full flex gap-6 pt-10">
<div class="w-1/2">
<h2 class="heading heading-2">Details</h2>
<div class="w-full">
<label for="title-input" class="font-bold">
Title
</label>
<InputText id="title-input" class="p-2 w-full px-4 border border-gray-400 rounded-lg" @bind-Value="@ActivityModel.Title" title="title" required placeholder="The activity name"/>
<InputText id="title-input" class="p-2 w-full px-4 border border-gray-400 rounded-lg"
@bind-Value="@ActivityModel.Title" title="title" required placeholder="The activity name" />
</div>
<div class="w-full mt-4">
<label for="description-input" class="font-bold">
<label for="activity-description-input" class="font-bold">
Description
</label>
<InputTextArea id="activity-description-input" onfocus="adjustTextareaHight('activity-description-input')" oninput="adjustTextareaHight('activity-description-input')" class="p-2 w-full px-4 border border-gray-400 rounded-lg" @bind-Value="@ActivityModel.Description" title="description" required placeholder="The activity description"/>
<InputTextArea id="activity-description-input"
onfocus="adjustTextareaHeight('activity-description-input')"
oninput="adjustTextareaHeight('activity-description-input')"
class="p-2 w-full px-4 border border-gray-400 rounded-lg"
@bind-Value="@ActivityModel.Description" title="description" required
placeholder="The activity description" />
</div>
<div class="w-full">
<p class="font-bold">Schedule</p>
<div class="flex flex-col">
<label>
<i class="fa-regular fa-calendar"></i> Start Time:
<InputDate Type="InputDateType.Time" @bind-Value="ActivityModel.Start"/>
<InputDate Type="InputDateType.Time" @bind-Value="ActivityModel.Start" />
</label>
<label>
<i class="fa-regular fa-calendar-minus"></i> End Time:
<InputDate Type="InputDateType.Time" @bind-Value="ActivityModel.End"/>
<InputDate Type="InputDateType.Time" @bind-Value="ActivityModel.End" />
</label>
</div>
</div>
Expand All @@ -40,21 +47,25 @@
Host Picture
</label>
<div class="flex items-center gap-2">
<img src="@ActivityModel.HostImageUrl" alt="@ActivityModel.HostName" class="block w-[50px] aspect-square"/>
<img src="@ActivityModel.HostImageUrl" alt="@ActivityModel.HostName"
class="block w-[50px] aspect-square" />
<InputFile OnChange="@HandleFileSelected" title="Choose host picture" accept="image/*" />
</div>
</div>
<div class="w-full mt-4">
<label for="host-name-input" class="font-bold">
Host Name
</label>
<InputText id="host-name-input" class="p-2 w-full px-4 border border-gray-400 rounded-lg" @bind-Value="@ActivityModel.HostName" title="host name" required placeholder="Host name"/>
<InputText id="host-name-input" class="p-2 w-full px-4 border border-gray-400 rounded-lg"
@bind-Value="@ActivityModel.HostName" title="host name" required placeholder="Host name" />
</div>
<div class="w-full mt-4">
<label for="host-email-input" class="font-bold">
Host Email
</label>
<InputText id="host-email-input" class="p-2 w-full px-4 border border-gray-400 rounded-lg" @bind-Value="@ActivityModel.HostEmail" title="host email" required placeholder="Host Email"/>
<InputText id="host-email-input" class="p-2 w-full px-4 border border-gray-400 rounded-lg"
@bind-Value="@ActivityModel.HostEmail" title="host email" required
placeholder="Host Email" />
</div>
</div>
</div>
Expand All @@ -66,7 +77,7 @@
</div>
</div>

@code{
@code {
private const string ActiveClass = "active";
private string _class = string.Empty;
[Parameter]
Expand All @@ -85,29 +96,24 @@
private async Task Add()
{
Parent.AddActivity(new ActivityModel
{
Title = ActivityModel.Title,
Description = ActivityModel.Description,
Host = new HostModel
{
Name = ActivityModel.HostName,
Email = ActivityModel.HostEmail,
ImageUrl = ActivityModel.HostImageUrl
},
Schedule = ActivitySchedule.Create(ActivityModel.Start, ActivityModel.End)
});
Title = ActivityModel.Title,
Description = ActivityModel.Description,
Host = new HostModel
{
Name = ActivityModel.HostName,
Email = ActivityModel.HostEmail,
ImageUrl = ActivityModel.HostImageUrl
},
Schedule = ActivitySchedule.Create(ActivityModel.Start, ActivityModel.End)
});
ActivityModel.HostImageUrl = string.Empty;
await JsInterop.InvokeVoidAsync("toggleActivityPopup");
}

private async Task HandleFileSelected(InputFileChangeEventArgs e)
{
var file = e.File;
if (file is null)
{
return;
}

using var memoryStream = new MemoryStream();
await file.OpenReadStream().CopyToAsync(memoryStream);
byte[] fileBytes = memoryStream.ToArray();
Expand All @@ -117,19 +123,19 @@
}

private async Task CloseActivityPopup()
{
{
ActivityModel.HostImageUrl = string.Empty;
await JsInterop.InvokeVoidAsync("toggleActivityPopup");
}

class Model
{
public string Title { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string HostName { get; set; } = string.Empty;
public string HostEmail { get; set; } = string.Empty;
public string HostImageUrl { get; set; } = string.Empty;
public TimeOnly Start { get; set; } = new();
public TimeOnly End { get; set; } = new();
public TimeOnly Start { get; set; }
public TimeOnly End { get; set; }
}
}
Loading

0 comments on commit 64edb88

Please sign in to comment.