sync: Auto-sync from Mikes-MacBook-Air.local at 2026-03-09 08:14:13
Synced files: - Session logs updated - Latest context and credentials - Command/directive updates Machine: Mikes-MacBook-Air.local Timestamp: 2026-03-09 08:14:13 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
69
projects/msp-tools/quote-wizard/frontend/src/lib/utils.ts
Normal file
69
projects/msp-tools/quote-wizard/frontend/src/lib/utils.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { type ClassValue, clsx } from 'clsx';
|
||||
|
||||
/**
|
||||
* Utility function to merge class names
|
||||
* Combines clsx for conditional classes
|
||||
*/
|
||||
export function cn(...inputs: ClassValue[]): string {
|
||||
return clsx(inputs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format currency value
|
||||
*/
|
||||
export function formatCurrency(value: number): string {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'USD',
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: 0,
|
||||
}).format(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format number with commas
|
||||
*/
|
||||
export function formatNumber(value: number): string {
|
||||
return new Intl.NumberFormat('en-US').format(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Debounce function
|
||||
*/
|
||||
export function debounce<T extends (...args: unknown[]) => unknown>(
|
||||
func: T,
|
||||
wait: number
|
||||
): (...args: Parameters<T>) => void {
|
||||
let timeout: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
return function executedFunction(...args: Parameters<T>) {
|
||||
const later = () => {
|
||||
timeout = null;
|
||||
func(...args);
|
||||
};
|
||||
|
||||
if (timeout !== null) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
timeout = setTimeout(later, wait);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate total device count
|
||||
*/
|
||||
export function getTotalDevices(devices: {
|
||||
workstations: number;
|
||||
laptops: number;
|
||||
servers: number;
|
||||
networkDevices: number;
|
||||
mobileDevices: number;
|
||||
}): number {
|
||||
return (
|
||||
devices.workstations +
|
||||
devices.laptops +
|
||||
devices.servers +
|
||||
devices.networkDevices +
|
||||
devices.mobileDevices
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user