implemented modifing of tasks of an event

This commit is contained in:
z1glr
2025-01-13 22:22:10 +00:00
parent 0685283007
commit a3c6fd685d
12 changed files with 468 additions and 288 deletions

View File

@@ -9,32 +9,32 @@ export type APICallResult<T extends object> = Response & {
export async function apiCall<K extends object>(
method: "GET",
api: string,
params?: QueryParams,
query?: QueryParams,
): Promise<APICallResult<K>>;
export async function apiCall<K extends object>(
method: "POST" | "PATCH",
method: "POST" | "PATCH" | "PUT",
api: string,
params?: QueryParams,
query?: QueryParams,
body?: object,
): Promise<APICallResult<K>>;
export async function apiCall<K extends object>(
method: "DELETE",
api: string,
params?: QueryParams,
query?: QueryParams,
body?: object,
): Promise<APICallResult<K>>;
export async function apiCall<K extends object>(
method: "GET" | "POST" | "PATCH" | "DELETE",
method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE",
api: string,
params?: QueryParams,
query?: QueryParams,
body?: object,
): Promise<APICallResult<K>> {
let url = window.origin + "/api/" + api;
if (params) {
if (query) {
const urlsearchparams = new URLSearchParams(
Object.fromEntries(
Object.entries(params).map(([key, value]): [string, string] => {
Object.entries(query).map(([key, value]): [string, string] => {
if (typeof value !== "string") {
return [key, value.toString()];
} else {
@@ -109,6 +109,6 @@ export async function getTasks(): Promise<Record<number, Task>> {
return tasks;
} else {
return [];
return {};
}
}