fix: string helper function (#2633)

This commit is contained in:
Aaryan Khandelwal 2023-11-03 19:11:28 +05:30 committed by GitHub
parent cc26f604aa
commit cf19afa707
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View File

@ -66,6 +66,7 @@ export const CustomAnalyticsSelectBar: React.FC<Props> = observer((props) => {
onChange(val);
}}
params={params}
/>
)}
/>

View File

@ -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<Props> = ({ value, onChange }) => {
export const SelectXAxis: React.FC<Props> = (props) => {
const { value, onChange, params } = props;
const router = useRouter();
const { cycleId, moduleId } = router.query;
@ -25,6 +28,7 @@ export const SelectXAxis: React.FC<Props> = ({ 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;

View File

@ -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, " ");