Skip to content

Commit

Permalink
#816 Add privacy policy agreement to order page. (#840)
Browse files Browse the repository at this point in the history
* Add privacy policy agreement to order page.

* Create todo to test privacy policy agreement and make the checkbox the same color as its text
  • Loading branch information
ArtemijRodionov authored May 2, 2019
1 parent 609223f commit 27ffe12
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 8 deletions.
26 changes: 19 additions & 7 deletions front/js/components/order.es6
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(() => {
const DOM = {
$fancybox: $('.fancybox'),
$formErrorText: $('.js-form-error-text'),
$contactsError: $('.js-contacts-error'),
$privacyPolicyError: $('.js-privacy-policy-error'),
$order: $('.js-order-contain'),
yandexFormWrapper: '#yandex-form-wrapper',
yandexForm: '#yandex-form',
Expand All @@ -13,6 +14,7 @@
paymentOptions: 'input[name=payment_type]',
defaultPaymentOptions: 'input[for=id_payment_type_0]',
orderFieldData: $('#order-form-full').data('fields'),
privacyCheckbox: '.js-privacy-checkbox',
};

const config = {
Expand Down Expand Up @@ -161,14 +163,19 @@
return orderInfo;
};

/**
* Return true if form has valid phone & email.
*/
function isValid(customerInfo) {
function isContactsValid(customerInfo) {
return helpers.isPhoneValid(customerInfo.phone) &&
helpers.isEmailValid(customerInfo.email);
}

function isPrivacyPolicyAccepted() {
return $(DOM.privacyCheckbox).is(':checked');
}

function showFormError($error) {
$error.removeClass('hidden').addClass('shake animated');
}

function renderYandexForm(formData) {
const formHtml = `
<form action="${formData.yandex_kassa_link}" method="POST" id="yandex-form">
Expand Down Expand Up @@ -198,8 +205,13 @@
event.preventDefault();
const orderInfo = getOrderInfo();

if (!isValid(orderInfo)) {
DOM.$formErrorText.removeClass('hidden').addClass('shake animated');
if (!isContactsValid(orderInfo)) {
showFormError(DOM.$contactsError);
return;
}

if (!isPrivacyPolicyAccepted()) {
showFormError(DOM.$privacyPolicyError);
return;
}

Expand Down
1 change: 1 addition & 0 deletions front/less/common/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
@c-price-border-color: #dddddd;

@c-search-area: #616161;
@c-privacy-check: #A0A0A0;
@c-stock-in: #54bf5f;
@c-stock-out: #ffd180;
@c-stuff-link-border: #BEC3C8;
Expand Down
34 changes: 34 additions & 0 deletions front/less/pages/order.less
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,40 @@ div.info {
width: 145px;
}

.privacy-policy-form {
position: relative;
line-height: 1.8;
margin: 0 0 15px;
color: @c-privacy-check;
font-size: @f-size-base - 4;

input {
border: none;
background: @c-privacy-check;
color: @c-privacy-check;
cursor: pointer;

&:checked {
border: transparent;
box-shadow: 0 1px 1px transparent inset;
opacity: 1;
}
}

label {
a {
color: @c-privacy-check;
}

cursor: pointer;
width: 83%;

.Q(@sm; {
width: auto;
});
}
}

.payment-types-form {
position: relative;
}
Expand Down
16 changes: 15 additions & 1 deletion templates/ecommerce/order/table_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,25 @@ <h1>Оформление заказа</h1>
<div class="payment-types-form">
{% include 'ecommerce/order/payment_types.html' %}
</div>
{% comment %} @todo #816:30m Test privacy policy agreement.{% endcomment %}

{% comment %} @todo #816:30m Make the checkbox to the same color as its text.{% endcomment %}
<div class="privacy-policy-form">
<label>
<input class="js-privacy-checkbox" type="checkbox" required checked>
Я согласен на <a href="/media/privacy-policy.pdf">обработку персональных данных</a>
</label>
</div>
</div>

<div class="order-user-info">
<div class="order-info-header text-center">ФОРМА ЗАКАЗА</div>
<p class="error-msg hidden js-form-error-text">Введите ваш телефон и почтовый адрес</p>
<p class="error-msg hidden js-contacts-error">
Введите ваш телефон, почтовый адрес.
</p>
<p class="error-msg hidden js-privacy-policy-error">
Примите соглашение на обработку персональных данных.
</p>

<div class="order-form-right form-horizontal">
<div class="form-group">
Expand Down

2 comments on commit 27ffe12

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 27ffe12 May 2, 2019

Choose a reason for hiding this comment

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

Puzzle 816-b6729641 discovered in templates/ecommerce/order/table_form.html and submitted as #841. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 27ffe12 May 2, 2019

Choose a reason for hiding this comment

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

Puzzle 816-0b7aa454 discovered in templates/ecommerce/order/table_form.html and submitted as #842. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.