Massage Spa & Salons

Provider Dashboard

Loading dashboard…

My Profiles

You haven’t created any profiles yet.

You can manage up to 2 free profiles.

Claim Business

Please answer the following security questions to prove ownership of .

Edit Profile

`;
});
listContainer.innerHTML = html;
}

window.searchBusiness = async function(e) {
e.preventDefault();
const btn = document.getElementById(‘btn-search’);
btn.disabled = true;
btn.textContent = ‘Searching…’;
const name = document.getElementById(‘search-name’).value;
const location = document.getElementById(‘search-location’).value;
try {
const searchFn = httpsCallable(functions, ‘searchProfiles’);
const res = await searchFn({ name, location });
const resultsDiv = document.getElementById(‘search-results’);
const listDiv = document.getElementById(‘search-results-list’);
resultsDiv.style.display = ‘block’;
if (res.data && res.data.matches && res.data.matches.length > 0) {
let html = ”;
res.data.matches.forEach(match => {
html += `

${match.title}

${match.address || ‘Location unknown’}

`;
});
listDiv.innerHTML = html;
} else {
listDiv.innerHTML = ‘

No existing profiles found. You can create a brand new one!

‘;
}
} catch (err) {
console.error(err);
alert(‘Search failed: ‘ + err.message);
} finally {
btn.disabled = false;
btn.textContent = ‘Search Directory’;
}
}

window.submitClaim = async function(e) {
e.preventDefault();
const btn = document.getElementById(‘btn-claim-submit’);
btn.disabled = true;
btn.textContent = ‘Submitting…’;
const msg = document.getElementById(‘msg-claim’);
msg.style.display = ‘none’;

try {
await addDoc(collection(db, “pending_claims”), {
uid: currentUser.uid,
email: currentUser.email,
wp_post_id: targetClaimPostId,
business_name: targetClaimBizName,
q_founded: document.getElementById(‘claim-q1’).value,
q_phone: document.getElementById(‘claim-q2’).value,
q_owner: document.getElementById(‘claim-q3’).value,
q_proof: document.getElementById(‘claim-q4’).value,
status: ‘pending’,
submittedAt: new Date().toISOString()
});
msg.textContent = ‘Claim application submitted successfully! Our team will review your answers and grant access within 24-48 hours.’;
msg.className = ‘msg success’;
document.getElementById(‘btn-claim-submit’).style.display = ‘none’;
} catch (err) {
console.error(err);
msg.textContent = ‘Error: ‘ + err.message;
msg.className = ‘msg error’;
btn.disabled = false;
btn.textContent = ‘Submit Claim Application’;
}
}

window.saveProfile = async function(e) {
e.preventDefault();
const btn = document.getElementById(‘btn-save’);
btn.disabled = true;
btn.textContent = ‘Saving…’;
const msg = document.getElementById(‘msg-edit’);
msg.style.display = ‘none’;

// If it’s a 2nd profile, we set the first profile as the parent_business
let parentBusinessId = null;
if (!currentEditPostId && userData.owned_profiles && userData.owned_profiles.length > 0) {
parentBusinessId = userData.owned_profiles[0];
}

const payload = {
title: document.getElementById(‘prof-title’).value,
description: document.getElementById(‘prof-desc’).value,
address: document.getElementById(‘prof-address’).value,
contact_phone: document.getElementById(‘prof-phone’).value,
services: document.getElementById(‘prof-services’).value,
parent_business: parentBusinessId
};

if (currentEditPostId) {
payload.wp_post_id = currentEditPostId;
}

try {
const saveProfileFn = httpsCallable(functions, ‘saveProfile’);
const result = await saveProfileFn(payload);
const newPostId = result.data.wp_post_id;
// Add to owned_profiles if new
if (!currentEditPostId) {
const owned = userData.owned_profiles || [];
owned.push(newPostId);
userData.owned_profiles = owned;
await updateDoc(doc(db, “users”, currentUser.uid), { owned_profiles: owned });
}

msg.textContent = ‘Profile saved securely to WordPress!’;
msg.className = ‘msg success’;
// Go back to list after 2 seconds
setTimeout(() => showList(), 2000);
} catch (err) {
console.error(err);
msg.textContent = err.message || ‘Failed to save profile.’;
msg.className = ‘msg error’;
btn.disabled = false;
btn.textContent = ‘Save Profile’;
}
}