update state management
This commit is contained in:
@@ -1,24 +1,24 @@
|
||||
import { updateConfig, getConfigFiles } from '$api/serverService';
|
||||
import type { Actions } from './$types';
|
||||
import type { Actions, RequestEvent } from './$types';
|
||||
import { checkAuth } from '$api/authService';
|
||||
import { getTracks } from '$api/lookupService';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
|
||||
export const load = async ({ params }) => {
|
||||
const isAuth = await checkAuth();
|
||||
export const load = async (event) => {
|
||||
const isAuth = await checkAuth(event);
|
||||
if (!isAuth) return redirect(308, '/login');
|
||||
const config = await getConfigFiles(params.id);
|
||||
const tracks = await getTracks();
|
||||
const config = await getConfigFiles(event, event.params.id);
|
||||
const tracks = await getTracks(event);
|
||||
return {
|
||||
id: params.id,
|
||||
id: event.params.id,
|
||||
config,
|
||||
tracks
|
||||
};
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
event: async ({ request }) => {
|
||||
const formData = await request.formData();
|
||||
event: async (event: RequestEvent) => {
|
||||
const formData = await event.request.formData();
|
||||
const id = formData.get('id') as string;
|
||||
const object: any = {};
|
||||
formData.forEach((value, key) => {
|
||||
@@ -32,7 +32,7 @@ export const actions = {
|
||||
object[key] = value != '' && !Number.isNaN(+value) ? +value : value;
|
||||
}
|
||||
});
|
||||
await updateConfig(id, 'event.json', object, true, true);
|
||||
await updateConfig(event, id, 'event.json', object, true, true);
|
||||
redirect(303, '/dashboard');
|
||||
}
|
||||
} satisfies Actions;
|
||||
|
||||
Reference in New Issue
Block a user