From da8d39aab2a48683b17f96dde0b0dc2fb3b958c2 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Tue, 14 Feb 2023 19:44:42 -0300 Subject: [PATCH] Converting snake case on the fields names --- space_flow/src/CustomNodes/GenericNode/index.tsx | 8 ++++---- space_flow/src/utils.ts | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/space_flow/src/CustomNodes/GenericNode/index.tsx b/space_flow/src/CustomNodes/GenericNode/index.tsx index 38c73ea8c..b666f42fb 100644 --- a/space_flow/src/CustomNodes/GenericNode/index.tsx +++ b/space_flow/src/CustomNodes/GenericNode/index.tsx @@ -7,7 +7,7 @@ import { import { Handle, Position } from "reactflow"; import Dropdown from "../../components/dropdownComponent"; import Input from "../../components/inputComponent"; -import { nodeColors, nodeIcons } from "../../utils"; +import { nodeColors, nodeIcons, snakeToNormalCase } from "../../utils"; import Tooltip from "../../components/TooltipComponent"; import { useEffect } from "react"; @@ -48,7 +48,7 @@ export default function GenericNode({ data }) { onSelect={() => {}} /> ) : data.node.template[t].type === "str" ? ( - {}} /> + {}} /> ) : ( <> )} @@ -59,10 +59,10 @@ export default function GenericNode({ data }) {
(word[0].toUpperCase() + word.slice(1).toLowerCase())) .join(''); }; + + export function snakeToNormalCase(str: string){ + return str + .split('_') + .map((word, index) => {if(index === 0){return word[0].toUpperCase() + word.slice(1).toLowerCase()} return word.toLowerCase()}) + .join(' '); + }; export function roundNumber(x, decimals){ return Math.round(x * Math.pow(10, decimals))/Math.pow(10, decimals)