All files / src/lib utils.ts

83.33% Statements 5/6
50% Branches 2/4
100% Functions 3/3
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                                  83119x             14x 14x 14x         6x    
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
 
// Date formatters now live in @interioring/utils so portal, marketplace, and
// pro-sites all use the same en-IN locale + options. Re-exported here to keep
// existing portal call-site imports stable; new code should import from the
// shared module directly.
export {
	formatDate,
	formatDateLong,
	formatDateTime,
	formatDateTimeLong,
	formatDayMonth,
	formatMonthYear,
} from "@interioring/utils/format/date";
 
export function cn(...inputs: ClassValue[]) {
	return twMerge(clsx(inputs));
}
 
// Indian numbering system formatters are portal-only and stay here.
// 200000 → "2,00,000"
export function formatIndianNumber(value: string | number): string {
	const num =
		typeof value === "string" ? value.replace(/\D/g, "") : String(value);
	Iif (!num) return "";
	return Number(num).toLocaleString("en-IN");
}
 
// "2,00,000" → "200000"
export function parseIndianNumber(value: string): string {
	return value.replace(/,/g, "");
}