Commit 5446ed83 authored by Almouhannad's avatar Almouhannad

(F) add send to doctor

parent 71900f50
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<!-- #region Name--> <!-- #region Name-->
<div class="custom-user-full-name"> <div class="custom-user-full-name">
<h3 style="border:none;">{{doctor.fullName}}</h3> <h3 style="border:none;">د. {{doctor.fullName}}</h3>
</div> </div>
<!-- #endregion --> <!-- #endregion -->
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<div class="d-grid gap-3 custom-edit-button"> <div class="d-grid gap-3 custom-edit-button">
<a> <a>
<button class="btn btn-outline-secondary" style="width: 100%;" <button class="btn btn-outline-secondary" style="width: 100%;"
(click)="openModal(SendToDoctorModal)"> (click)="onClickSend(); openModal(SendToDoctorModal)">
إرسال إلى طبيب<i class="fas fa-arrow-left"></i> إرسال إلى طبيب<i class="fas fa-arrow-left"></i>
</button> </button>
</a> </a>
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
<select class="text-center mb-3 form-control" <select class="text-center mb-3 form-control"
[(ngModel)]="selectedDoctorId"> [(ngModel)]="selectedDoctorId">
<option value="-1" disabled>يرجى اختيار الطبيب</option> <option value="-1" disabled>يرجى اختيار الطبيب</option>
<option *ngFor="let doctor of doctors" [ngValue]="doctor.id">{{doctor.name}}</option> <option *ngFor="let doctor of doctors" [ngValue]="doctor.id">د. {{doctor.name}}</option>
</select> </select>
</div> </div>
......
...@@ -3,6 +3,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; ...@@ -3,6 +3,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { WaitingListRecord } from '../../../classes/waitingList/waiting-list-record'; import { WaitingListRecord } from '../../../classes/waitingList/waiting-list-record';
import { WaitingListService } from '../../../services/waitingList/waiting-list.service'; import { WaitingListService } from '../../../services/waitingList/waiting-list.service';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { DoctorsService } from '../../../services/doctors/doctors.service';
@Component({ @Component({
selector: 'app-waiting-list-item', selector: 'app-waiting-list-item',
...@@ -13,7 +14,8 @@ export class WaitingListItemComponent { ...@@ -13,7 +14,8 @@ export class WaitingListItemComponent {
constructor(private modalService: NgbModal, constructor(private modalService: NgbModal,
private waitingListService: WaitingListService, private waitingListService: WaitingListService,
private toastrService: ToastrService private toastrService: ToastrService,
private doctorsService: DoctorsService
) {} ) {}
@Input("model") model: WaitingListRecord = new WaitingListRecord(0,0,'',true, new Date(Date.now())); @Input("model") model: WaitingListRecord = new WaitingListRecord(0,0,'',true, new Date(Date.now()));
...@@ -49,15 +51,31 @@ export class WaitingListItemComponent { ...@@ -49,15 +51,31 @@ export class WaitingListItemComponent {
}) })
} }
selectedDoctorId: number = -1; selectedDoctorId: number = -1;
doctors: {id: number, name:string}[] = [ doctors: {id: number, name:string}[] = []
{id: 1, name: 'A'}, onClickSend(): void {
{id: 2, name: 'B'}, this.doctorsService.getAvailable()
{id: 3, name: 'C'}, .subscribe(result => {
{id: 4, name: 'D'}, if (result === null) {
{id: 5, name: 'E'}, this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
] }
else {
this.doctors = result;
}
})
}
onSendToDoctor(): void { onSendToDoctor(): void {
console.log(this.selectedDoctorId); this.waitingListService.SendToDoctor(this.model.id, this.model.patientId, this.selectedDoctorId)
.subscribe(result => {
if (result.status === true) {
this.toastrService.success('تم الإرسال بنجاح ✔');
this.deleted.emit();
}
else {
this.toastrService.error('حدثت مشكلة، يرجى اعادة المحاولة');
}
})
} }
} }
...@@ -25,4 +25,17 @@ export class DoctorsService { ...@@ -25,4 +25,17 @@ export class DoctorsService {
}) })
) )
} }
getAvailable(): Observable< {id: number, name: string}[] | null > {
return this.http.get<{availableDoctors: {id: number, name: string}[] }>(`${this.DOCTORS_ENDPOINT}/Available`)
.pipe(
map((result) => {
return result.availableDoctors;
}),
catchError((error: HttpErrorResponse) => {
console.error(error.error.detail);
return of (null);
})
);
}
} }
...@@ -51,4 +51,23 @@ export class WaitingListService { ...@@ -51,4 +51,23 @@ export class WaitingListService {
); );
} }
public SendToDoctor(waitingListRecordId: number,
patientId: number, doctorId: number) : Observable<{ status: boolean, errorMessage: string | null }> {
var body: any = {
waitingListRecordId: waitingListRecordId,
patientId: patientId,
doctorId: doctorId
}
return this.http.post(`${this.WAITINGLIST_ENDPOINT}/SendToDoctor`, body)
.pipe(
map(_ => {
return {status: true, errorMessage: null};
}),
catchError((error: HttpErrorResponse) => {
console.error(error.error.detail);
return of({status: false, errorMessage: error.error.detail})
})
);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment