Skip to content

Commit

Permalink
feat: add coop provider
Browse files Browse the repository at this point in the history
  • Loading branch information
manuel-rw committed Jan 26, 2024
1 parent 3a9c1c6 commit c7a70b6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
16 changes: 16 additions & 0 deletions GrocyScanner.Core/Providers/CoopProductProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using GrocyScanner.Core.Models;

namespace GrocyScanner.Core.Providers;

public class CoopProductProvider : IProductProvider
{
public Task<Product?> GetProductByGtin(string gtin)
{
throw new NotImplementedException();
}

public string Name => "Coop";
public string IconUri => "/coop-logo.png";

public string Country => "Switzerland";
}
2 changes: 2 additions & 0 deletions GrocyScanner.Core/Providers/IProductProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public interface IProductProvider
public string Name { get; }

public string IconUri { get; }

public string Country { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ public OpenFoodFactsProductProvider(ILogger<OpenFoodFactsProductProvider> logger

public string Name => "Open Food Facts";
public string IconUri => "/open-food-facts-logo.png";
public string Country => "Global";
}
9 changes: 6 additions & 3 deletions GrocyScanner.Service/Pages/Settings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
<MudList>
@foreach (IProductProvider provider in ProductProviders)
{
<MudListItem Avatar="<image href='https://ch.openfoodfacts.org/images/favicon/apple-touch-icon.png' width='100%' height='100%' />">
<MudListItem Avatar="@($"<image href='{provider.IconUri}' width='100%' height='100%' />")">
<div class="d-flex align-items-center gap-3">
<MudText>@provider.Name</MudText>
<MudChip Variant="Variant.Text" Color="Color.Success">Enabled</MudChip>
<div>
<MudText>@provider.Name</MudText>
<MudText Typo="Typo.body2" Style="@($"color:{Colors.Grey.Default};")">@provider.Country</MudText>
</div>
<MudChip Variant="Variant.Text" Color="Color.Dark">Enabled</MudChip>
</div>
</MudListItem>
}
Expand Down
1 change: 1 addition & 0 deletions GrocyScanner.Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton<IGtinValidator, GtinValidator>();
builder.Services.AddSingleton<IProductProvider, OpenFoodFactsProductProvider>();
builder.Services.AddSingleton<IProductProvider, CoopProductProvider>();
builder.Services.AddSingleton<IGrocyClient, GrocyClient>();
builder.Services.AddSingleton<IGrocyQuantityUnit, GrocyQuantityUnitsMasterData>();
builder.Services.AddSingleton<IGrocyLocations, GrocyLocationMasterData>();
Expand Down
Binary file added GrocyScanner.Service/wwwroot/coop-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c7a70b6

Please sign in to comment.