From bccae3b73d776f4de3d516a3d6157014abd8f779 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 6 Dec 2024 07:41:55 -0800 Subject: [PATCH] fix(SILVA-515): added new fields and test update --- .../src/__test__/services/OpeningService.test.ts | 12 ++++++------ frontend/src/services/OpeningService.ts | 3 ++- frontend/src/services/search/openings.ts | 11 +++++++++++ frontend/src/types/OpeningPerYearChart.ts | 1 + 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/frontend/src/__test__/services/OpeningService.test.ts b/frontend/src/__test__/services/OpeningService.test.ts index 582d9152..823d4c27 100644 --- a/frontend/src/__test__/services/OpeningService.test.ts +++ b/frontend/src/__test__/services/OpeningService.test.ts @@ -23,22 +23,22 @@ describe('OpeningService', () => { describe('fetchOpeningsPerYear', () => { it('should fetch openings per year successfully', async () => { const mockData = [ - { monthName: 'January', amount: 10 }, - { monthName: 'February', amount: 20 } + { monthName: 'Jan', amount: 10, statusCounts: { APP: 5, FG: 2 } }, + { monthName: 'Feb', amount: 20, statusCounts: { APP: 5, FG: 2 } } ]; (axios.get as vi.Mock).mockResolvedValue({ data: mockData }); - const props = { orgUnitCode: '001', statusCode: 'APP', entryDateStart: '2023-01-01', entryDateEnd: '2023-12-31' }; + const props = { orgUnitCode: ['001'], statusCode: ['APP'], entryDateStart: '2023-01-01', entryDateEnd: '2023-12-31' }; const result = await fetchOpeningsPerYear(props); - expect(axios.get).toHaveBeenCalledWith(`${backendUrl}/api/dashboard-metrics/submission-trends?orgUnitCode=001&statusCode=APP&entryDateStart=2023-01-01&entryDateEnd=2023-12-31`, { + expect(axios.get).toHaveBeenCalledWith(`${backendUrl}/api/users/submission-trends?orgUnitCode=001&statusCode=APP&entryDateStart=2023-01-01&entryDateEnd=2023-12-31`, { headers: { Authorization: `Bearer ${authToken}`, "Access-Control-Allow-Origin": "http://localhost:3000", "Content-Type": "application/json" } }); expect(result).toEqual([ - { group: 'Openings', key: 'January', value: 10 }, - { group: 'Openings', key: 'February', value: 20 } + { group: 'Openings', key: 'Jan', value: 10, statusCount: { APP: 5, FG: 2 } }, + { group: 'Openings', key: 'Feb', value: 20, statusCount: { APP: 5, FG: 2 } } ]); }); diff --git a/frontend/src/services/OpeningService.ts b/frontend/src/services/OpeningService.ts index 86271753..6d37e918 100644 --- a/frontend/src/services/OpeningService.ts +++ b/frontend/src/services/OpeningService.ts @@ -52,7 +52,8 @@ export async function fetchOpeningsPerYear(props: IOpeningPerYear): Promise ({ group: "Openings", key: item.monthName, - value: item.amount + value: item.amount, + statusCount: item.statusCounts })); return formattedData; diff --git a/frontend/src/services/search/openings.ts b/frontend/src/services/search/openings.ts index 40988116..1c04478f 100644 --- a/frontend/src/services/search/openings.ts +++ b/frontend/src/services/search/openings.ts @@ -4,6 +4,7 @@ import { getAuthIdToken } from "../AuthService"; import { dateTypes, blockStatuses } from "../../mock-data/openingSearchFilters"; import { createDateParams } from "../../utils/searchUtils"; import { API_ENDPOINTS, defaultHeaders } from "../apiConfig"; +import { TextValueData } from "../../utils/multiSelectSortUtils"; export interface OpeningFilters { searchInput?: string; @@ -66,6 +67,16 @@ export interface CodeDescription { description: string; } +export const status: TextValueData[] = [ + {value:'AMG', text: 'Amalgamate'}, + {value:'AMD', text: 'Amended'}, + {value:'APP', text: 'Approved'}, + {value:'DFT', text: 'Draft'}, + {value:'FG', text: 'Free Growing'}, + {value:'RMD', text: 'Removed'}, + {value:'RET', text: 'Retired'}, + {value:'SUB', text: 'Submitted'} +]; export const fetchOpenings = async (filters: OpeningFilters): Promise => { // Get the date params based on dateType diff --git a/frontend/src/types/OpeningPerYearChart.ts b/frontend/src/types/OpeningPerYearChart.ts index 9f2a009a..b658b0e4 100644 --- a/frontend/src/types/OpeningPerYearChart.ts +++ b/frontend/src/types/OpeningPerYearChart.ts @@ -2,4 +2,5 @@ export interface OpeningPerYearChart { group: string; key: string; value: string; + statusCount: Record; }