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