This commit is contained in:
2025-01-01 14:25:33 +01:00
parent a7e961fc0c
commit f5332411d2
3 changed files with 29 additions and 17 deletions

View File

@@ -43,8 +43,6 @@
let member = $state(event.maxTeamMembers); let member = $state(event.maxTeamMembers);
let schemType = $state(event.schemType); let schemType = $state(event.schemType);
let publicOnly = $state(event.publicSchemsOnly); let publicOnly = $state(event.publicSchemsOnly);
let addReferee: {name: string, id: number}[] = [];
let removeReferee: {name: string, id: number}[] = [];
let errorOpen = $state(false); let errorOpen = $state(false);
let error: any = $state(undefined); let error: any = $state(undefined);
@@ -69,9 +67,7 @@
endDate.diff(dayjs(event.end)) !== 0 || endDate.diff(dayjs(event.end)) !== 0 ||
member !== event.maxTeamMembers || member !== event.maxTeamMembers ||
schemType != event.schemType || schemType != event.schemType ||
publicOnly !== event.publicSchemsOnly || publicOnly !== event.publicSchemsOnly);
addReferee.length > 0 ||
removeReferee.length > 0);
async function del() { async function del() {
@@ -95,8 +91,8 @@
publicSchemsOnly: publicOnly, publicSchemsOnly: publicOnly,
schemType: schemType ?? "null", schemType: schemType ?? "null",
start: startDate, start: startDate,
addReferee: addReferee.map((ref) => ref.id), addReferee: [],
removeReferee: removeReferee.map((ref) => ref.id) removeReferee: []
}; };
try { try {

View File

@@ -43,6 +43,14 @@
async function addReferee() { async function addReferee() {
if (selectedPlayer) { if (selectedPlayer) {
referees = (await $eventRepo.updateEvent(data.event.id.toString(), { referees = (await $eventRepo.updateEvent(data.event.id.toString(), {
deadline: null,
end: null,
maxTeamMembers: null,
name: null,
publicSchemsOnly: null,
removeReferee: null,
schemType: null,
start: null,
addReferee: [selectedPlayer] addReferee: [selectedPlayer]
})).referees; })).referees;
} }
@@ -53,7 +61,15 @@
function removeReferee(id: string) { function removeReferee(id: string) {
return async () => { return async () => {
referees = (await $eventRepo.updateEvent(data.event.id.toString(), { referees = (await $eventRepo.updateEvent(data.event.id.toString(), {
removeReferee: [id] deadline: null,
end: null,
maxTeamMembers: null,
name: null,
publicSchemsOnly: null,
addReferee: null,
schemType: null,
start: null,
removeReferee: [id],
})).referees; })).referees;
} }
} }

View File

@@ -31,15 +31,15 @@ export interface CreateEvent {
} }
export interface UpdateEvent { export interface UpdateEvent {
name?: string; name: string | null;
start?: Dayjs; start: Dayjs | null;
end?: Dayjs; end: Dayjs | null;
deadline?: Dayjs; deadline: Dayjs | null;
maxTeamMembers?: number; maxTeamMembers: number | null;
schemType?: string | null; schemType: string | null;
publicSchemsOnly?: boolean; publicSchemsOnly: boolean | null;
addReferee?: string[]; addReferee: string[] | null;
removeReferee?: string[]; removeReferee: string[] | null;
} }
export class EventRepo { export class EventRepo {