From d72af09e63a5c42777e59c87b9e089c049a996b5 Mon Sep 17 00:00:00 2001 From: zeleniucvladislav Date: Mon, 4 Mar 2024 13:53:41 +0200 Subject: [PATCH] feat(ministry brands): added extra for getEkklesiaFields --- public/editor-client/src/ekklesia/index.ts | 6 ++++-- public/editor-client/src/ekklesia/utils.ts | 6 ++++-- public/editor-client/src/types/Ekklesia.ts | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/public/editor-client/src/ekklesia/index.ts b/public/editor-client/src/ekklesia/index.ts index 07c70b1e9e..4d3621c7e6 100644 --- a/public/editor-client/src/ekklesia/index.ts +++ b/public/editor-client/src/ekklesia/index.ts @@ -1,6 +1,7 @@ import { Config } from "config"; import { ChoicesAsync, ChoicesSync } from "types/Choices"; import { + EkklesiaExtra, EkklesiaFieldMap, EkklesiaFields, EkklesiaKeys, @@ -14,7 +15,8 @@ export const getEkklesiaFields = (config: Config) => ({ async handler( res: Response, rej: Response, - keys: EkklesiaParams + keys: EkklesiaParams, + extra?: EkklesiaExtra ): Promise { const { ekklesiaApiUrl } = config.api; if (!ekklesiaApiUrl) { @@ -25,7 +27,7 @@ export const getEkklesiaFields = (config: Config) => ({ return; } try { - const fields = await getFields(ekklesiaApiUrl, keys); + const fields = await getFields(ekklesiaApiUrl, keys, extra); res(fields); } catch (error) { if (process.env.NODE_ENV === "development") { diff --git a/public/editor-client/src/ekklesia/utils.ts b/public/editor-client/src/ekklesia/utils.ts index 88f59ff865..2c696f4d9f 100644 --- a/public/editor-client/src/ekklesia/utils.ts +++ b/public/editor-client/src/ekklesia/utils.ts @@ -3,6 +3,7 @@ import { makeUrl } from "api/utils"; import { ChoicesSync } from "types/Choices"; import { EkklesiaChoiceParamsWithSubKey, + EkklesiaExtra, EkklesiaFields, EkklesiaParams, EkklesiaParentsChilds, @@ -44,11 +45,12 @@ export const getFields = async < T extends keyof EkklesiaFields = keyof EkklesiaFields >( _url: string, - keys: EkklesiaParams + keys: EkklesiaParams, + extra?: EkklesiaExtra ): Promise => { const { key } = keys; - const url = makeUrl(_url, { module: key }); + const url = makeUrl(_url, { module: key, ...extra }); const { data = {} } = await requestFields(url); const field = data[key]; diff --git a/public/editor-client/src/types/Ekklesia.ts b/public/editor-client/src/types/Ekklesia.ts index c45a23f9ef..6ebc5fc731 100644 --- a/public/editor-client/src/types/Ekklesia.ts +++ b/public/editor-client/src/types/Ekklesia.ts @@ -18,6 +18,10 @@ export interface EkklesiaFields { smallgroupsLvl: EkklesiaParentsChilds; } +export interface EkklesiaExtra { + find_group?: string; +} + export interface EkklesiaParentsChilds { parents: Record; childs: Record;