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

#64 fixed styling and tried to add the name of the wines #10

Merged
merged 3 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
29 changes: 20 additions & 9 deletions src/Controller/MealController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
namespace App\Controller;


use App\Repository\ProductsRepository;
use App\Service\MealMatcherService;
use Grandcruwijnen\SDK\API;
use Grandcruwijnen\SDK\Products;
use GuzzleHttp\Exception\GuzzleException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;


class MealController extends AbstractController
{

class MealController extends AbstractController {
/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
#[Route('/', name: 'landing_page')]
public function getIndex(MealMatcherService $mealMatcherService): Response
Expand All @@ -20,7 +26,7 @@ public function getIndex(MealMatcherService $mealMatcherService): Response
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
#[Route('/categories', name: 'meal_categories')]
public function getMealCategories(MealMatcherService $mealMatcherService): Response
Expand All @@ -29,7 +35,7 @@ public function getMealCategories(MealMatcherService $mealMatcherService): Respo
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
#[Route('/{parentId}', name: 'meal_categories_for_parent')]
public function getCategoriesForParent(int $parentId, MealMatcherService $mealMatcherService): Response
Expand All @@ -38,7 +44,7 @@ public function getCategoriesForParent(int $parentId, MealMatcherService $mealMa
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
#[Route('/meals/{categoryId}', name: 'meals_for_category')]
public function getMealsForCategory(int $categoryId, MealMatcherService $mealMatcherService): Response
Expand All @@ -47,11 +53,16 @@ public function getMealsForCategory(int $categoryId, MealMatcherService $mealMat
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
* @Route("/", name="product_index", methods={"GET"})
*/
#[Route('/matches/{mealId}', name: 'wines_for_meals')]
public function getWinesForMeals($mealId, MealMatcherService $mealMatcherService): Response
public function getWinesForMeals($mealId, MealMatcherService $mealMatcherService)
{
return $this->render('wines/index.html.twig', ['matches' => $mealMatcherService->getWinesForMeal($mealId)]);
$products = new Products(new API("[email protected]", "7Wn2okY7!A@mX-DZMmw7tanFaQ*sTGef87o!Gn4_mE6ctiqmLk2hH6LX_deN_K8P7U6LRs7H2BT.cGWvh", "https://beta.grandcruwijnen.dev"));
$products = $products->getProducts();
return $this->render('wines/index.html.twig', [
'products' => $products, 'matches' => $mealMatcherService->getWinesForMeal($mealId)
]);
}
}
50 changes: 0 additions & 50 deletions src/Repository/MealMatcherRepository.php

This file was deleted.

16 changes: 9 additions & 7 deletions src/Service/MealMatcherService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
namespace App\Service;


use Grandcruwijnen\SDK\Products;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use App\Controller\MealController;

class MealMatcherService {
private Client $client;
Expand All @@ -22,7 +25,7 @@ public function getIndexPage()
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function getMealsCategories()
{
Expand All @@ -37,7 +40,7 @@ public function getMealsCategories()
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function getParentMealCategories(): array
{
Expand All @@ -56,7 +59,7 @@ public function getParentMealCategories(): array
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function getCategoriesForParent(int $parentId): array
{
Expand All @@ -75,7 +78,7 @@ public function getCategoriesForParent(int $parentId): array
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function getMealsForCategory(int $categoryId)
{
Expand All @@ -85,12 +88,11 @@ public function getMealsForCategory(int $categoryId)
}

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws GuzzleException
*/
public function getWinesForMeal($mealId)
{
$response = $this->client->request('GET', '/api/meal_matches?mealId='.$mealId.'&limit=50');

$response = $this->client->request('GET', '/api/meal_matches?mealId=' . $mealId . '&limit=30', );
return json_decode($response->getBody()->getContents());
}
}
54 changes: 35 additions & 19 deletions templates/categories/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,47 @@

{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('style/style.css') }}">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
{% endblock %}

{% block title %}Hello MealController!{% endblock %}

{% block body %}
<div class="content" style="background-color: #e9dcd1; height: 100vh">
<div class="container" >
<img src='https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/images/logo.svg' alt='logo' style='padding:40px; margin-left: -20vw;'>
<button type="button" class="btn btn-danger btn-sm" data-toggle="modal" onclick='goBack()'><i class="fa fa-arrow-left" aria-hidden="true"></i> Terug</button>
<div class="text">
<h1 style='text-align:center;'>U het gerecht en wij adviseren de wijn!</h1>
<p class="p"></p>
</div>
</div>
<br>
{% for meal in meals %}
<section class="grid">
{% if meal.parent is null %}
<a href="{{ path('meal_categories_for_parent', {parentId: meal.categoryId}) }}" class="meal-name">
<div class="item">{{ meal.name }}</div>
<img src="https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/Grandcruwijnen_SmartSommelier/images/93.svg"
alt="" class="image">
</a>

<div class="text" style="text-align: center">
<h1>U het gerecht en wij adviseren de wijn!</h1>
<p>Als Grandcruwijnen bieden wij u een Online Sommelier welke dag-en-nacht voor u gereed staat. Deze functie is makkelijk te gebruiken. <br>U kiest uit een zeer uitgebreide lijst aan gerechten en de Online sommelier adviseert u de geschikte wijnen en adviseert bij de wijnen <br> de best bijpassende gerechten. Als u in een creative stemming bent en uw eigen gerecht wilt samenstellen dan kan dit ook!</p>
<p class="p"></p>
{% else %}
<a href="{{ path('meals_for_category', {categoryId: meal.categoryId}) }}" class="meal-name">
<div class="item">{{ meal.name }}</div>
</a>
{% endif %}
</section>
{% endfor %}
</div>
{% for meal in meals %}
<section class="grid">
{% if meal.parent is null %}
<a href="{{ path('meal_categories_for_parent', {parentId: meal.categoryId}) }}" class="meal-name">
<div class="item">{{ meal.name }}</div>
<img src="https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/Grandcruwijnen_SmartSommelier/images/93.svg"
alt="" class="image">
</a>
{% endblock %}

{% block javascripts%}
<script>
function goBack(){
window.history.back();
}
</script>

{% else %}
<a href="{{ path('meals_for_category', {categoryId: meal.categoryId}) }}" class="meal-name">
<div class="item">{{ meal.name }}</div>
</a>
{% endif %}
</section>
{% endfor %}
{% endblock %}
25 changes: 17 additions & 8 deletions templates/landing page/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,28 @@
padding: 2px 6px;
}
</style>

<div class="example-wrapper" style="text-align: center";>
<div class="container">
<img src='https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/images/logo.svg'
alt='logo' style='padding:40px;'>
</div>
<div class="example-wrapper" style="text-align: center;">
<h1>Grandcruwijnen biedt u de volgende opties:</h1>
</div>
<div class="images" style="text-align: center; margin-top: 75px;">
<img style="padding-right: 60px;" src="https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/Grandcruwijnen_SmartSommelier/images/93.svg" alt="" class="image">
<img style="padding-right: 60px;" src="https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/Grandcruwijnen_SmartSommelier/images/93.svg" alt="" class="image">
<img src="https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/Grandcruwijnen_SmartSommelier/images/93.svg" alt="" class="image">
<img style="padding-right: 60px;"
src="https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/Grandcruwijnen_SmartSommelier/images/93.svg"
alt="" class="image">
<img style="padding-right: 60px;"
src="https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/Grandcruwijnen_SmartSommelier/images/93.svg"
alt="" class="image">
<img src="https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/Grandcruwijnen_SmartSommelier/images/93.svg"
alt="" class="image">
</div>
<div class="choices" style="text-align: center; margin-top: 50px;">
<a href="{{ path('meal_categories')}}" style="text-decoration: none; padding-right: 30px;">Wijn overzicht</a>
<a href="{{ path('meal_categories')}}" style="text-decoration: none; padding-right: 30px;">Online Sommelier</a>
<a href="{{ path('meal_categories')}}" style="text-decoration: none;">Uw eigen gerecht</a>
<a href="https://winefinder.grandcruwijnen.nl" style="text-decoration: none; padding-right: 30px;">Wijn
overzicht</a>
<a href="{{ path('meal_categories') }}" style="text-decoration: none; padding-right: 30px;">Online Sommelier</a>
<a href="#" style="text-decoration: none;">Uw eigen gerecht</a>
</div>

{% endblock %}
53 changes: 35 additions & 18 deletions templates/meals/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,51 @@

{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('style/style.css') }}">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
{% endblock %}


{% block title %}Hello MealController!{% endblock %}


{% block body %}
<style>
body{
background-color:#e9dcd1;
}
</style>
{# https://mealmatcher.grandcruwijnen.nl/meals/%7B12de8bb3-8ce2-43a9-8b09-d56161365ebc%7D #}
<div class="text">
<img src='https://www.grandcruwijnen.nl/static/version1634749600/frontend/Grandcruwijnen/default/nl_NL/images/logo.svg' alt='logo' style='padding:40px;'>
<button type="button" class="btn btn-danger btn-sm" data-toggle="modal" onclick='goBack()'><i class="fa fa-arrow-left" aria-hidden="true"></i> Terug</button>
<div class="example-wrapper" style='text-align:center;padding-bottom:50px;'>
<h1>Welkom bij de online sommelier</h1>
<p>Hier kunt u uw gerecht kiezen en dan worden er bijpassende wijnen gezocht.</p>
</div>
{% for meal in meals %}
<p><a href="{{ path('wines_for_meal', {wineId: meal.id}) }}">{{ meal.name }}</a></p>
<img src="https://mealmatcher.grandcruwijnen.nl/meals/{{ meal.id }}" alt="">
{% endfor %}
{% endblock %}



{% for meal in meals %}
<p>
<a href="{{ path('wines_for_meals', {mealId: meal.id}) }}">
{{ meal.name }}
</a>
</p>
<img src="https://mealmatcher.grandcruwijnen.nl/meals/{{ meal.id }}" alt="{{ meal.name }}">
{% endfor %}

<div class="container" style='width:100%;'>
<div class="row" style='display: flex; flex-wrap: wrap;justify-content:center;'>
{% for meal in meals %}
<div class="col-sm-3" style="text-align: center; padding: 10px 10px 10px 10px; margin:5px; box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;">
<img src="https://mealmatcher.grandcruwijnen.nl/meals/{{ meal.id }}" alt="{{ meal.name }}" style='width:300px;'>
<p style='margin-top:20px;'>{{ meal.name }}</p>
<a href="{{ path('wines_for_meals', {mealId: meal.id}) }}">
<button type="button" class="btn btn-danger btn-sm">Selecteer <i class="fa fa-arrow-right" aria-hidden="true"></i></button>
</a>
</div>
{% endfor %}
</div>
</div>



{% endblock %}

{% block javascripts%}
<script>
function goBack(){
window.history.back();
}
</script>

{% endblock %}
Loading