From a962c51c32bd8143953c1af95432352866af7177 Mon Sep 17 00:00:00 2001 From: Ayobami Akingbade Date: Fri, 31 May 2024 06:30:57 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(dashboard):=20filter=20porta?= =?UTF-8?q?l=20dashbord=20types=20correctly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/Dashboard/Widget/_manage/Form.tsx | 26 ++++++++++++------- .../views/Dashboard/Widget/constants.tsx | 2 +- .../views/Dashboard/Widget/portal/index.ts | 1 + .../Dashboard/Widget/portal/main/constants.ts | 4 +++ .../portal/menu/{index.d.ts => index.ts} | 0 .../portal/menu/{main.d.ts => main.ts} | 0 6 files changed, 22 insertions(+), 11 deletions(-) rename src/shared/constants/portal/menu/{index.d.ts => index.ts} (100%) rename src/shared/constants/portal/menu/{main.d.ts => main.ts} (100%) diff --git a/src/frontend/views/Dashboard/Widget/_manage/Form.tsx b/src/frontend/views/Dashboard/Widget/_manage/Form.tsx index 89f7f8462..c6057e24d 100644 --- a/src/frontend/views/Dashboard/Widget/_manage/Form.tsx +++ b/src/frontend/views/Dashboard/Widget/_manage/Form.tsx @@ -37,27 +37,28 @@ import { MessageDescriptor } from "@lingui/core"; import { useDomainMessages } from "frontend/lib/crud-config"; import { LANG_DOMAINS } from "frontend/lib/crud-config/lang-domains"; import { DashboardWidgetPresentation } from "../Presentation"; -import { WIDGET_CONFIG } from "../constants"; +import { BASE_WIDGET_CONFIG } from "../constants"; import { PortalFormFields, PortalFormSchema } from "./portal"; import { WidgetFormField } from "./types"; import { DASHBOARD_WIDGET_HEIGHTS } from "./constants"; +import { usePortalDashboardTypesOptions } from "../portal"; -const DashboardTypesOptions: { +const FormSchema: Partial> = { + "summary-card": ["color", "icon"], + table: [], + ...PortalFormSchema, +}; + +const baseDashboardTypesOptions: { label: MessageDescriptor; value: IWidgetConfig["_type"]; -}[] = typescriptSafeObjectDotEntries(WIDGET_CONFIG).map( +}[] = typescriptSafeObjectDotEntries(BASE_WIDGET_CONFIG).map( ([value, { label }]) => ({ label, value: value as IWidgetConfig["_type"], }) ); -const FormSchema: Partial> = { - "summary-card": ["color", "icon"], - table: [], - ...PortalFormSchema, -}; - export function useRunWidgetScript() { return useMutation({ mutationFn: async (script: string) => @@ -89,6 +90,8 @@ export function DashboardWidgetForm({ } }, [initialValues]); + const portalDashboardTypesOptions = usePortalDashboardTypesOptions(); + return ( <>
diff --git a/src/frontend/views/Dashboard/Widget/constants.tsx b/src/frontend/views/Dashboard/Widget/constants.tsx index 203c54c2f..f20402a33 100644 --- a/src/frontend/views/Dashboard/Widget/constants.tsx +++ b/src/frontend/views/Dashboard/Widget/constants.tsx @@ -8,7 +8,7 @@ import { IWidgetConfigBag } from "./types"; import { TableWidgetSchema } from "./_render/Table/types"; import { SummaryCardWidgetSchema } from "./_render/Summary/types"; -const BASE_WIDGET_CONFIG: Partial< +export const BASE_WIDGET_CONFIG: Partial< Record > = { table: { diff --git a/src/frontend/views/Dashboard/Widget/portal/index.ts b/src/frontend/views/Dashboard/Widget/portal/index.ts index 4d2a7ffc4..6b6d223a5 100644 --- a/src/frontend/views/Dashboard/Widget/portal/index.ts +++ b/src/frontend/views/Dashboard/Widget/portal/index.ts @@ -1,2 +1,3 @@ export { PORTAL_WIDGET_CONFIG } from "./main/constants"; export { PortalDashboardWidget } from "./main/DashboardWidget"; +export { usePortalDashboardTypesOptions } from "./main/constants"; diff --git a/src/frontend/views/Dashboard/Widget/portal/main/constants.ts b/src/frontend/views/Dashboard/Widget/portal/main/constants.ts index 88c47cd4f..1eb5555ad 100644 --- a/src/frontend/views/Dashboard/Widget/portal/main/constants.ts +++ b/src/frontend/views/Dashboard/Widget/portal/main/constants.ts @@ -4,3 +4,7 @@ import { IWidgetConfigBag } from "../../types"; export const PORTAL_WIDGET_CONFIG: Partial< Record > = {}; + +export const usePortalDashboardTypesOptions = () => { + return []; +}; diff --git a/src/shared/constants/portal/menu/index.d.ts b/src/shared/constants/portal/menu/index.ts similarity index 100% rename from src/shared/constants/portal/menu/index.d.ts rename to src/shared/constants/portal/menu/index.ts diff --git a/src/shared/constants/portal/menu/main.d.ts b/src/shared/constants/portal/menu/main.ts similarity index 100% rename from src/shared/constants/portal/menu/main.d.ts rename to src/shared/constants/portal/menu/main.ts