Show users offers on dedicated page
This commit is contained in:
parent
c2636811fd
commit
1ae9096729
4 changed files with 49 additions and 38 deletions
|
@ -47,7 +47,7 @@ class UserController extends AbstractController
|
||||||
{
|
{
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
|
|
||||||
return $this->render('user/offers.html.twig', [
|
return $this->render('user/public.html.twig', [
|
||||||
'user' => $user,
|
'user' => $user,
|
||||||
'offers' => $offeringRepository->findByUser($user),
|
'offers' => $offeringRepository->findByUser($user),
|
||||||
]);
|
]);
|
||||||
|
@ -105,4 +105,15 @@ class UserController extends AbstractController
|
||||||
|
|
||||||
throw new HttpException(403, "No permission");
|
throw new HttpException(403, "No permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/myoffers', name: 'own_offers')]
|
||||||
|
public function ownOffers(OfferingRepository $offeringRepository): Response
|
||||||
|
{
|
||||||
|
$user = $this->getUser();
|
||||||
|
|
||||||
|
return $this->render('user/offers.html.twig', [
|
||||||
|
'user' => $user,
|
||||||
|
'offers' => $offeringRepository->findByUser($user),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" data-toggle="dropdown"role="button" aria-haspopup="true" aria-expanded="false"><i class="fas fa-user"></i> User</a>
|
<a class="nav-link dropdown-toggle" data-toggle="dropdown"role="button" aria-haspopup="true" aria-expanded="false"><i class="fas fa-user"></i> User</a>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
|
<a class="dropdown-item" href="{{ path('own_offers') }}"><i class="fas fa-seedling"></i> My Offers</a>
|
||||||
<a class="dropdown-item" href="{{ path('wishlist') }}"><i class="fas fa-star"></i> Wishlist</a>
|
<a class="dropdown-item" href="{{ path('wishlist') }}"><i class="fas fa-star"></i> Wishlist</a>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item" href="{{ path('user_page') }}"><i class="fas fa-user"></i> User settings</a>
|
<a class="dropdown-item" href="{{ path('user_page') }}"><i class="fas fa-user"></i> User settings</a>
|
||||||
|
|
|
@ -47,30 +47,4 @@
|
||||||
<h3 class="mb-3">Delete Account</h3>
|
<h3 class="mb-3">Delete Account</h3>
|
||||||
<button class="btn btn-danger">Delete Account</button>
|
<button class="btn btn-danger">Delete Account</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr>
|
|
||||||
<h1>Offers</h1>
|
|
||||||
{% 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="./offer/{{ offer.id }}" 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>
|
|
||||||
<div class="card-footer offer-footer">
|
|
||||||
<p class="username"><i class="fas fa-user mt-3"></i> {{ offer.byUser }}</p>
|
|
||||||
<p class="zip"><i class="fas fa-map-marker-alt mt-3"></i> {{ offer.zipCode }}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<div class="alert alert-warning" role="alert">There are currently no active offers.</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -8,24 +8,49 @@
|
||||||
{{ message }}
|
{{ message }}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<h1>Offers</h1>
|
<h1>My Offers</h1>
|
||||||
{% if offers|length > 0 %}
|
{% if offers|length > 0 %}
|
||||||
<div class="card-deck d-flex justify-content-around justify-content-sm-around justify-content-md-between flex-wrap">
|
<div class="card-deck d-flex justify-content-around justify-content-sm-around justify-content-md-between flex-wrap">
|
||||||
{% for offer in offers %}
|
{% for offer in offers %}
|
||||||
|
<div class="mb-5">
|
||||||
<div class="card offer h-100">
|
<div class="card offer h-100">
|
||||||
{% if offer.photoFilename %}
|
<a href="{{ path('show_offer', {'id': offer.id }) }}">
|
||||||
<img class="card-img-top" src="{{ asset('uploads/photos/' ~ offer.photofilename) }}" />
|
{% if offer.photoFilename %}
|
||||||
{% endif %}
|
<img class="card-img-top offer-img" src="{{ asset('uploads/photos/' ~ offer.photofilename) }}" />
|
||||||
<div class="card-body">
|
{% else %}
|
||||||
<h5 class="card-title">{{ offer.title }}</h5>
|
<img class="card-img-top offer-img" src="{{ asset('placeholder.jpg') }}" />
|
||||||
<p class="card-text">{{ offer.description }}</p>
|
{% endif %}
|
||||||
</div>
|
<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">
|
<div class="card-footer offer-footer">
|
||||||
<a href=" {{ path('show_offer', { id: offer.id }) }}" class="btn btn-primary"><i class="fas fa-external-link-alt"></i></a>
|
<a href="{{ path('edit_offer', {'id': offer.id}) }}" class="btn btn-info"><i class="fas fa-pen"></i></a>
|
||||||
<a href="#" class="btn btn-info"><i class="fas fa-pen"></i></a>
|
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#offer-modal-{{ offer.id }}"><i class="fas fa-trash-alt"></i></button>
|
||||||
<a href="#" class="btn btn-danger"><i class="fas fa-trash-alt"></i></a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Modal -->
|
||||||
|
<div class="modal fade" id="offer-modal-{{ offer.id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="exampleModalLabel">Warning</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
Are you sure you want to delete this offer?
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||||
|
<a type="button" class="btn btn-danger" href="{{ path('delete_offer', {'id': offer.id}) }}">Delete</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
Reference in a new issue