Skip to content

Commit

Permalink
reformat and add some php to reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
mspeake161 committed Feb 18, 2025
1 parent e88e406 commit 6e50d7f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 47 deletions.
29 changes: 15 additions & 14 deletions public/js/rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ const ratingContainer = document.querySelector('.rating');
const stars = ratingContainer.querySelectorAll('.star');

stars.forEach(star => {
star.addEventListener('click', () => {
const rating = parseInt(star.dataset.value, 10);
ratingContainer.dataset.rating = rating;
star.addEventListener('click', () => {
const rating = parseInt(star.dataset.value, 10);
ratingContainer.dataset.rating = rating;

// Update star appearance
stars.forEach(s => {
if (s.dataset.value <= rating) {
s.classList.add('active');
} else {
s.classList.remove('active');
}
// Update star appearance
stars.forEach(s => {
if (s.dataset.value <= rating) {
s.classList.add('active');
} else {
s.classList.remove('active');
}
});

// You can now submit the rating to your server or perform other actions
console.log("Rating submitted:", rating);
});
});

// You can now submit the rating to your server or perform other actions
console.log("Rating submitted:", rating);
});
});
66 changes: 33 additions & 33 deletions resources/views/pages/review.blade.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
@extends('layouts.page')
@section('title','Review')
@section('content')
<div class="review">
<h1>Create Review</h1>
<!-- Need a form submission -->

<form method="POST" action="/review" onsubmit="validateReviewForm(event)">

</form>
<!-- Image + Name of Product -->
<img></img>
<p></p>
<div class="line-break"><br></div>
<h2>Overall rating</h2>
<!-- Stars -->
<div class="rating" data-rating="0">
<span class="star" data-value="1">&#9734;</span>
<span class="star" data-value="2">&#9734;</span>
<span class="star" data-value="3">&#9734;</span>
<span class="star" data-value="4">&#9734;</span>
<span class="star" data-value="5">&#9734;</span>
<div class="review">
<h1>Create Review</h1>
<!-- Need a form submission -->
<form method="POST" action="/review">
<!-- Image + Name of Product -->
<img src="{{asset($product->getMainImage())}}" alt="Product Image">
<p>{{$product->name}}</p>
<div class="line-break"><br></div>
<h2>Overall rating</h2>
<!-- Stars -->
<div class="rating" data-rating="0">
<span class="star" data-value="1">&#9734;</span>
<span class="star" data-value="2">&#9734;</span>
<span class="star" data-value="3">&#9734;</span>
<span class="star" data-value="4">&#9734;</span>
<span class="star" data-value="5">&#9734;</span>
</div>
<script src="{{ asset('js/rating.js') }}"></script>
<div class="line-break"><br></div>
<h2>Add a headline</h2>
<!-- Input for headline -->
<input type="text" placeholder="What's most important to know?"></input>
<div class="line-break"><br></div>
<h2>Add a written review</h2>
<!-- Input for review -->
<textarea name="message" id="message" cols="10" rows="7"
placeholder="What did you like or dislike? What did you use this product for?" required
style="resize: none"></textarea>
<div class="line-break"><br></div>
<p>We will notify you via email as soon as your review is processed.</p>
<!-- Submit button -->
<button>Submit</button>
</form>
</div>
<script src="{{ asset('js/rating.js') }}"></script>
<div class="line-break"><br></div>
<h2>Add a headline</h2>
<!-- Input for headline -->
<input type="text" placeholder="What's most important to know?"></input>
<div class="line-break"><br></div>
<h2>Add a written review</h2>
<!-- Input for review -->
<textarea name="message" id="message" cols="10" rows="7" placeholder="What did you like or dislike? What did you use this product for?" required style="resize: none"></textarea>
<div class="line-break"><br></div>
<p>We will notify you via email as soon as your review is processed.<p>
<!-- Submit button -->
<button>Submit</button>
</div>
@endsection

0 comments on commit 6e50d7f

Please sign in to comment.