Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
punkouter24 committed Apr 11, 2024
1 parent b377c8e commit 7774cb8
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 51 deletions.
7 changes: 2 additions & 5 deletions PoMad/Components/Layout/NavMenu.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
</NavLink>
</div>




<div class="nav-item px-3">
@* <div class="nav-item px-3">
<NavLink class="nav-link" href="auth">
<span class="bi bi-lock-nav-menu" aria-hidden="true"></span> Auth Required
</NavLink>
</div>
</div> *@


<AuthorizeView>
Expand Down
4 changes: 2 additions & 2 deletions PoMad/Components/Pages/Calendar.razor
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
@for (int day = 0; day < 7; day++)
{
var date = _dates[week * 7 + day];
var dailyData = _dailyDataList?.FirstOrDefault(d => d.Date == date);
var dailyData = _dailyDataList?.FirstOrDefault(d => d.Date.Date == date.Date);

<div class="calendar-cell @(date.Month != _currentMonth.Month ? "inactive" : "")">
<div class="calendar-cell @(date.Month != _currentMonth.Month ? "inactive" : "") @(dailyData != null ? (dailyData.DidOMAD ? "" : "omad-false") : "no-data")">
<div class="date">@date.Day</div>
@if (dailyData != null)
{
Expand Down
45 changes: 3 additions & 42 deletions PoMad/Components/Pages/Home.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@

<h1>Dashboard</h1>

@* <div Class="rz-p-0 rz-p-md-12">
<RadzenChart>
<RadzenColumnSeries Data="@revenue1" CategoryProperty="Quarter" ValueProperty="Revenue" />
<RadzenColumnSeries Data="@revenue2" CategoryProperty="Quarter" ValueProperty="Revenue" />
</RadzenChart>
</div> *@

<div class="row">
<div class="col-md-6">
<h3>Monthly Weight</h3>
<RadzenChart>
<RadzenLineSeries Data="_monthlyWeightData" CategoryProperty="Month" ValueProperty="Weight" Title="Weight" />
<RadzenColumnSeries Data="_monthlyWeightData" CategoryProperty="Month" ValueProperty="Weight" Title="Weight" />
<RadzenCategoryAxis>
<RadzenAxisTitle Text="Month" />
</RadzenCategoryAxis>
Expand Down Expand Up @@ -55,44 +48,12 @@
<RadzenDataGridColumn TItem="DailyData" Property="Calories" Title="Calories" />
<RadzenDataGridColumn TItem="DailyData" Property="Weight" Title="Weight" />
<RadzenDataGridColumn TItem="DailyData" Property="DidOMAD" Title="Did OMAD" />
<RadzenDataGridColumn TItem="DailyData" Property="DidOMAD" Title="OMAD" />
</Columns>
</RadzenDataGrid>
</div>
</div>

@code {

// class DataItem
// {
// public string Quarter { get; set; }
// public double Revenue { get; set; }
// }
// DataItem[] revenue1 = new DataItem[]
// {
// new DataItem { Quarter = "Q1", Revenue = 234000 },
// new DataItem { Quarter = "Q2", Revenue = 284000 },
// new DataItem { Quarter = "Q3", Revenue = 274000 },
// new DataItem { Quarter = "Q4", Revenue = 294000 }
// };
// DataItem[] revenue2 = new DataItem[]
// {
// new DataItem { Quarter = "Q1", Revenue = 324000 },
// new DataItem { Quarter = "Q2", Revenue = 224000 },
// new DataItem { Quarter = "Q3", Revenue = 444000 },
// new DataItem { Quarter = "Q4", Revenue = 564000 }
// };








private List<DailyData> _dailyDataList;

Check warning on line 57 in PoMad/Components/Pages/Home.razor

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_dailyDataList' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
private List<MonthlyWeightData> _monthlyWeightData;

Check warning on line 58 in PoMad/Components/Pages/Home.razor

View workflow job for this annotation

GitHub Actions / build

Non-nullable field '_monthlyWeightData' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
private List<MonthlyCaloriesData> _monthlyCaloriesData;
Expand All @@ -116,7 +77,7 @@
.Select(g => new MonthlyWeightData
{
Month = $"{g.Key.Year}-{g.Key.Month:D2}",
Weight = g.Average(d => d.Weight)
Weight = (int)g.Average(d => d.Weight)
})
.ToList();
}
Expand All @@ -136,7 +97,7 @@
public class MonthlyWeightData
{
public string Month { get; set; }
public double Weight { get; set; }
public int Weight { get; set; }
}

public class MonthlyCaloriesData
Expand Down
7 changes: 6 additions & 1 deletion PoMad/Components/Pages/UserSettings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@using PoMad.Services
@inject UserManager<ApplicationUser> UserManager
@inject AuthenticationStateProvider AuthenticationStateProvider
@inject NavigationManager NavigationManager

<h1>User Settings</h1>

Expand Down Expand Up @@ -39,6 +40,10 @@
{
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
user = await UserManager.GetUserAsync(authState.User);

Check warning on line 42 in PoMad/Components/Pages/UserSettings.razor

View workflow job for this annotation

GitHub Actions / build

Possible null reference assignment.
if (user.Birthday == DateTime.MinValue)

Check warning on line 43 in PoMad/Components/Pages/UserSettings.razor

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
{
user.Birthday = new DateTime(1975, 1, 1);
}
// Assuming user is not null, otherwise handle null case
}

Expand All @@ -51,7 +56,7 @@
}
else
{
// Optionally, redirect or show a success message
NavigationManager.NavigateTo("/");
}
}
}
8 changes: 8 additions & 0 deletions PoMad/Data/ApplicationUser.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
using Microsoft.AspNetCore.Identity;
using System.ComponentModel.DataAnnotations;

namespace PoMad.Data
{
// Add profile data for application users by adding properties to the ApplicationUser class
public class ApplicationUser : IdentityUser
{
[Range(50, 500, ErrorMessage = "Weight must be between 50 and 500 lbs.")]
public int IdealWeight { get; set; }

[Range(50, 100, ErrorMessage = "Height must be between 50 and 100 inches.")]
public int Height { get; set; }

[Range(10, 100, ErrorMessage = "Age must be between 10 and 100.")]
public int Age { get; set; }

[Range(typeof(DateTime), "1/1/1900", "12/31/9999", ErrorMessage = "Birthday must be after January 1, 1900.")]
public DateTime Birthday { get; set; }
}

Expand Down
10 changes: 10 additions & 0 deletions PoMad/PoMad.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
<UserSecretsId>aspnet-PoMad-d3e2d5e7-1bbb-4efd-9a35-ca370c1fc7ce</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<None Remove="app.db" />
</ItemGroup>

<ItemGroup>
<Content Include="app.db">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Data.Tables" Version="12.8.3" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.3" />
Expand Down
Binary file modified PoMad/app.db
Binary file not shown.
Binary file modified PoMad/app.db-shm
Binary file not shown.
Binary file modified PoMad/app.db-wal
Binary file not shown.
17 changes: 16 additions & 1 deletion PoMad/wwwroot/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ h1:focus {
border: 1px solid #ccc;
padding: 5px;
text-align: center;
width: 100px; /* Fixed width */
height: 100px; /* Fixed height */
overflow: hidden; /* Prevents content overflow */
}

.calendar-cell.inactive {
Expand All @@ -90,4 +93,16 @@ h1:focus {
.calendar-cell .weight,
.calendar-cell .omad {
font-size: 12px;
}
}

.omad-true {
background-color: green;
}

.omad-false {
background-color: red;
}

.no-data {
background-color: white;
}

0 comments on commit 7774cb8

Please sign in to comment.