create a public user page

This commit is contained in:
Jannis Portmann 2021-05-13 12:11:02 +02:00
parent e0ec9807a3
commit 428baa749c
6 changed files with 92 additions and 43 deletions

View file

@ -6,7 +6,7 @@ $primary: darken(#005035, 20%);
// the ~ allows you to reference things in node_modules
@import "~bootstrap/scss/bootstrap";
.offer > img {
.offer-img {
height: 15rem;
object-fit: cover;
}
@ -40,4 +40,12 @@ $primary: darken(#005035, 20%);
.offer-footer {
color: #555;
}
.user-link {
color: #555;
}
.user-link:hover {
color: #000;
}

BIN
public/placeholder.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View file

@ -52,12 +52,13 @@ class UserController extends AbstractController
]);
}
#[Route('/user/{id}', name: 'public_wishlist')]
public function show_user(User $user, WishRepository $wishRepository): Response
#[Route('/user/{id}', name: 'user_public')]
public function show_user(User $user, OfferingRepository $offeringRepository, WishRepository $wishRepository): Response
{
return $this->render('user/public_wishlist.html.twig', [
return $this->render('user/public.html.twig', [
'username' => $user->getUsername(),
'wishes' => $wishRepository->findByUser($user),
'offers' => $offeringRepository->findByUser($user),
]);
}

View file

@ -12,21 +12,27 @@
{% if offers|length > 0 %}
<div class="card-deck d-flex justify-content-around justify-content-sm-around justify-content-md-between flex-wrap">
{% for offer in offers %}
<a href="{{ path('show_offer', {'id': offer.id}) }}" class="mb-5">
<div class="mb-5">
<div class="card offer h-100">
{% if offer.photoFilename %}
<img class="card-img-top" src="{{ asset('uploads/photos/' ~ offer.photofilename) }}" />
{% endif %}
<div class="card-body">
<h5 class="card-title">{{ offer.title }}</h5>
<p class="card-text">{{ offer.description }}</p>
</div>
<a href="{{ path('show_offer', {'id': offer.id }) }}">
{% if offer.photoFilename %}
<img class="card-img-top offer-img" src="{{ asset('uploads/photos/' ~ offer.photofilename) }}" />
{% else %}
<img class="card-img-top offer-img" src="{{ asset('placeholder.jpg') }}" />
{% endif %}
<div class="card-body">
<h5 class="card-title">{{ offer.title }}</h5>
<p class="card-text">{{ offer.description }}</p>
</div>
</a>
<div class="card-footer offer-footer">
<p class="username"><i class="fas fa-user mt-3"></i> {{ offer.byUser }}</p>
<a class="user-link" href="{{ path('user_public', { 'id': offer.byuser.id }) }}">
<p class="username"><i class="fas fa-user mt-3"></i> {{ offer.byUser }}</p>
</a>
<p class="zip"><i class="fas fa-map-marker-alt mt-3"></i> {{ offer.zipCode }}</p>
</div>
</div>
</a>
</div>
{% endfor %}
</div>
{% else %}

View file

@ -0,0 +1,63 @@
{% extends 'base.html.twig' %}
{% block title %}Whishlist{% endblock %}
{% block body %}
{% for message in app.flashes('success') %}
<div class="alert alert-success" role="alert">
{{ message }}
</div>
{% endfor %}
<div class="mb-3">
<h1>{{ username }}'s Wishlist</h1>
</div>
<div class="mb-4">
{% if wishes == [] %}
<div class="alert alert-warning" role="alert">
There are currently no wishes!
</div>
{% else %}
<ul class="list-group">
{% for wish in wishes %}
<li class="list-group-item"> {{ wish.title }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
<hr>
<div class="mb-3">
<h1>{{ username }}'s Offers</h1>
</div>
{% if offers|length > 0 %}
<div class="card-deck d-flex justify-content-around justify-content-sm-around justify-content-md-between flex-wrap">
{% for offer in offers %}
<div class="mb-5">
<div class="card offer h-100">
<a href="{{ path('show_offer', {'id': offer.id }) }}">
{% if offer.photoFilename %}
<img class="card-img-top offer-img" src="{{ asset('uploads/photos/' ~ offer.photofilename) }}" />
{% else %}
<img class="card-img-top offer-img" src="{{ asset('placeholder.jpg') }}" />
{% endif %}
<div class="card-body">
<h5 class="card-title">{{ offer.title }}</h5>
<p class="card-text">{{ offer.description }}</p>
</div>
</a>
<div class="card-footer offer-footer">
<a class="user-link" href="{{ path('user_public', { 'id': offer.byuser.id }) }}">
<p class="username"><i class="fas fa-user mt-3"></i> {{ offer.byUser }}</p>
</a>
<p class="zip"><i class="fas fa-map-marker-alt mt-3"></i> {{ offer.zipCode }}</p>
</div>
</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="alert alert-warning" role="alert">There are currently no active offers.</div>
{% endif %}
{% endblock %}

View file

@ -1,29 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Whishlist{% endblock %}
{% block body %}
{% for message in app.flashes('success') %}
<div class="alert alert-success" role="alert">
{{ message }}
</div>
{% endfor %}
<div class="mb-3">
<h1>{{ username }}'s' Wishlist</h1>
</div>
<div class="mb-3">
{% if wishes == [] %}
<div class="alert alert-warning" role="alert">
There are currently no wishes!
</div>
{% else %}
<ul class="list-group">
{% for wish in wishes %}
<li class="list-group-item"> {{ wish.title }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
{% endblock %}