umpires can be added to courts as umpires (removal also)

This commit is contained in:
2026-05-27 21:10:38 +02:00
parent 71c3733363
commit 0c071c0621
10 changed files with 436 additions and 90 deletions
@@ -0,0 +1,48 @@
import { Injectable } from '@angular/core';
import { toSignal } from '@angular/core/rxjs-interop';
import { CourtServiceJudge, db } from 'db';
import { liveQuery } from 'dexie';
import { from } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class CourtServiceJudgeService {
/**
* All service judges (reactive)
*/
readonly umpires = toSignal(
from(liveQuery(() => db.courtServiceJudges.orderBy('courtNo').toArray())),
{ initialValue: [] }
);
/**
* Get by court number (reactive)
*/
getByCourtNo(courtNo: number) {
return toSignal<CourtServiceJudge | undefined>(
liveQuery(() =>
db.courtServiceJudges.where('courtNo').equals(courtNo).first()
),
{ initialValue: undefined }
);
}
/**
* Create / update
*/
async save(item: Omit<CourtServiceJudge, 'id'>): Promise<number> {
return db.courtServiceJudges.add(item as CourtServiceJudge);
}
async update(
id: number,
changes: Partial<CourtServiceJudge>
): Promise<number> {
return db.courtServiceJudges.update(id, changes);
}
async delete(id: number): Promise<void> {
await db.courtServiceJudges.delete(id);
}
}