JOIN OUR REWARDS PROGRAM TODAY AND PARTICIPATE TO WIN!
Eat. Drink. Win.
<div id="create-reward-button" style="position: fixed; bottom: 33px; z-index: 99; right: 43px; display: flex; align-items: center; cursor: pointer; border-radius: 24px; padding: 7px; max-width: 187px; background-color: #1254cc; width: 100%; box-shadow: 0 6px 12px rgba(53, 63, 94, 0.1);">
<div style="min-width: 30px; height: 30px; background-image: url(''); background-color: #ffffff; background-repeat: no-repeat; background-position: 50% 50%; background-size: cover; border-radius: 50%; overflow: hidden;"></div>
<div style="color: #ffffff; border-left: 2px solid #FFFFFF; padding-left: 8px; margin-left: 8px; font-weight: 600; font-size: 12px; font-family: Poppins, sans-serif;">
Join Our Rewards Program Today
</div>
</div>
<div id="reward-modal" style="display: none; align-items: center; justify-content: center; position: fixed; left: 0; right: 0; bottom: 0; top: 0; z-index: 100; background: rgb(8, 3, 29, 0.4)">
<div style="background-color: #ffffff; position: relative; padding: 24px; box-shadow: 0 6px 12px rgba(53, 63, 94, 0.1); border-radius: 8px; max-width: 657px;">
<div style="display: flex; align-items: center">
<div style="font-size: 20px; font-weight: 600; font-family: Poppins, sans-serif">
<span id="reward-title">Rewards program</span>
<span style="display: none" id="reward-error-title">Ooops something went wrong</span>
</div>
<div id="close-reward-modal" style="position: absolute; width: 30px; height: 25px; right: 15px; top: 25px; cursor: pointer">
<span style="display: inline-block; position: absolute; top: 0; right: 15px; width: 2px; height: 20px; background-color: #08031D; transform: rotate(45deg)"></span>
<span style="display: inline-block; position: absolute; top: 0; right: 15px; width: 2px; height: 20px; background-color: #08031D; transform: rotate(-45deg)"></span>
</div>
</div>
<div id="reward-modal-body" style="display: block; font-size: 12px; color: #08031D; font-family: Poppins, sans-serif;">
<div style="font-size: 14px; color: #353F5E; font-family: Poppins, sans-serif; margin-top: 16px; margin-bottom: 13px;"><b>Join us!</b> Sign up and start enjoying the benefits and rewards of our loyalty program.</div>
<div style="margin-bottom: 23px;">
<label style="font-size: 12px; color: #08031D; font-family: Poppins, sans-serif;" for="customer-name">Name *</label>
<input name="name" style="border-radius: 4px; margin-top: 4px; border: 1px solid #77819C; width: 100%; height: 44px; box-sizing: border-box; padding: 11px 16px;" id="customer-name" type="text">
<div id="name-error-message" style="margin-top: 5px; font-size: 12px; color: red; font-family: Poppins, sans-serif;"></div>
</div>
<div>
<label style="font-size: 12px; color: #08031D; font-family: Poppins, sans-serif;" for="customer-email">Email *</label>
<input name="email" style="border-radius: 4px; margin-top: 4px; border: 1px solid #77819C; width: 100%; height: 44px; box-sizing: border-box; padding: 11px 16px;" id="customer-email" type="email">
<div id="email-error-message" style="margin-top: 5px; font-size: 12px; color: red; font-family: Poppins, sans-serif;"></div>
</div>
<div style="display: flex; align-items: flex-start; margin-top: 16px;">
<div>
<label style="font-size: 12px;" for="customer-birth-month">Birthday (optional)</label>
<div>
<input name="birth-month" maxlength="2" placeholder="MM" style="border-radius: 4px; margin-top: 4px; margin-right: 16px; border: 1px solid #77819C; width: 58px; height: 44px; box-sizing: border-box; padding: 11px 16px;" id="customer-birth-month" type="text">
<input name="birth-day" maxlength="2" placeholder="DD" style="border-radius: 4px; margin-top: 4px; margin-right: 16px; border: 1px solid #77819C; width: 58px; height: 44px; box-sizing: border-box; padding: 11px 16px;" id="customer-birth-day" type="text">
<input name="birth-year" maxlength="4" placeholder="YYYY" style="border-radius: 4px; margin-top: 4px; margin-right: 28px; border: 1px solid #77819C; width: 70px; height: 44px; box-sizing: border-box; padding: 11px 16px;" id="customer-birth-year" type="text">
</div>
<div id="birthday-error-message" style="margin-top: 5px; font-size: 12px; color: red; font-family: Poppins, sans-serif;"></div>
</div>
<div style="flex: 1">
<label style="font-size: 12px; color: #08031D; font-family: Poppins, sans-serif;" for="customer-phone">Phone *</label>
<input name="phone" placeholder="(555) 555-5555" style="border-radius: 4px; margin-top: 4px; border: 1px solid #77819C; width: 100%; height: 44px; box-sizing: border-box; padding: 11px 16px;" id="customer-phone" type="tel">
<div id="phone-error-message" style="margin-top: 5px; font-size: 12px; color: red; font-family: Poppins, sans-serif;"></div>
</div>
</div>
<div style="margin-top: 16px;">By clicking submit, you agree to the <a href='https://www.spoton.com/legal/user-terms/' target='_blank'>Terms of Use</a> and <a href='https://www.spoton.com/legal/consumer-privacy/' target='_blank'>Privacy Policy</a>.</div>
<div style="display: flex; align-items: center; justify-content: flex-end; margin-top: 20px;">
<button id="reward-submit" style="font-family: Poppins, sans-serif; font-size: 16px; font-weight: 600; border-radius: 4px; border: 1px solid #1769FF; cursor: pointer; background-color: #1769FF; color: #ffffff; padding: 10px 16px">Submit</button>
</div>
</div>
<div id="reward-modal-success" style="display: none; flex-direction: column; margin-top: 14px;">
<div style="font-family: Poppins, sans-serif; color: #353F5E; font-size: 14px; line-height: 19px;">
<b>Welcome!</b>
<br />
Provide your phone or email on your next visit to start earning.
</div>
<img src="images/settings/loyalty/reward_card.svg" alt="reward_card">
</div>
<div id="reward-modal-error" style="display: none; margin-top: 14px; max-width: 475px">
<div style="font-family: Poppins, sans-serif; color: #353F5E; font-size: 14px; line-height: 19px; margin-bottom: 24px">
Please email or call SpotOn customer service for further assistance.
</div>
<div style="font-family: Poppins, sans-serif; color: #353F5E; font-size: 14px; line-height: 19px;">
support@spoton.com / (877) 814-4102
</div>
<img style="margin: 45px 136px;" src="images/settings/loyalty/reward_error.svg" alt="reward_error">
</div>
</div>
</div>
<script>
const createRewardButton = document.getElementById('create-reward-button');
const rewardModal = document.getElementById('reward-modal');
const closeRewardModal = document.getElementById('close-reward-modal');
const rewardModalBody = document.getElementById('reward-modal-body');
const rewardModalSuccess = document.getElementById('reward-modal-success');
const rewardModalError = document.getElementById('reward-modal-error');
const rewardSubmitButton = document.getElementById('reward-submit');
const customerName = document.getElementById('customer-name');
const customerPhone = document.getElementById('customer-phone');
const customerEmail = document.getElementById('customer-email');
const customerBirthMonth = document.getElementById('customer-birth-month');
const customerBirthDay = document.getElementById('customer-birth-day');
const customerBirthYear = document.getElementById('customer-birth-year');
const dobError = document.getElementById('birthday-error-message');
const nameError = document.getElementById('name-error-message');
const phoneError = document.getElementById('phone-error-message');
const emailError = document.getElementById('email-error-message');
const rewardTitle = document.getElementById('reward-title');
const rewardErrorTitle = document.getElementById('reward-error-title');
const pattern = /^\+1\s|[-()\s]/g;
let isLoading = false;
function resetForm() {
customerName.value = '';
customerPhone.value = ''
customerEmail.value = '';
customerBirthMonth.value = '';
customerBirthDay.value = '';
customerBirthYear.value = '';
nameError.innerText = '';
phoneError.innerText = '';
emailError.innerText = '';
dobError.innerText = '';
customerName.style.borderColor = '';
customerEmail.style.borderColor = '';
customerPhone.style.borderColor = '';
customerBirthMonth.style.borderColor = '';
customerBirthDay.style.borderColor = '';
customerBirthYear.style.borderColor = '';
}
function showErrorModal() {
rewardModalBody.style.display = 'none';
rewardModalError.style.display = 'block';
rewardErrorTitle.style.display = 'block';
rewardTitle.style.display = 'none';
}
createRewardButton.addEventListener('click', function () {
resetForm();
rewardModal.style.display = 'flex';
});
closeRewardModal.addEventListener('click', function () {
rewardModal.style.display = 'none';
rewardModalBody.style.display = 'block';
rewardModalSuccess.style.display = 'none';
rewardModalError.style.display = 'none';
rewardTitle.style.display = 'block';
rewardErrorTitle.style.display = 'none';
resetForm();
});
rewardSubmitButton.addEventListener('click', () => {
rewardSubmitButton.style.opacity = '0.5';
rewardSubmitButton.disabled = true;
let dob;
if (isLoading) {
return;
}
isLoading = true;
if (customerBirthMonth.value && customerBirthDay.value && customerBirthYear.value) {
const month = customerBirthMonth.value.length < 2 ? "0" + customerBirthMonth.value : customerBirthMonth.value;
const day = customerBirthDay.value.length < 2 ? "0" + customerBirthDay.value : customerBirthDay.value;
dob = customerBirthYear.value + "-" + month + "-" + day;
}
fetch("/api/v1/customers/find-upsert-join", {
method: 'POST',
headers: {
'Content-Type':'application/json'
},
body: JSON.stringify({
name: customerName.value,
email: customerEmail.value,
phone: "+1" + customerPhone.value.replace(pattern, ''),
merchantId: "6573741530c59d003c36c644",
source: "37",
dob
}),
})
.then((response) => {
if (response.ok) {
rewardModalBody.style.display = 'none';
rewardModalSuccess.style.display = 'flex';
resetForm();
} else {
response.text().then(text => {
const responseError = JSON.parse(text);
if (responseError.errors) {
const { name, phone, email, phoneNumber, dob: dobErrorMessage, birthDate } = responseError.errors;
if (phoneNumber) {
showErrorModal();
} else {
customerName.style.borderColor = name ? 'red' : '';
customerEmail.style.borderColor = email ? 'red' : '';
customerPhone.style.borderColor = phone ? 'red' : '';
customerBirthMonth.style.borderColor = (dobErrorMessage || birthDate) ? 'red' : '';
customerBirthDay.style.borderColor = (dobErrorMessage || birthDate) ? 'red' : '';
customerBirthYear.style.borderColor = (dobErrorMessage || birthDate) ? 'red' : '';
nameError.innerText = name || '';
phoneError.innerText = phone || '';
emailError.innerText = email || '';
dobError.innerText = dobErrorMessage || birthDate || '';
}
}
})
}
})
.catch(() => {
showErrorModal();
})
.finally(() => {
isLoading = false;
rewardSubmitButton.style.opacity = '1';
rewardSubmitButton.disabled = false;
});
});
</scr