Skip to content

Commit

Permalink
work in progress -- probably want to switch to radio buttons for thre…
Browse files Browse the repository at this point in the history
…e options
  • Loading branch information
eebbesen committed Nov 6, 2024
1 parent fb31bd9 commit 005d8c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Display downtown Saint Paul food and drink deals

![tests](https://github.com/eebbesen/StpFoodBlazor/actions/workflows/test.yml/badge.svg)

[See it in action!](stpfoodblazor-d3f0aqbuf5bxfugt.centralus-01.azurewebsites.net)

## Requirements

You can modify this code to use other data services and data attributes but this code assumes you are using [sheet_zoukas-lambda](https://github.com/eebbesen/sheet_zoukas-lambda/) deployed on AWS to expose a Google Sheet.
Expand Down
20 changes: 19 additions & 1 deletion StpFoodBlazor/StpFoodBlazor/Components/Pages/Deals.razor
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ else
}
</select>
</div>
<div class="col">
<label for="happy-hour-checkbox" class="form-label">Include Happy Hour?</label>
<input type="checkbox" id="happy-hour-checkbox" checked="@happyHour"
@onchange="OnHappyHourChanged">
</div>
</div>
<div class="row bg-dark text-light rounded" id="deals_table_header">
@if (string.IsNullOrEmpty(selectedDayOfWeek))
Expand Down Expand Up @@ -67,6 +72,8 @@ else
private DealEvent[]? deals;
private DealEvent[]? allDeals = null;
private string? selectedDayOfWeek = null;

private bool happyHour = false;
private static readonly List<DayOfWeek> daysOfWeek = Enum.GetValues(typeof(DayOfWeek)).Cast<DayOfWeek>().ToList();

protected override async Task OnAfterRenderAsync(bool firstRender)
Expand All @@ -88,11 +95,22 @@ else
SortDeals();
}

void OnHappyHourChanged(ChangeEventArgs e)
{
if (e.Value is bool value)
{
happyHour = value;
}
FilterDeals();
SortDeals();
}

private void FilterDeals()
{
DealFilter filter = new DealFilter();
filter.Day = selectedDayOfWeek;
filter.Deals = allDeals;
filter.Day = selectedDayOfWeek;
filter.HappyHour = happyHour;
deals = filter.Filter();
}

Expand Down

0 comments on commit 005d8c3

Please sign in to comment.