Commit a6b2cfad authored by Almouhannad's avatar Almouhannad

(F) Change srarch to medicine behavior

parent beead90c
......@@ -71,29 +71,41 @@ export class CreateVisitComponent implements OnInit {
diagnosis: string;
medicines: VisitMedicine[] = [];
onAddMedicine(visitMedicine: VisitMedicine){
this.medicines.push(visitMedicine);
onAddMedicine(visitMedicine: VisitMedicine) {
const existingMedicine = this.medicines.find(medicine => medicine.id === visitMedicine.id);
if (!existingMedicine) {
this.medicines.push(visitMedicine);
}
else {
this.toastr.error('هذا الدواء موجود بالفعل');
}
}
onDeleteMedicine(index: number) {
this.medicines.splice(index, 1);
}
onSubmit(): void {
var userId = this.authenticationService.getUserData()!.id;
this.visitsService.create(userId,
this.employeeId, this.diagnosis, this.medicines)
.subscribe(result => {
if(result.status === false) {
this.toastr.error("حدثت مشكلة، يرجى إعادة المحاولة");
this.router.navigateByUrl('doctor/waitinglist');
}
else {
this.doctorsService.changeStatusByUserId(userId, 'متاح')
.subscribe(_ => {});
this.toastr.success('تم تسجيل الزيارة بنجاح ✔');
this.router.navigateByUrl(`doctor/history/${this.employeeId}`);
}
})
if (this.medicines.length !== 0) {
var userId = this.authenticationService.getUserData()!.id;
this.visitsService.create(userId,
this.employeeId, this.diagnosis, this.medicines)
.subscribe(result => {
if(result.status === false) {
this.toastr.error("حدثت مشكلة، يرجى إعادة المحاولة");
this.router.navigateByUrl('doctor/waitinglist');
}
else {
this.doctorsService.changeStatusByUserId(userId, 'متاح')
.subscribe(_ => {});
this.toastr.success('تم تسجيل الزيارة بنجاح ✔');
this.router.navigateByUrl(`doctor/history/${this.employeeId}`);
}
})
}
else {
this.toastr.error("يرجى إضافة أدوية");
}
}
}
......@@ -14,7 +14,7 @@
.custom-field .custom-input:focus {
box-shadow: 0 0 0 0.1em var(--heading-color);
}
}
.custom-no-button {
......@@ -27,7 +27,7 @@
margin: auto;
}
.custom-medicine-button .btn{
.custom-medicine-button .btn {
width: 100%;
font-weight: 700;
margin: auto;
......@@ -36,7 +36,7 @@
background-color: white;
}
.custom-medicine-button .btn:hover{
.custom-medicine-button .btn:hover {
margin: auto;
color: white;
border-color: var(--heading-color);
......@@ -44,7 +44,7 @@
}
.custom-selected-button .btn{
.custom-selected-button .btn {
width: 100%;
font-weight: 700;
margin: auto;
......@@ -53,9 +53,24 @@
background-color: white;
}
.custom-selected-button .btn:hover{
.custom-selected-button .btn:hover {
margin: auto;
color: white;
border-color: var(--accent-color);
background-color: var(--accent-color);
}
.custom-medicine-button {
animation: fade-in 0.5s;
}
@keyframes fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
\ No newline at end of file
......@@ -31,12 +31,15 @@
<div *ngIf="isSelected">
<div class="custom-field">
<input class="form-control custom-input" type="number" placeholder="يرجى ادخال الكمية" dir="ltr"
[(ngModel)]="number">
min="1"
[(ngModel)]="number" #numberField="ngModel">
<p *ngIf="numberField.errors && numberField.errors['min']" class="text-danger text-center"
style="font-weight: 800;">يرجى ادخال قيمة صالحة</p>
</div>
<div class="custom-ok-button mt-3" style="width:100%">
<button class="btn btn-outline-primary" (click)="onSave(); parentModal.dismiss()"
[disabled]="number === null">حفظ</button>
[disabled]="number === null || number! <= 0">حفظ</button>
</div>
</div>
......
......@@ -22,7 +22,7 @@ export class SearchForMedicineComponent implements OnInit {
// Listen to input changes with delay
this.prefix.valueChanges.pipe(
debounceTime(1000),
debounceTime(500),
distinctUntilChanged(),
filter(value => value.trim().length >= 2), // igonre less than 2 letters
switchMap(value => this.medicinesService.getAll(value))
......
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