Commit 85554f52 authored by Almouhannad's avatar Almouhannad

(F) Use fixed messages

parent a6b2cfad
......@@ -5,6 +5,7 @@ import { CreateDoctorUserCommand } from '../../../classes/admin/create-doctor-us
import { NgForm } from '@angular/forms';
import { Router } from '@angular/router';
import { ViewportScroller } from '@angular/common';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-create-doctor-user-form',
......@@ -52,7 +53,7 @@ export class CreateDoctorUserFormComponent {
}
else {
this.toastrService.success("تم إضافة الطبيب بنجاح ✔");
this.toastrService.success(ConstantMessages.SUCCESS_ADD_DOCTOR);
this.router.navigateByUrl('admin/doctors');
}
}
......
......@@ -4,6 +4,7 @@ import { ToastrService } from 'ngx-toastr';
import { NgForm } from '@angular/forms';
import { UpdateDoctorPersonalDataQuery } from '../../../classes/admin/update-doctor-personal-data-query';
import { Router } from '@angular/router';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-update-doctor-personal-data-form',
......@@ -41,7 +42,7 @@ export class UpdateDoctorPersonalDataFormComponent {
result => {
if (result.status === true)
{
this.toastrService.success('تم تعديل البيانات بنجاح ✔');
this.toastrService.success(ConstantMessages.SUCCESS_EDIT);
this.router.navigateByUrl('admin/doctors');
}
else {
......
......@@ -4,6 +4,7 @@ import { DoctorUsersService } from '../../../services/admin/doctor-users.service
import { ToastrService } from 'ngx-toastr';
import { Router } from '@angular/router';
import { NgForm } from '@angular/forms';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-update-doctor-user-data-form',
......@@ -35,7 +36,7 @@ export class UpdateDoctorUserDataFormComponent {
.subscribe(
result => {
if (result.status === true) {
this.toastrService.success('تم تحديث البيانات بنجاح ✔');
this.toastrService.success(ConstantMessages.SUCCESS_EDIT);
this.router.navigateByUrl('admin/doctors');
}
else {
......
......@@ -4,6 +4,7 @@ import { LoginCommand } from '../../../classes/authentication/Login/login-comman
import { AuthenticationService } from '../../../services/authentication/authentication.service';
import { UserData } from '../../../classes/authentication/user-data';
import { ToastrService } from 'ngx-toastr';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-login-form',
......@@ -49,7 +50,7 @@ export class LoginFormComponent {
this.errorMessage = result.errorMessage!;
}
else{
this.toastrService.success("تم تسجيل الدخول بنجاح ✔");
this.toastrService.success(ConstantMessages.SUCCESS_LOGIN);
this.loggedIn.emit(this.authenticationService.getUserData()!);
}
}
......
......@@ -25,7 +25,7 @@ export class AskForSerialNumberComponent {
@ViewChild("form") form: NgForm;
isFailure: boolean = false;
errorMessage: string = 'الموظف غير موجود';
errorMessage: string = '';
serialNumber: string;
......
......@@ -9,6 +9,7 @@ import { VisitMedicine } from '../../../classes/medicine/visit-medicine';
import { VisitsService } from '../../../services/visits/visits.service';
import { AuthenticationService } from '../../../services/authentication/authentication.service';
import { DoctorsService } from '../../../services/doctors/doctors.service';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-create-visit',
......@@ -35,7 +36,7 @@ export class CreateVisitComponent implements OnInit {
this.activatedRoute.params.subscribe(params => {
this.employeeId = params['id'];
if (isNaN(this.employeeId)) {
this.toastr.error("حدثت مشكلة، يرجى إعادة المحاولة");
this.toastr.error(ConstantMessages.ERROR);
this.router.navigateByUrl('doctor/waitinglist');
}
this.setEmployee();
......@@ -47,7 +48,7 @@ export class CreateVisitComponent implements OnInit {
this.employeesDataService.getById(this.employeeId)
.subscribe(result => {
if (result.status === false) {
this.toastr.error("حدثت مشكلة، يرجى إعادة المحاولة");
this.toastr.error(ConstantMessages.ERROR);
this.router.navigateByUrl('doctor/waitinglist');
}
else {
......@@ -77,7 +78,7 @@ export class CreateVisitComponent implements OnInit {
this.medicines.push(visitMedicine);
}
else {
this.toastr.error('هذا الدواء موجود بالفعل');
this.toastr.error(ConstantMessages.ERROR_ALREADY_ADDED_MEDICINE);
}
}
onDeleteMedicine(index: number) {
......@@ -91,19 +92,19 @@ export class CreateVisitComponent implements OnInit {
this.employeeId, this.diagnosis, this.medicines)
.subscribe(result => {
if(result.status === false) {
this.toastr.error("حدثت مشكلة، يرجى إعادة المحاولة");
this.toastr.error(ConstantMessages.ERROR);
this.router.navigateByUrl('doctor/waitinglist');
}
else {
this.doctorsService.changeStatusByUserId(userId, 'متاح')
.subscribe(_ => {});
this.toastr.success('تم تسجيل الزيارة بنجاح ✔');
this.toastr.success(ConstantMessages.SUCCESS_ADD_VISIT);
this.router.navigateByUrl(`doctor/history/${this.employeeId}`);
}
})
}
else {
this.toastr.error("يرجى إضافة أدوية");
this.toastr.error(ConstantMessages.ERROR_NO_MEDICINES);
}
......
......@@ -4,6 +4,7 @@ import { UserData } from '../../../classes/authentication/user-data';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ToastrService } from 'ngx-toastr';
import { DoctorsService } from '../../../services/doctors/doctors.service';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-doctor-status',
......@@ -40,7 +41,7 @@ export class DoctorStatusComponent implements OnInit {
this.doctorsService.getStatusByUserId(this.userData.id)
.subscribe(result => {
if (result.status === false) {
this.toastr.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.toastr.error(ConstantMessages.ERROR);
}
else {
this.doctorStatus = result.doctorStatus!;
......@@ -54,10 +55,10 @@ export class DoctorStatusComponent implements OnInit {
this.doctorsService.changeStatusByUserId(this.userData.id, this.doctorStatus)
.subscribe(result => {
if (result.status === false) {
this.toastr.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.toastr.error(ConstantMessages.ERROR);
}
else {
this.toastr.success('تم تغيير الحالة بنجاح ✔')
this.toastr.success(ConstantMessages.SUCCESS_CHANGE_STATUS)
}
})
}
......
......@@ -5,6 +5,7 @@ import { ToastrService } from 'ngx-toastr';
import { EmployeeData } from '../../../classes/employeeData/employee-data';
import { VisitView } from '../../../classes/visit/visit-view';
import { VisitsService } from '../../../services/visits/visits.service';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-history',
......@@ -28,7 +29,7 @@ export class HistoryComponent implements OnInit {
this.route.params.subscribe((params: any) => {
this.patientId = Number(params.id);
if (isNaN(this.patientId)) {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.toastrService.error(ConstantMessages.ERROR);
this.router.navigateByUrl('doctor/waitinglist');
}
this.getEmployee();
......@@ -42,7 +43,7 @@ export class HistoryComponent implements OnInit {
this.employeesDataService.getById(this.patientId)
.subscribe(result => {
if (result.status === false) {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.toastrService.error(ConstantMessages.ERROR);
this.router.navigateByUrl('doctor/waitinglist');
}
else {
......@@ -59,7 +60,7 @@ export class HistoryComponent implements OnInit {
this.visitsService.getAllByPatientId(this.patientId)
.subscribe(result => {
if (result.status === false) {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.toastrService.error(ConstantMessages.ERROR);
this.router.navigateByUrl('doctor/waitinglist');
}
else {
......
......@@ -6,6 +6,7 @@ import { Router } from '@angular/router';
import { FormControl } from '@angular/forms';
import { debounceTime, distinctUntilChanged, filter, switchMap } from 'rxjs';
import { VisitMedicine } from '../../../classes/medicine/visit-medicine';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-search-for-medicine',
......@@ -30,7 +31,7 @@ export class SearchForMedicineComponent implements OnInit {
.subscribe(
value => {
if(value.status === false) {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.toastrService.error(ConstantMessages.ERROR);
this.router.navigateByUrl('doctor/waitinglist');
}
else {
......
......@@ -5,6 +5,7 @@ import { Router } from '@angular/router';
import { ToastrService } from 'ngx-toastr';
import { EmployeeData } from '../../../classes/employeeData/employee-data';
import { EmployeesDataService } from '../../../services/employees/employees-data.service';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-create-employee-form',
......@@ -45,7 +46,7 @@ export class CreateEmployeeFormComponent {
this.employeesDataService.create(this.formModel)
.subscribe(result => {
if (result.status === true) {
this.toastrService.success('تم إضافة الموظف بنجاح ✔');
this.toastrService.success(ConstantMessages.SUCCESS_ADD_EMPLOYEE);
this.router.navigateByUrl(`receptionist/employees/${result.id!}`);
}
else {
......
......@@ -4,6 +4,7 @@ import { Router } from '@angular/router';
import { ToastrService } from 'ngx-toastr';
import { WaitingListService } from '../../../services/waitingList/waiting-list.service';
import { ViewportScroller } from '@angular/common';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-create-witing-list-item-for-employee',
......@@ -35,7 +36,7 @@ export class CreateWitingListItemForEmployeeComponent {
this.waitingListService.createBySerialNumber(this.formModel.serialNumber)
.subscribe((result => {
if (result.status === true) {
this.toastrService.success('تمت الإضافة بنجاح ✔');
this.toastrService.success(ConstantMessages.SUCCESS_ADD);
this.router.navigateByUrl('receptionist/waitinglist');
}
else {
......
......@@ -2,6 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { DoctorsService } from '../../../services/doctors/doctors.service';
import { Doctor } from '../../../classes/doctor/doctor';
import { ToastrService } from 'ngx-toastr';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-doctors',
......@@ -22,7 +23,7 @@ export class DoctorsComponent implements OnInit {
this.doctorsService.getAll()
.subscribe(result => {
if (result === null) {
this.toasreService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.toasreService.error(ConstantMessages.ERROR);
}
else this.doctors = result;
})
......
......@@ -5,6 +5,7 @@ import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
import { ToastrService } from 'ngx-toastr';
import { EmployeeData } from '../../../classes/employeeData/employee-data';
import { EmployeesDataService } from '../../../services/employees/employees-data.service';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-employee',
......@@ -31,7 +32,7 @@ export class EmployeeComponent implements OnInit {
this.activeRoute.params.subscribe((params: any) => {
this.id = Number(params.id);
if (isNaN(this.id)) {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.toastrService.error(ConstantMessages.ERROR);
this.router.navigateByUrl('receptionist/waitinglist');
}
this.updateFormModel();
......@@ -45,7 +46,7 @@ export class EmployeeComponent implements OnInit {
this.formModel = result.employeeData!;
}
else {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.toastrService.error(ConstantMessages.ERROR);
this.router.navigateByUrl('receptionist/waitinglist');
}
})
......
......@@ -7,6 +7,7 @@ import { DoctorsService } from '../../../services/doctors/doctors.service';
import { AuthenticationService } from '../../../services/authentication/authentication.service';
import { UserData } from '../../../classes/authentication/user-data';
import { Roles } from '../../../classes/authentication/roles';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-waiting-list-item',
......@@ -50,11 +51,11 @@ export class WaitingListItemComponent implements OnInit {
this.waitingListService.delete(this.model.id)
.subscribe(result => {
if (result.status === true) {
this.toastrService.success('تم الحذف بنجاح ✔');
this.toastrService.success(ConstantMessages.SUCCESS_DELETE);
this.deleted.emit();
}
else {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.toastrService.error(ConstantMessages.ERROR);
}
})
}
......@@ -66,7 +67,7 @@ export class WaitingListItemComponent implements OnInit {
this.doctorsService.getAvailable()
.subscribe(result => {
if (result === null) {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.toastrService.error(ConstantMessages.ERROR);
}
else {
this.doctors = result;
......@@ -78,11 +79,11 @@ export class WaitingListItemComponent implements OnInit {
this.waitingListService.SendToDoctor(this.model.id, this.model.patientId, this.selectedDoctorId)
.subscribe(result => {
if (result.status === true) {
this.toastrService.success('تم الإرسال بنجاح ✔');
this.toastrService.success(ConstantMessages.SUCCESS_SEND_TO_DOCTOR);
this.deleted.emit();
}
else {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.toastrService.error(ConstantMessages.ERROR);
}
})
}
......
......@@ -5,6 +5,7 @@ import { ToastrService } from 'ngx-toastr';
import { UserData } from '../../../classes/authentication/user-data';
import { AuthenticationService } from '../../../services/authentication/authentication.service';
import { Roles } from '../../../classes/authentication/roles';
import { ConstantMessages } from '../../../constants/messages';
@Component({
selector: 'app-waiting-list',
......@@ -27,7 +28,7 @@ export class WaitingListComponent implements OnInit {
this.waitingListService.getAll()
.subscribe(result => {
if (result === null)
this.toastrService.error("حدثت مشكلة، يرجى إعادة المحاولة");
this.toastrService.error(ConstantMessages.ERROR);
else this.records = result;
});
}
......
......@@ -6,6 +6,7 @@ import { Roles } from '../../../../classes/authentication/roles';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ToastrService } from 'ngx-toastr';
import { ViewportScroller } from '@angular/common';
import { ConstantMessages } from '../../../../constants/messages';
@Component({
selector: 'app-header',
......@@ -74,7 +75,7 @@ export class HeaderComponent {
//#region On logout
onLogout(): void {
this.authenticationService.logout();
this.toastrService.success("تم تسجيل الخروج بنجاح ✔");
this.toastrService.success(ConstantMessages.SUCCESS_LOGOUT);
this.userData = null;
this.showDropdown = false;
this.selectedButton = 'Home';
......
export class ConstantMessages {
public static readonly ERROR: string = 'حدثت مشكلة، يرجى إعادة المحاولة';
public static readonly ERROR_NO_MEDICINES: string = 'يرجى إضافة أدوية';
public static readonly ERROR_ALREADY_ADDED_MEDICINE: string = 'الدواء موجود بالفعل';
public static readonly SUCCESS_ADD_DOCTOR: string = 'تم إضافة الطبيب بنجاح ✔';
public static readonly SUCCESS_EDIT: string = 'تم تعديل البيانات بنجاح ✔';
public static readonly SUCCESS_DELETE: string = 'تم الحذف بنجاح ✔';
public static readonly SUCCESS_ADD: string = 'تمت الإضافة بنجاح ✔';
public static readonly SUCCESS_LOGIN: string = 'تم تسجيل الدخول بنجاح ✔';
public static readonly SUCCESS_LOGOUT: string = 'تم تسجيل الخروج بنجاح ✔';
public static readonly SUCCESS_ADD_VISIT: string = 'تم تسجيل الزيارة بنجاح ✔';
public static readonly SUCCESS_CHANGE_STATUS: string = 'تم تغيير الحالة بنجاح ✔';
public static readonly SUCCESS_ADD_EMPLOYEE: string = 'تم إضافة الموظف بنجاح ✔';
public static readonly SUCCESS_SEND_TO_DOCTOR: string = 'تم الإرسال بنجاح بنجاح ✔';
}
\ No newline at end of file
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