Skip to content

Commit

Permalink
feat: show user message about route deleted successfully
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleostro committed Aug 21, 2024
1 parent 86cf727 commit 74b5757
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { provideHttpClient } from '@angular/common/http';
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { UserMessageService } from '@/app/shared/services/userMessage/user-message.service';

import { RoutesListComponent } from './routes-list.component';

describe('RoutesListComponent', () => {
Expand All @@ -10,7 +12,7 @@ describe('RoutesListComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [RoutesListComponent],
providers: [provideHttpClient()],
providers: [provideHttpClient(), { provide: UserMessageService, useValue: {} }],
}).compileComponents();

fixture = TestBed.createComponent(RoutesListComponent);
Expand Down
4 changes: 4 additions & 0 deletions src/app/admin/components/routes-list/routes-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { RouteResponse } from '@/app/api/models/route';
import { Station } from '@/app/api/models/stations';
import { RouteService } from '@/app/api/routeService/route.service';
import { ModalService } from '@/app/shared/services/modal/modal.service';
import { USER_MESSAGE } from '@/app/shared/services/userMessage/constants/user-messages';
import { UserMessageService } from '@/app/shared/services/userMessage/user-message.service';

import { RouteComponent } from '../route/route.component';

Expand All @@ -31,6 +33,7 @@ import { RouteComponent } from '../route/route.component';
export class RoutesListComponent implements OnDestroy {
public routeService = inject(RouteService);
public modalService = inject(ModalService);
public userMessageService = inject(UserMessageService);
public routes = input<RouteResponse[]>([]);
public stations = input<Station[]>([]);
public deletionRouteId = signal<number>(NaN);
Expand All @@ -53,6 +56,7 @@ export class RoutesListComponent implements OnDestroy {
this.isRouteDeleted.set(false);
this.deletionRouteId.set(NaN);
this.modalService.closeModal();
this.userMessageService.showSuccessMessage(USER_MESSAGE.ROUTE_DELETED_SUCCESSFULLY);
}),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export const USER_MESSAGE = {
PROFILE_UPDATED_ERROR: "We couldn't update your profile. Please try again.",
PASSWORD_CHANGED_SUCCESSFULLY: 'Password changed successfully!',
PASSWORD_CHANGED_ERROR: "We couldn't change your password. Please try again.",
ROUTE_DELETED_SUCCESSFULLY: 'Route deleted successfully!',
};

0 comments on commit 74b5757

Please sign in to comment.