refactor part 1

This commit is contained in:
2026-06-23 22:17:01 -04:00
parent 214cf50908
commit d5bb7ff24f
18 changed files with 508 additions and 398 deletions

View File

@@ -1,15 +1,7 @@
export const BASE = import.meta.env.DEV ? 'http://10.69.5.23:3000' : ''
export const BASE = import.meta.env.DEV ? 'http://10.69.5.23' : ''
export type DataRow = Record<string, number | string | null>
export async function fetchDaily(start?: string, end?: string): Promise<DataRow[]> {
const params = new URLSearchParams()
if (start) params.set('start', start)
if (end) params.set('end', end)
const res = await fetch(`/api/daily?${params}`)
return res.json()
}
async function get<T>(path: string, params: Record<string, string> = {}): Promise<T> {
const url = new URL(`${BASE}${path}`, window.location.origin)
Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v))