mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
feat(FE-166-169): Slicing UI Penjualan Form dan Client side validation
This commit is contained in:
@@ -2,6 +2,7 @@ import moment from 'moment';
|
||||
import 'moment/locale/id';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
import clsx, { ClassValue } from 'clsx';
|
||||
import { ChangeEvent } from 'react';
|
||||
|
||||
// set locale globally
|
||||
moment.locale('id');
|
||||
@@ -29,6 +30,28 @@ export const formatNumber = (
|
||||
}).format(value);
|
||||
};
|
||||
|
||||
export function formatVechicleNumber(value: string): string {
|
||||
let result = '';
|
||||
for (let i = 0; i < value.length; i++) {
|
||||
const curr = value[i];
|
||||
const prev = value[i - 1];
|
||||
|
||||
// Cek apakah terjadi perpindahan dari huruf ke angka atau angka ke huruf
|
||||
if (i > 0) {
|
||||
const isCurrDigit = /\d/.test(curr);
|
||||
const isPrevDigit = /\d/.test(prev);
|
||||
|
||||
if (isCurrDigit !== isPrevDigit) {
|
||||
result += ' ';
|
||||
}
|
||||
}
|
||||
|
||||
result += curr;
|
||||
}
|
||||
|
||||
return result.trim().replace(/\s+/g, ' ');
|
||||
}
|
||||
|
||||
export const formatCurrency = (
|
||||
value: number | bigint | Intl.StringNumericLiteral,
|
||||
currency = 'IDR',
|
||||
|
||||
Reference in New Issue
Block a user