Create a new test when visiting /test/

This commit is contained in:
nemunaire 2025-10-20 12:27:49 +07:00
commit 8bf3b500d9
3 changed files with 24 additions and 1 deletions

View file

@ -0,0 +1,21 @@
import { error, redirect, type Load } from "@sveltejs/kit";
import { createTest as apiCreateTest } from "$lib/api";
export const prerender = false;
export const ssr = false;
export const load: Load = async ({}) => {
let response;
try {
response = await apiCreateTest();
} catch (err) {
error(err.response.status, err.message);
}
if (response.response.ok) {
redirect(302, `/test/${response.data.id}`);
} else {
error(response.response.status, response.error);
}
};

View file

@ -132,7 +132,7 @@
<!-- Test Again Button --> <!-- Test Again Button -->
<div class="row"> <div class="row">
<div class="col-12 text-center"> <div class="col-12 text-center">
<a href="/" class="btn btn-primary btn-lg"> <a href="/test/" class="btn btn-primary btn-lg">
<i class="bi bi-arrow-repeat me-2"></i> <i class="bi bi-arrow-repeat me-2"></i>
Test Another Email Test Another Email
</a> </a>

View file

@ -0,0 +1,2 @@
export const prerender = false;
export const ssr = false;