Add initial logic for 'boards'

This commit is contained in:
2026-03-17 20:04:38 +00:00
parent 3240560a0b
commit 64bc5b979d
8 changed files with 79 additions and 11 deletions

View File

@@ -9,11 +9,11 @@ class LocationStore {
data = $state<LocationRecord[]>([]);
loaded = $state(false);
async init() {
async init(fetcher = fetch) {
if (this.loaded) return;
try {
const res = await fetch('/api/tiplocs');
const res = await fetcher('/api/tiplocs');
this.data = await res.json();
this.loaded = true;
} catch (err) {
@@ -21,6 +21,18 @@ class LocationStore {
}
}
find(id: string | null): LocationRecord | undefined {
if (!id) return undefined;
const query = id.toUpperCase().trim();
console.log(query);
return this.data.find((loc) => {
return loc.t === query || loc.c === query;
});
}
}
export const LOCATIONS = new LocationStore();