feat(FE): Add formatTitleCaseGeneral helper and update usage

This commit is contained in:
rstubryan
2026-02-09 17:05:35 +07:00
parent 4cf2f77265
commit efec9b6265
2 changed files with 15 additions and 2 deletions
@@ -12,7 +12,11 @@ import {
BaseSalesOrder, BaseSalesOrder,
Marketing, Marketing,
} from '@/types/api/marketing/marketing'; } from '@/types/api/marketing/marketing';
import { formatDate, formatTitleCase } from '@/lib/helper'; import {
formatDate,
formatTitleCase,
formatTitleCaseGeneral,
} from '@/lib/helper';
type MarketingSchemaType = { type MarketingSchemaType = {
customer_id: number | undefined; customer_id: number | undefined;
@@ -119,7 +123,7 @@ export const SalesProductToFieldValues = (
marketing_type: product.marketing_type marketing_type: product.marketing_type
? { ? {
value: product.marketing_type, value: product.marketing_type,
label: formatTitleCase(product.marketing_type), label: formatTitleCaseGeneral(product.marketing_type),
} }
: null, : null,
convertion_unit: product.convertion_unit convertion_unit: product.convertion_unit
+9
View File
@@ -45,6 +45,15 @@ export const formatTitleCase = (value: string) => {
.join(' '); .join(' ');
}; };
export const formatTitleCaseGeneral = (value: string) => {
return value
.toLowerCase()
.replace(/_/g, ' ')
.split(' ')
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
};
export function formatVechicleNumber(value: string): string { export function formatVechicleNumber(value: string): string {
let result = ''; let result = '';
for (let i = 0; i < (value?.length ?? 0); i++) { for (let i = 0; i < (value?.length ?? 0); i++) {