31 lines
761 B
TypeScript
31 lines
761 B
TypeScript
import { type ClassValue, clsx } from 'clsx';
|
|
import { twMerge } from 'tailwind-merge';
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs));
|
|
}
|
|
|
|
export function formatPhoneNumber(phone: string): string {
|
|
const cleaned = phone.replace(/\D/g, '');
|
|
const match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/);
|
|
if (match) {
|
|
return `(${match[1]}) ${match[2]}-${match[3]}`;
|
|
}
|
|
return phone;
|
|
}
|
|
|
|
export function formatCurrency(amount: number): string {
|
|
return new Intl.NumberFormat('en-US', {
|
|
style: 'currency',
|
|
currency: 'USD',
|
|
}).format(amount);
|
|
}
|
|
|
|
export function slugify(text: string): string {
|
|
return text
|
|
.toLowerCase()
|
|
.replace(/[^\w\s-]/g, '')
|
|
.replace(/[\s_-]+/g, '-')
|
|
.replace(/^-+|-+$/g, '');
|
|
}
|