From cf19afa7070539495b3620c5e5d51e722e684799 Mon Sep 17 00:00:00 2001 From: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Date: Fri, 3 Nov 2023 19:11:28 +0530 Subject: [PATCH] fix: string helper function (#2633) --- web/components/analytics/custom-analytics/select-bar.tsx | 1 + .../analytics/custom-analytics/select/x-axis.tsx | 8 ++++++-- web/helpers/string.helper.ts | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/web/components/analytics/custom-analytics/select-bar.tsx b/web/components/analytics/custom-analytics/select-bar.tsx index ef289f5c8..195aa2e56 100644 --- a/web/components/analytics/custom-analytics/select-bar.tsx +++ b/web/components/analytics/custom-analytics/select-bar.tsx @@ -66,6 +66,7 @@ export const CustomAnalyticsSelectBar: React.FC = observer((props) => { onChange(val); }} + params={params} /> )} /> diff --git a/web/components/analytics/custom-analytics/select/x-axis.tsx b/web/components/analytics/custom-analytics/select/x-axis.tsx index 99e872340..66582a1e9 100644 --- a/web/components/analytics/custom-analytics/select/x-axis.tsx +++ b/web/components/analytics/custom-analytics/select/x-axis.tsx @@ -3,16 +3,19 @@ import { useRouter } from "next/router"; // ui import { CustomSelect } from "@plane/ui"; // types -import { TXAxisValues } from "types"; +import { IAnalyticsParams, TXAxisValues } from "types"; // constants import { ANALYTICS_X_AXIS_VALUES } from "constants/analytics"; type Props = { value: TXAxisValues; onChange: (val: string) => void; + params: IAnalyticsParams; }; -export const SelectXAxis: React.FC = ({ value, onChange }) => { +export const SelectXAxis: React.FC = (props) => { + const { value, onChange, params } = props; + const router = useRouter(); const { cycleId, moduleId } = router.query; @@ -25,6 +28,7 @@ export const SelectXAxis: React.FC = ({ value, onChange }) => { maxHeight="lg" > {ANALYTICS_X_AXIS_VALUES.map((item) => { + if (params.segment === item.value) return null; if (cycleId && item.value === "issue_cycle__cycle_id") return null; if (moduleId && item.value === "issue_module__module_id") return null; diff --git a/web/helpers/string.helper.ts b/web/helpers/string.helper.ts index 29f414200..778ec602a 100644 --- a/web/helpers/string.helper.ts +++ b/web/helpers/string.helper.ts @@ -5,7 +5,13 @@ import { VIEW_ISSUES, } from "constants/fetch-keys"; -export const addSpaceIfCamelCase = (str: string) => str.replace(/([a-z])([A-Z])/g, "$1 $2"); +export const addSpaceIfCamelCase = (str: string) => { + if (str === undefined || str === null) return ""; + + if (typeof str !== "string") str = `${str}`; + + return str.replace(/([a-z])([A-Z])/g, "$1 $2"); +}; export const replaceUnderscoreIfSnakeCase = (str: string) => str.replace(/_/g, " ");