From 897855e10a5e184a64ea70e5cfd381b021b5788a Mon Sep 17 00:00:00 2001 From: abefernan <44572727+abefernan@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:14:39 +0200 Subject: [PATCH] Improve prettyFieldName --- lib/form.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/form.ts b/lib/form.ts index b156d1b..9982863 100644 --- a/lib/form.ts +++ b/lib/form.ts @@ -8,7 +8,8 @@ import { FieldSchemaInput } from "@/components/forms/CreateTxForm/Fields/types"; import { z } from "zod"; export const prettyFieldName = (fieldName: string) => { - const splitName = fieldName.split(/(?=[A-Z])/).join(" "); + const truncatedName = fieldName.slice(fieldName.indexOf(".", "msgs.".length) + 1); + const splitName = truncatedName.split(/(?=[A-Z])/).join(" "); const capitalizedName = splitName.charAt(0).toUpperCase() + splitName.slice(1); return capitalizedName;