dress/resources/js/lib/utils.ts

16 lines
503 B
TypeScript

import type { InertiaLinkProps } from '@inertiajs/react';
import { clsx } from 'clsx';
import type { ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function toUrl(url: InertiaLinkProps['href']): string {
if (!url) return '';
if (typeof url === 'string') return url;
if (typeof url === 'object' && url !== null && 'url' in url) return url.url as string;
return String(url);
}