diff --git a/README.md b/README.md index d38990f..00dc4b4 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,4 @@ Searching with filters such as: | Name | `string` | textfield | | Category | `Category` | dropdown | -Distance from entered ZIP to the offering ZIP. +Distance from entered ZIP to the offer ZIP. diff --git a/assets/app.js b/assets/app.js index 67845a1..126a834 100644 --- a/assets/app.js +++ b/assets/app.js @@ -22,7 +22,7 @@ import "friendly-challenge/widget"; // Dsiplay Filename when uploading document.querySelector('.custom-file-input').addEventListener('change',function(e){ - var fileName = document.getElementById("offering_form_photo").files[0].name; + var fileName = document.getElementById("offer_form_photo").files[0].name; var nextSibling = e.target.nextElementSibling nextSibling.innerText = fileName }) \ No newline at end of file diff --git a/assets/styles/app.scss b/assets/styles/app.scss index aa11425..5658853 100644 --- a/assets/styles/app.scss +++ b/assets/styles/app.scss @@ -6,12 +6,12 @@ $primary: darken(#005035, 20%); // the ~ allows you to reference things in node_modules @import "~bootstrap/scss/bootstrap"; -.offering > img { +.offer > img { height: 15rem; object-fit: cover; } -.offering { +.offer { $card-height: 100%; width: 20rem; } @@ -24,7 +24,7 @@ $primary: darken(#005035, 20%); float: right; } -.listings-container { +.offer-container { padding-top: 2rem; } diff --git a/src/Controller/OfferController.php b/src/Controller/OfferController.php index 9f487e2..1286092 100644 --- a/src/Controller/OfferController.php +++ b/src/Controller/OfferController.php @@ -26,25 +26,25 @@ class OfferController extends AbstractController } #[Route('/', name: 'homepage')] - public function index(Environment $twig, OfferingRepository $offeringRepository): Response + public function index(Environment $twig, OfferingRepository $offerRepository): Response { return new Response($twig->render('app/index.html.twig', [ - 'offerings' => $offeringRepository->findAll(), + 'offers' => $offerRepository->findAll(), ])); } - #[Route('/new', name: 'new_listing')] - public function new_listing(Request $request, string $photoDir): Response + #[Route('/new', name: 'new_offer')] + public function newOffer(Request $request, string $photoDir): Response { - $offering = new Offering(); - $form = $this->createForm(OfferingFormType::class, $offering); + $offer = new Offering(); + $form = $this->createForm(OfferingFormType::class, $offer); $user = $this->getUser(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $offering->setByUser($user); - $offering->setCreatedAt(new \DateTime()); + $offer->setByUser($user); + $offer->setCreatedAt(new \DateTime()); if ($photo = $form['photo']->getData()) { $filename = bin2hex(random_bytes(6)).'.'.$photo->guessExtension(); @@ -53,30 +53,30 @@ class OfferController extends AbstractController } catch (FileException $e) { // unable to upload the photo, give up $this->addFlash("error", "There was an error uploading the photo: ".$e); - return $this->redirectToRoute('new_listing'); + return $this->redirectToRoute('new_offer'); } - $offering->setPhotoFilename($filename); + $offer->setPhotoFilename($filename); } - $this->entityManager->persist($offering); + $this->entityManager->persist($offer); $this->entityManager->flush(); - $this->addFlash("success", "Successfully added the new offering!"); + $this->addFlash("success", "Successfully added the new offer!"); return $this->redirectToRoute('homepage'); } - return $this->render('app/new_listing.html.twig', [ + return $this->render('app/new_offer.html.twig', [ 'user' => $this->getUser(), - 'offering_form' => $form->createView(), + 'offer_form' => $form->createView(), ]); } #[Route('/offer/{id}', name: 'show_offer')] - public function show_offer(Offering $offering, WishRepository $wishRepository): Response + public function show_offer(Offering $offer, WishRepository $wishRepository): Response { return $this->render('app/offer.html.twig', [ - 'offer' => $offering, - 'wishes' => $wishRepository->findByUser($offering->getByUser()), + 'offer' => $offer, + 'wishes' => $wishRepository->findByUser($offer->getByUser()), ]); } } diff --git a/templates/app/index.html.twig b/templates/app/index.html.twig index baaafde..f8947ea 100644 --- a/templates/app/index.html.twig +++ b/templates/app/index.html.twig @@ -9,27 +9,27 @@ {% endfor %}

Offers

- {% if offerings|length > 0 %} + {% if offers|length > 0 %}
- {% for offering in offerings %} - -
- {% if offering.photoFilename %} - + {% for offer in offers %} + +
+ {% if offer.photoFilename %} + {% endif %}
-
{{ offering.title }}
-

{{ offering.description }}

+
{{ offer.title }}
+

{{ offer.description }}

{% endfor %}
{% else %} - + {% endif %} {% endblock %} \ No newline at end of file diff --git a/templates/app/new_listing.html.twig b/templates/app/new_listing.html.twig deleted file mode 100644 index d9a9547..0000000 --- a/templates/app/new_listing.html.twig +++ /dev/null @@ -1,19 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block body %} - {% for message in app.flashes('error') %} - - {% endfor %} - -

Add new offering

- {{ form_start(offering_form) }} - {{ form_row(offering_form.title) }} - {{ form_row(offering_form.zipCode) }} - {{ form_row(offering_form.description) }} - {{ form_row(offering_form.photo, { - label: 'Choose file' - }) }} - {{ form_end(offering_form) }} -{% endblock %} \ No newline at end of file diff --git a/templates/app/new_offer.html.twig b/templates/app/new_offer.html.twig new file mode 100644 index 0000000..eee20eb --- /dev/null +++ b/templates/app/new_offer.html.twig @@ -0,0 +1,19 @@ +{% extends 'base.html.twig' %} + +{% block body %} + {% for message in app.flashes('error') %} + + {% endfor %} + +

Add new offer

+ {{ form_start(offer_form) }} + {{ form_row(offer_form.title) }} + {{ form_row(offer_form.zipCode) }} + {{ form_row(offer_form.description) }} + {{ form_row(offer_form.photo, { + label: 'Choose file' + }) }} + {{ form_end(offer_form) }} +{% endblock %} \ No newline at end of file diff --git a/templates/base.html.twig b/templates/base.html.twig index 2405c89..c958c03 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -24,19 +24,19 @@ -
+
{% block body %}{% endblock %}