38 lines
786 B
TypeScript
38 lines
786 B
TypeScript
import { type ClassValue, clsx } from 'clsx';
|
|
import { twMerge } from 'tailwind-merge';
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs));
|
|
}
|
|
|
|
export function formatCurrency(amount: number) {
|
|
return new Intl.NumberFormat('en-IN', {
|
|
style: 'currency',
|
|
currency: 'INR',
|
|
}).format(amount);
|
|
}
|
|
|
|
export function formatDate(date: string | Date) {
|
|
return new Date(date).toLocaleDateString('en-IN', {
|
|
year: 'numeric',
|
|
month: 'long',
|
|
day: 'numeric',
|
|
});
|
|
}
|
|
|
|
export function generateSlug(text: string) {
|
|
return text
|
|
.toLowerCase()
|
|
.replace(/[^\w ]+/g, '')
|
|
.replace(/ +/g, '-');
|
|
}
|
|
|
|
export function generateSKU() {
|
|
return (
|
|
'SKU-' +
|
|
Date.now() +
|
|
'-' +
|
|
Math.random().toString(36).substr(2, 9).toUpperCase()
|
|
);
|
|
}
|