From b91eb0dbd5c7b47576ecb3b66de092ce1e1bebc6 Mon Sep 17 00:00:00 2001 From: Mathieu Anderson Date: Tue, 16 May 2023 16:43:36 +0200 Subject: [PATCH] feat(coral): Add `getTopicOverview` to `topic` `domain` (#1240) feat(coral): Add getTopicOverview to domain Signed-off-by: Mathieu Anderson --- coral/src/domain/topic/topic-api.ts | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/coral/src/domain/topic/topic-api.ts b/coral/src/domain/topic/topic-api.ts index 2bcd836c62..3f8a5ffcb6 100644 --- a/coral/src/domain/topic/topic-api.ts +++ b/coral/src/domain/topic/topic-api.ts @@ -1,4 +1,6 @@ import omitBy from "lodash/omitBy"; +import { Schema } from "src/app/features/topics/request/form-schemas/topic-request-form"; +import { transformAdvancedConfigEntries } from "src/app/features/topics/request/utils"; import { RequestVerdictApproval, RequestVerdictDecline, @@ -15,14 +17,12 @@ import { TopicRequestApiResponse, } from "src/domain/topic/topic-types"; import api, { API_PATHS } from "src/services/api"; +import { convertQueryValuesToString } from "src/services/api-helper"; import { KlawApiRequest, KlawApiRequestQueryParameters, KlawApiResponse, } from "types/utils"; -import { convertQueryValuesToString } from "src/services/api-helper"; -import { Schema } from "src/app/features/topics/request/form-schemas/topic-request-form"; -import { transformAdvancedConfigEntries } from "src/app/features/topics/request/utils"; const getTopics = async ( params: KlawApiRequestQueryParameters<"getTopics"> @@ -204,6 +204,25 @@ const deleteTopicRequest = ({ }); }; +const getTopicOverview = ({ + topicName, + environmentId, + groupBy, +}: KlawApiRequestQueryParameters<"getTopicOverview">) => { + const queryParams = convertQueryValuesToString({ + topicName, + ...(environmentId && { environmentId }), + ...(groupBy && { + groupBy, + }), + }); + + return api.get>( + API_PATHS.getTopicOverview, + new URLSearchParams(queryParams) + ); +}; + export { getTopics, getTopicNames, @@ -215,4 +234,5 @@ export { approveTopicRequest, declineTopicRequest, deleteTopicRequest, + getTopicOverview, };