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

#816 Add privacy policy agreement to order page. #840

Merged
merged 2 commits into from
May 2, 2019
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
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