diff --git a/interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts b/interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts index 2363f8910..8e91fd81c 100644 --- a/interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts @@ -225,10 +225,13 @@ export class ChatComponent implements OnDestroy { eventPlaceCodeId: number, placeCode: string, ) { - await this.apiService.closeEventPlaceCode(eventPlaceCodeId); - this.filteredAreas = this.filteredAreas.filter( - (item) => item.id !== eventPlaceCodeId, - ); + let loading = await this.loadingCtrl.create({}); + loading.present(); + this.apiService.closeEventPlaceCode(eventPlaceCodeId).then(() => { + loading.dismiss(); + }); + this.eapActionsService.loadDistrictsAndActions(); + this.eventService.getTrigger(); this.countryService .getCountrySubscription() .subscribe((country: Country) => { @@ -240,10 +243,5 @@ export class ChatComponent implements OnDestroy { placeCode: placeCode, }); }); - let loading = await this.loadingCtrl.create({}); - loading.present(); - setTimeout(() => { - loading.dismiss(); - }, 1000); } } diff --git a/interfaces/IBF-dashboard/src/app/services/api.service.ts b/interfaces/IBF-dashboard/src/app/services/api.service.ts index cc4aae13c..848b96254 100644 --- a/interfaces/IBF-dashboard/src/app/services/api.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/api.service.ts @@ -202,11 +202,11 @@ export class ApiService { ).toPromise(); } - closeEventPlaceCode(eventPlacecodeId: number) { + closeEventPlaceCode(eventPlaceCodeId: number) { return this.post( 'event/close-place-code', { - eventPlacecodeId, + eventPlaceCodeId, }, false, ).toPromise(); diff --git a/services/API-service/src/api/data/data.controller.ts b/services/API-service/src/api/data/data.controller.ts index f95151104..aa7880ecd 100644 --- a/services/API-service/src/api/data/data.controller.ts +++ b/services/API-service/src/api/data/data.controller.ts @@ -7,7 +7,7 @@ import { } from '@nestjs/swagger'; import { RolesGuard } from '../../roles.guard'; -import { TriggeredArea, CountryEvent } from './data.model'; +import { TriggeredArea, EventSummaryCountry } from './data.model'; import { DataService } from './data.service'; import { GeoJson } from './geo.model'; @@ -74,10 +74,14 @@ export class DataController { return await this.dataService.getTriggeredAreas(params.countryCode); } - @ApiOperation({ summary: 'Get active country event' }) + @ApiOperation({ summary: 'Get active event summary of a country' }) @ApiParam({ name: 'countryCodeISO3', required: true, type: 'string' }) @Get('event/:countryCodeISO3') - public async getCountryEvent(@Param() params): Promise { - return await this.dataService.getCountryEvent(params.countryCodeISO3); + public async getEventSummaryCountry( + @Param() params, + ): Promise { + return await this.dataService.getEventSummaryCountry( + params.countryCodeISO3, + ); } } diff --git a/services/API-service/src/api/data/data.model.ts b/services/API-service/src/api/data/data.model.ts index 2dd860a95..f25a5feb8 100644 --- a/services/API-service/src/api/data/data.model.ts +++ b/services/API-service/src/api/data/data.model.ts @@ -135,7 +135,7 @@ export class TriggeredArea { public population_affected: number; } -export class CountryEvent { +export class EventSummaryCountry { public country_code: string; public startDate: string; public endDate: string; diff --git a/services/API-service/src/api/data/data.service.ts b/services/API-service/src/api/data/data.service.ts index 12040368d..4525efc5f 100644 --- a/services/API-service/src/api/data/data.service.ts +++ b/services/API-service/src/api/data/data.service.ts @@ -1,4 +1,4 @@ -import { CountryEvent } from './data.model'; +import { EventSummaryCountry } from './data.model'; /* eslint-disable @typescript-eslint/camelcase */ import { Injectable } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; @@ -130,9 +130,11 @@ export class DataService { return result; } - public async getCountryEvent(countryCodeISO3: string): Promise { + public async getEventSummaryCountry( + countryCodeISO3: string, + ): Promise { const query = fs - .readFileSync('./src/api/data/sql/get-country-event.sql') + .readFileSync('./src/api/data/sql/get-event-summary-country.sql') .toString(); const result = await this.manager.query(query, [countryCodeISO3]); if (!result[0].startDate) { diff --git a/services/API-service/src/api/data/sql/get-country-event.sql b/services/API-service/src/api/data/sql/get-event-summary-country.sql similarity index 100% rename from services/API-service/src/api/data/sql/get-country-event.sql rename to services/API-service/src/api/data/sql/get-event-summary-country.sql diff --git a/services/API-service/src/api/event/dto/event-place-code.dto.ts b/services/API-service/src/api/event/dto/event-place-code.dto.ts index e797ba92d..00382819f 100644 --- a/services/API-service/src/api/event/dto/event-place-code.dto.ts +++ b/services/API-service/src/api/event/dto/event-place-code.dto.ts @@ -5,5 +5,5 @@ export class EventPlaceCodeDto { @ApiProperty() @IsNotEmpty() @IsNumber() - public eventPlacecodeId: number; + public eventPlaceCodeId: number; } diff --git a/services/API-service/src/api/event/event.service.spec.ts b/services/API-service/src/api/event/event.service.spec.ts index 82ed2e657..720b2fdc0 100644 --- a/services/API-service/src/api/event/event.service.spec.ts +++ b/services/API-service/src/api/event/event.service.spec.ts @@ -4,7 +4,7 @@ import { getRepositoryToken } from '@nestjs/typeorm'; import { repositoryMockFactory } from '../../mock/repositoryMock.factory'; import { EventPlaceCodeEntity } from './event-place-code.entity'; -describe('User service', (): void => { +describe('Event service', (): void => { let service: EventService; beforeAll( async (): Promise => { diff --git a/services/API-service/src/api/event/event.service.ts b/services/API-service/src/api/event/event.service.ts index 695278b1f..b28fe46b1 100644 --- a/services/API-service/src/api/event/event.service.ts +++ b/services/API-service/src/api/event/event.service.ts @@ -14,7 +14,7 @@ export class EventService { eventPlaceCodeDto: EventPlaceCodeDto, ): Promise { const eventPlaceCode = await this.eventPlaceCodeRepo.findOne( - eventPlaceCodeDto.eventPlacecodeId, + eventPlaceCodeDto.eventPlaceCodeId, ); if (!eventPlaceCode) { const errors = 'Event Pcode not found'; diff --git a/services/API-service/src/api/indicator/indicator.service.ts b/services/API-service/src/api/indicator/indicator.service.ts index 6dc1851d0..c000e2c22 100644 --- a/services/API-service/src/api/indicator/indicator.service.ts +++ b/services/API-service/src/api/indicator/indicator.service.ts @@ -18,7 +18,7 @@ export class IndicatorService { i.country_codes.split(',').includes(countryCode), ); - const event = await this.dataService.getCountryEvent(countryCode); + const event = await this.dataService.getEventSummaryCountry(countryCode); const activeTrigger = event && event.activeTrigger; countryIndicators.find( (i): boolean => i.name === 'population_affected',