Skip to content
Snippets Groups Projects
Commit 224b6fa4 authored by Ethan Allen-Harris's avatar Ethan Allen-Harris Committed by Ethan Allen-Harris
Browse files

made shop toggle a bit nicer

parent 816dbfcc
Branches
No related tags found
1 merge request!114LoggingService service class, new method to add a log to the "Logs" table when...
function toggleShop(shopId){
const textResponse = document.getElementById("status-text");
params = 'shopId=' + shopId;
//Sends list to server
var xhttp = new XMLHttpRequest();
......@@ -7,8 +8,13 @@ function toggleShop(shopId){
xhttp.onload = function () {
if (xhttp.readyState === 4 && xhttp.status === 200) {
console.log(xhttp.responseText);
alert("shop activity has been successfully changed");
location.reload();
if(textResponse.innerText === "Your site is currently LIVE, changing this will hide your site from all customers."){
textResponse.innerText = "Your site is currently not LIVE, changing this will show your site to anyone on ShopHub.";
} else if (textResponse.innerText === "Your site is currently not LIVE, changing this will show your site to anyone on ShopHub."){
textResponse.innerText = "Your site is currently LIVE, changing this will hide your site from all customers.";
} else{
window.location.href = "/settings?tab=shop-setup";
}
} else if (xhttp.readyState === 401) {
alert("Check the credentials and try again.");
} else {
......
......@@ -8,8 +8,8 @@
<body th:fragment="toggleShop">
<div class="content-container">
<p class="title-red">Toggle Live</p>
<p th:if="${shopActive[0] == 1}" class="info-text">Your site is currently LIVE, changing this will hide your site from all customers.</p>
<p th:if="${shopActive[0] == 0}" class="info-text">Your site is currently not LIVE, changing this will show your site to anyone on ShopHub.</p>
<p th:if="${shopActive[0] == 1}" class="info-text" id="status-text">Your site is currently LIVE, changing this will hide your site from all customers.</p>
<p th:if="${shopActive[0] == 0}" class="info-text" id="status-text">Your site is currently not LIVE, changing this will show your site to anyone on ShopHub.</p>
<button class="button is-danger is-small is-outlined" style="margin-top: 10px;" th:onclick="toggleShop([[${shop.shopId}]])">Toggle</button>
</div>
<p class="horizontal-line"><br></p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment