Add complete project files
This commit is contained in:
30
lib/utils.ts
Executable file
30
lib/utils.ts
Executable file
@@ -0,0 +1,30 @@
|
||||
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, '');
|
||||
}
|
||||
Reference in New Issue
Block a user