e.id), parseInt(engineerId)], site_supervisor_ids: this.supervisors.map(s => s.id), }), }); if (response.ok) { const engineer = this.availableEngineers.find(e => e.id === parseInt(engineerId)); if (engineer) { this.engineers.push({ ...engineer, status: 'active' }); this.selectedEngineer = null; this.engineerSearch = ''; document.querySelector('[data-message]').textContent = 'Engineer assigned successfully!'; } } } catch (error) { console.error('Error:', error); } finally { this.loading = false; } }, async removeEngineer(engineerId) { if (this.loading) return; this.loading = true; try { const response = await fetch('{{ route('admin.projects.update', $project) }}', { method: 'PUT', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': document.querySelector('meta[name=\"csrf-token\"]').content, }, body: JSON.stringify({ engineer_ids: this.engineers.filter(e => e.id !== engineerId).map(e => e.id), site_supervisor_ids: this.supervisors.map(s => s.id), }), }); if (response.ok) { this.engineers = this.engineers.filter(e => e.id !== engineerId); } } catch (error) { console.error('Error:', error); } finally { this.loading = false; } }, async addSupervisor(supervisorId) { if (!supervisorId || this.loading) return; this.loading = true; try { const response = await fetch('{{ route('admin.projects.update', $project) }}', { method: 'PUT', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': document.querySelector('meta[name=\"csrf-token\"]').content, }, body: JSON.stringify({ engineer_ids: this.engineers.map(e => e.id), site_supervisor_ids: [...this.supervisors.map(s => s.id), parseInt(supervisorId)], }), }); if (response.ok) { const supervisor = this.availableSupervisors.find(s => s.id === parseInt(supervisorId)); if (supervisor) { this.supervisors.push({ ...supervisor, status: 'active' }); this.selectedSupervisor = null; this.supervisorSearch = ''; } } } catch (error) { console.error('Error:', error); } finally { this.loading = false; } }, async removeSupervisor(supervisorId) { if (this.loading) return; this.loading = true; try { const response = await fetch('{{ route('admin.projects.update', $project) }}', { method: 'PUT', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': document.querySelector('meta[name=\"csrf-token\"]').content, }, body: JSON.stringify({ engineer_ids: this.engineers.map(e => e.id), site_supervisor_ids: this.supervisors.filter(s => s.id !== supervisorId).map(s => s.id), }), }); if (response.ok) { this.supervisors = this.supervisors.filter(s => s.id !== supervisorId); } } catch (error) { console.error('Error:', error); } finally { this.loading = false; } } }" class="space-y-6" >

Assigned Engineers

Assigned Site Supervisors