Files
DatBrowser/resources/js/lib/utils.ts
Matthias Guillitte 070235e011
Some checks failed
Push image to registry / build-image (push) Failing after 3m47s
Added jobRuns on the job page
2025-03-15 17:44:30 +01:00

26 lines
687 B
TypeScript

import type { Updater } from '@tanstack/vue-table'
import type { Ref } from 'vue'
import { type ClassValue, clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
export function valueUpdater<T extends Updater<any>>(updaterOrValue: T, ref: Ref) {
ref.value
= typeof updaterOrValue === 'function'
? updaterOrValue(ref.value)
: updaterOrValue
}
export async function httpApi<T>(route: string): Promise<T> {
let response = await fetch("/api" + route);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
}