Spaces:
Sleeping
Sleeping
File size: 17,076 Bytes
c024705 c1ce623 c024705 c1ce623 c024705 eeacc46 c024705 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Professional Form Test - AIMHSA</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/admin-lte@3.2/dist/css/adminlte.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
body { padding: 20px; background: #f4f4f4; }
.test-container { max-width: 1200px; margin: 0 auto; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.test-section { margin: 20px 0; padding: 15px; border: 1px solid #ddd; border-radius: 5px; }
.success { background-color: #d4edda; border-color: #c3e6cb; }
.error { background-color: #f8d7da; border-color: #f5c6cb; }
.warning { background-color: #fff3cd; border-color: #ffeaa7; }
.info { background-color: #d1ecf1; border-color: #bee5eb; }
button { padding: 10px 20px; margin: 5px; cursor: pointer; border: none; border-radius: 4px; }
.btn-primary { background: #007bff; color: white; }
.btn-success { background: #28a745; color: white; }
.btn-warning { background: #ffc107; color: black; }
.btn-danger { background: #dc3545; color: white; }
.btn-info { background: #17a2b8; color: white; }
/* Form input fixes */
.form-control {
background-color: #fff !important;
border: 1px solid #ced4da !important;
color: #497060 !important;
}
.form-control:focus {
border-color: #80bdff !important;
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important;
}
.form-control.is-invalid {
border-color: #dc3545 !important;
}
.form-check-input {
margin-top: 0.25rem !important;
}
.modal-body .form-control {
background-color: #fff !important;
color: #497060 !important;
}
</style>
</head>
<body>
<div class="test-container">
<h1>π§ͺ Professional Form Test - AIMHSA</h1>
<p>This page tests the professional management functionality to ensure all input fields work correctly.</p>
<div class="test-section info">
<h3>π Test Instructions</h3>
<ol>
<li>Click "Test Add Professional" to test the add functionality</li>
<li>Fill out the form and test validation</li>
<li>Click "Test Edit Professional" to test the edit functionality</li>
<li>Check console for detailed logs</li>
</ol>
</div>
<div class="test-section">
<h3>π§ Test Controls</h3>
<button class="btn btn-primary" onclick="testAddProfessional()">Test Add Professional</button>
<button class="btn btn-warning" onclick="testEditProfessional()">Test Edit Professional</button>
<button class="btn btn-info" onclick="testFormValidation()">Test Form Validation</button>
<button class="btn btn-success" onclick="testAPI()">Test API Connection</button>
</div>
<div class="test-section">
<h3>π Test Results</h3>
<div id="testResults">
<p>Click the test buttons above to see results here.</p>
</div>
</div>
</div>
<!-- Professional Modal (copied from admin_dashboard.html) -->
<div class="modal fade" id="professionalModal" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modalTitle">Add New Professional</h4>
<button type="button" class="close" data-dismiss="modal">
<span>×</span>
</button>
</div>
<div class="modal-body">
<form id="professionalForm">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="username">Username *</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="password">Password <span id="passwordRequired">*</span></label>
<input type="password" class="form-control" id="password" name="password" required>
<small id="passwordHelp" class="form-text text-muted" style="display: none;">Leave blank to keep current password</small>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="first_name">First Name *</label>
<input type="text" class="form-control" id="first_name" name="first_name" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="last_name">Last Name *</label>
<input type="text" class="form-control" id="last_name" name="last_name" required>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="email">Email *</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="phone">Phone</label>
<input type="tel" class="form-control" id="phone" name="phone">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="specialization">Specialization *</label>
<select class="form-control" id="specialization" name="specialization" required>
<option value="">Select Specialization</option>
<option value="psychiatrist">Psychiatrist</option>
<option value="psychologist">Psychologist</option>
<option value="counselor">Counselor</option>
<option value="social_worker">Social Worker</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="experience_years">Experience (Years)</label>
<input type="number" class="form-control" id="experience_years" name="experience_years" min="0" value="0">
</div>
</div>
</div>
<div class="form-group">
<label for="expertise_areas">Expertise Areas *</label>
<div class="row">
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="expertise" value="depression" id="expertise_depression">
<label class="form-check-label" for="expertise_depression">Depression</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="expertise" value="anxiety" id="expertise_anxiety">
<label class="form-check-label" for="expertise_anxiety">Anxiety</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="expertise" value="ptsd" id="expertise_ptsd">
<label class="form-check-label" for="expertise_ptsd">PTSD</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="expertise" value="trauma" id="expertise_trauma">
<label class="form-check-label" for="expertise_trauma">Trauma</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="expertise" value="suicide" id="expertise_suicide">
<label class="form-check-label" for="expertise_suicide">Suicide Prevention</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="expertise" value="crisis" id="expertise_crisis">
<label class="form-check-label" for="expertise_crisis">Crisis Intervention</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="expertise" value="youth" id="expertise_youth">
<label class="form-check-label" for="expertise_youth">Youth Mental Health</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="expertise" value="family" id="expertise_family">
<label class="form-check-label" for="expertise_family">Family Therapy</label>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="district">District</label>
<input type="text" class="form-control" id="district" name="district" placeholder="e.g., Gasabo, Kigali">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="consultation_fee">Consultation Fee (RWF)</label>
<input type="number" class="form-control" id="consultation_fee" name="consultation_fee" min="0">
</div>
</div>
</div>
<div class="form-group">
<label for="bio">Bio</label>
<textarea class="form-control" id="bio" name="bio" rows="3" placeholder="Brief professional background..."></textarea>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="saveProfessionalBtn">Save Professional</button>
</div>
</div>
</div>
</div>
<script>
// Test functions
function testAddProfessional() {
console.log('π§ͺ Testing Add Professional...');
$('#modalTitle').text('Add New Professional');
$('#passwordRequired').text('*');
$('#passwordHelp').hide();
$('#password').prop('required', true);
resetForm();
$('#professionalModal').modal('show');
addResult('β
Add Professional modal opened successfully');
}
function testEditProfessional() {
console.log('π§ͺ Testing Edit Professional...');
$('#modalTitle').text('Edit Professional');
$('#passwordRequired').text('');
$('#passwordHelp').show();
$('#password').prop('required', false);
// Fill form with sample data
$('#username').val('test_professional');
$('#first_name').val('Test');
$('#last_name').val('Professional');
$('#email').val('test@example.com');
$('#phone').val('+250123456789');
$('#specialization').val('counselor');
$('#experience_years').val('5');
$('#district').val('Gasabo');
$('#consultation_fee').val('50000');
$('#bio').val('Test professional bio');
// Check some expertise areas
$('#expertise_depression').prop('checked', true);
$('#expertise_anxiety').prop('checked', true);
$('#professionalModal').modal('show');
addResult('β
Edit Professional modal opened with sample data');
}
function testFormValidation() {
console.log('π§ͺ Testing Form Validation...');
resetForm();
// Test empty form validation
$('#saveProfessionalBtn').click();
addResult('β
Form validation test completed (check console for details)');
}
function testAPI() {
console.log('π§ͺ Testing API Connection...');
fetch('https://prodevroger-ishingiro.hf.space/admin/professionals')
.then(response => {
if (response.ok) {
addResult('β
API connection successful');
return response.json();
} else {
throw new Error(`HTTP ${response.status}`);
}
})
.then(data => {
addResult(`β
API returned ${data.professionals ? data.professionals.length : 0} professionals`);
})
.catch(error => {
addResult(`β API connection failed: ${error.message}`);
});
}
function resetForm() {
$('#professionalForm')[0].reset();
$('input[name="expertise"]').prop('checked', false);
$('.is-invalid').removeClass('is-invalid');
}
function addResult(message) {
const timestamp = new Date().toLocaleTimeString();
const resultDiv = document.createElement('div');
resultDiv.innerHTML = `<strong>[${timestamp}]</strong> ${message}`;
document.getElementById('testResults').appendChild(resultDiv);
}
// Initialize
$(document).ready(function() {
console.log('π Professional Form Test Page Loaded');
addResult('Page loaded successfully');
});
</script>
</body>
</html>
|