Untitled

mail@pastecode.io avatar
unknown
typescript
7 months ago
697 B
1
Indexable
Never
import { fail, redirect } from "@sveltejs/kit";
import type { Actions, PageServerLoad } from "./$types";
import { message, superValidate } from "sveltekit-superforms/server";
import { house } from "$lib/schemas";

export const load: PageServerLoad = async ({ locals }) => {
	const session = await locals.getSession();

	// console.log(session);

	if (!session) {
		throw redirect(303, "/register");
	}

	const form = await superValidate(house);

	return { form };
};

export const actions: Actions = {
	default: async ({ request, locals: { supabase } }) => {
		const form = await superValidate(request, house);

		console.log(form);

		if (!form.valid) {
			return fail(400, { form });
		}
	},
};