feat: doctor reply + diagnosis + tracking code per health request
Backend:
- HealthRequest model: TrackingCode (DR-XXXXXX), Diagnosis,
DoctorReply, RepliedAt fields
- Runtime migration: ALTER TABLE adds 4 new columns to existing DB
- POST /api/health-request: auto-generates tracking code, returns it
- PUT /api/health-requests/{id}/reply: doctor sets diagnosis + reply
- GET /api/health-request/track/{code}: public lookup by tracking code
- GET /api/health-requests?phone=: filter history by phone number
Admin panel:
- Request table shows tracking code column (gold badge)
- Detail modal (680px): tracking code header, patient info, full message
- Previous doctor reply shown in green box if exists
- Reply form: diagnosis input + textarea for doctor message
- History panel: all requests from same phone, click to switch
- 'پاسخ / مشاهده' button opens reply modal directly
Frontend:
- After form submit: shows tracking code in green box to user
(format: DR-XXXXXX, stays visible 8 seconds)
- Box auto-hides and form resets after timeout
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -791,6 +791,7 @@
|
||||
</div>
|
||||
<button type="submit" class="form-submit" id="booking-submit">ارسال و رزرو نوبت</button>
|
||||
</form>
|
||||
<div id="booking-tracking" style="display:none"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -844,15 +845,30 @@
|
||||
})
|
||||
});
|
||||
if (!res.ok) throw new Error();
|
||||
btn.textContent = '✓ درخواست شما ثبت شد';
|
||||
const data = await res.json();
|
||||
const code = data.trackingCode || '';
|
||||
btn.textContent = '✓ درخواست ثبت شد';
|
||||
btn.style.background = '#2D7A4F';
|
||||
// Show tracking code to user
|
||||
const trackBox = document.getElementById('booking-tracking');
|
||||
if (trackBox && code) {
|
||||
trackBox.innerHTML = `
|
||||
<div style="background:#E8F5E9;border-radius:14px;padding:1rem 1.4rem;border-right:4px solid #388E3C;margin-top:1rem">
|
||||
<p style="font-size:.85rem;color:#2D7A4F;margin-bottom:.4rem;font-weight:600">✓ درخواست شما با موفقیت ثبت شد</p>
|
||||
<p style="font-size:.82rem;color:#555;margin-bottom:.5rem">کد رهگیری شما برای پیگیری پاسخ پزشک:</p>
|
||||
<div style="font-size:1.3rem;font-weight:700;letter-spacing:.1em;color:#1a1a1a;font-family:monospace;background:#fff;display:inline-block;padding:.3rem .8rem;border-radius:8px;border:1.5px solid #a5d6a7">${code}</div>
|
||||
<p style="font-size:.75rem;color:#777;margin-top:.5rem">این کد را نزد خود نگه دارید. در اسرع وقت با شما تماس میگیریم.</p>
|
||||
</div>`;
|
||||
trackBox.style.display = 'block';
|
||||
}
|
||||
setTimeout(() => {
|
||||
btn.textContent = 'ارسال و رزرو نوبت';
|
||||
btn.style.background = '';
|
||||
btn.disabled = false;
|
||||
e.target.reset();
|
||||
document.getElementById('booking-category').value = 'beauty';
|
||||
}, 3500);
|
||||
if (trackBox) { trackBox.innerHTML=''; trackBox.style.display='none'; }
|
||||
}, 8000);
|
||||
} catch {
|
||||
btn.textContent = 'خطا — دوباره تلاش کنید';
|
||||
btn.style.background = '#c62828';
|
||||
|
||||
Reference in New Issue
Block a user