feat: add events app + "multi-tenants" aka multi-events

This commit is contained in:
2026-09-16 00:03:26 +02:00
parent b5c2cdc037
commit 8b9c254fd2
62 changed files with 1343 additions and 362 deletions
+18 -2
View File
@@ -37,12 +37,28 @@ interface SubmissionStats {
// API Service Class
export class ApiService {
private eventPath: string | null = null
// Every endpoint this service calls is event-scoped (/api/events/{event_path}/...),
// so the owning page sets this once (via provideEventPath()'s value) before any
// request is made, instead of threading eventPath through every method signature.
setEventPath(eventPath: string) {
this.eventPath = eventPath
}
private buildUrl(endpoint: string): string {
if (!this.eventPath) {
throw new Error('ApiService.setEventPath() must be called before making requests')
}
return `${API_BASE_URL}/events/${this.eventPath}${endpoint}`
}
private async request<T>(
endpoint: string,
options: RequestInit = {}
): Promise<ApiResponse<T>> {
try {
const response = await fetch(`${API_BASE_URL}${endpoint}`, {
const response = await fetch(this.buildUrl(endpoint), {
headers: {
'Content-Type': 'application/json',
...options.headers,
@@ -76,7 +92,7 @@ export class ApiService {
formData: FormData
): Promise<ApiResponse<T>> {
try {
const response = await fetch(`${API_BASE_URL}${endpoint}`, {
const response = await fetch(this.buildUrl(endpoint), {
method: 'POST',
body: formData,
})