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

Added feature to make sure users have to agree to the General terms a… #432

Merged
merged 3 commits into from
Jun 14, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ public class OrderProductDto {
* Field product should contain Product keys and number of webshop of that product.
*/
HashMap<String, Long> products;
Boolean agreedGTC;
julian9499 marked this conversation as resolved.
Show resolved Hide resolved

/**
* Constructor.
*/
public OrderProductDto() {
this.products = new HashMap<>();
this.agreedGTC = Boolean.FALSE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class WebshopCheckoutController extends WebshopController {
/** Error message no products in Order. */
private static final String ERROR_MESSAGE_ORDER_WITHOUT_PRODUCTS = "Shopping basket can not be empty!";

private static final String ERROR_MESSAGE_ORDER_NOT_AGREED = "You have to agree with the General Terms and Conditions to proceed to checkout.";

/** Username of the user that created this order. */
private static final String USERNAME_ORDER_CREATED = "events-webshop";

Expand Down Expand Up @@ -64,6 +66,11 @@ public WebshopCheckoutController(
@PostMapping
public String checkoutShoppingBasket(RedirectAttributes redirect, @ModelAttribute OrderProductDto orderProductDto) {
try {
if (orderProductDto.getAgreedGTC() == Boolean.FALSE) {
redirect.addFlashAttribute(MODEL_ATTR_ERROR, ERROR_MESSAGE_ORDER_NOT_AGREED);

return REDIRECT_EVENTS_HOME;
}
if (orderProductDto.getProducts().isEmpty()) {
redirect.addFlashAttribute(MODEL_ATTR_ERROR, ERROR_MESSAGE_ORDER_WITHOUT_PRODUCTS);

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/static/css/wisvch-dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ textarea:focus {
transition: box-shadow 0.15s linear, -webkit-box-shadow 0.15s linear
}

#checkoutShoppingBasket {
float: right;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to align the button on the right, since the addition of the checkbox moved it more left.
image, however i noticed that only the float is neccesary, so I will remove the margins.

select.form-control {
height: 2.4375rem !important;
padding: .5rem;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/templates/webshop/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ <h5 class="modal-title" id="shoppingBasketTitle">
<div class="modal-footer">
<form id="orderForm" method="POST" th:action="@{'/checkout'}" th:object="${orderProduct}">
<div id="products"></div>
<input type="checkbox" name="agreedGTC"> I agree to the <a href="https://ch.tudelft.nl/wp-content/uploads/Deelnemersvoorwaarden_versie_12_06_2023.pdf">General Terms and conditions</a></input></br>
<button type="submit" class="btn btn-secondary" id="checkoutShoppingBasket">
Checkout <i class="fa fa-fw fa-arrow-right"></i>
</button>
Expand Down