diff --git a/DrSousan.Api/Pages/Index.cshtml b/DrSousan.Api/Pages/Index.cshtml
index 9671b55..c2256e8 100644
--- a/DrSousan.Api/Pages/Index.cshtml
+++ b/DrSousan.Api/Pages/Index.cshtml
@@ -650,24 +650,6 @@
-
-
@@ -775,37 +757,39 @@
@@ -835,65 +819,56 @@
});
});
- // Form submission
- function handleSubmit(e) {
+ // Main booking form — submits to /api/health-request
+ async function handleSubmit(e) {
e.preventDefault();
- const btn = e.target.querySelector('.form-submit');
- btn.textContent = '✓ درخواست شما ثبت شد';
- btn.style.background = '#2D7A4F';
- setTimeout(() => {
- btn.textContent = 'ارسال و رزرو نوبت';
- btn.style.background = '';
- e.target.reset();
- }, 3000);
- }
-
- // Health care request form
- function openHealthForm(category) {
- document.getElementById('hf-category').value = category;
- document.getElementById('healthFormTitle').textContent =
- category === 'health' ? 'درخواست مراقبت سلامت عمومی' : 'درخواست مشاوره زیبایی پوست';
- const wrap = document.getElementById('healthFormWrap');
- wrap.classList.remove('hidden');
- setTimeout(() => wrap.scrollIntoView({behavior:'smooth', block:'center'}), 100);
- }
- async function submitHealthForm() {
- const name = document.getElementById('hf-name').value.trim();
- const phone = document.getElementById('hf-phone').value.trim();
- if (!name || !phone) { alert('نام و شماره تلفن الزامی است'); return; }
- const btn = document.getElementById('hf-submit');
+ const btn = document.getElementById('booking-submit');
+ const firstName = document.getElementById('booking-firstname').value.trim();
+ const lastName = document.getElementById('booking-lastname').value.trim();
+ const phone = document.getElementById('booking-phone').value.trim();
+ const service = document.getElementById('booking-service').value;
+ const message = document.getElementById('booking-message').value.trim();
+ const category = document.getElementById('booking-category').value || 'beauty';
btn.textContent = '...در حال ارسال';
btn.disabled = true;
try {
- const body = {
- fullName: name,
- phoneNumber: phone,
- email: document.getElementById('hf-email').value,
- message: document.getElementById('hf-message').value,
- category: document.getElementById('hf-category').value
- };
const res = await fetch('/api/health-request', {
method: 'POST',
headers: {'Content-Type':'application/json'},
- body: JSON.stringify(body)
+ body: JSON.stringify({
+ fullName: firstName + ' ' + lastName,
+ phoneNumber: phone,
+ email: '',
+ message: (service ? 'خدمت: ' + service + '\n' : '') + message,
+ category: category
+ })
});
if (!res.ok) throw new Error();
btn.textContent = '✓ درخواست شما ثبت شد';
btn.style.background = '#2D7A4F';
- ['hf-name','hf-phone','hf-email','hf-message'].forEach(id => document.getElementById(id).value='');
setTimeout(() => {
- document.getElementById('healthFormWrap').classList.add('hidden');
- btn.textContent = 'ارسال درخواست';
+ btn.textContent = 'ارسال و رزرو نوبت';
btn.style.background = '';
btn.disabled = false;
- }, 3000);
+ e.target.reset();
+ document.getElementById('booking-category').value = 'beauty';
+ }, 3500);
} catch {
btn.textContent = 'خطا — دوباره تلاش کنید';
btn.style.background = '#c62828';
- setTimeout(() => { btn.textContent='ارسال درخواست'; btn.style.background=''; btn.disabled=false; }, 2500);
+ setTimeout(() => { btn.textContent='ارسال و رزرو نوبت'; btn.style.background=''; btn.disabled=false; }, 2500);
}
}
+ // Health section buttons scroll to contact form and pre-select category
+ function openHealthForm(category) {
+ document.getElementById('booking-category').value = category;
+ // Pre-select matching service if health
+ const sel = document.getElementById('booking-service');
+ if (category === 'health') sel.value = 'سلامت عمومی';
+ document.getElementById('contact').scrollIntoView({behavior:'smooth', block:'start'});
+ }
+
// Active nav link on scroll
const sections = document.querySelectorAll('section[id]');
window.addEventListener('scroll', () => {