Create a new test when visiting /test/
This commit is contained in:
parent
0107858ee6
commit
8bf3b500d9
3 changed files with 24 additions and 1 deletions
21
web/src/routes/test/+page.ts
Normal file
21
web/src/routes/test/+page.ts
Normal 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);
|
||||
}
|
||||
};
|
||||
|
|
@ -132,7 +132,7 @@
|
|||
<!-- Test Again Button -->
|
||||
<div class="row">
|
||||
<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>
|
||||
Test Another Email
|
||||
</a>
|
||||
|
|
|
|||
2
web/src/routes/test/[test]/+page.ts
Normal file
2
web/src/routes/test/[test]/+page.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export const prerender = false;
|
||||
export const ssr = false;
|
||||
Loading…
Add table
Add a link
Reference in a new issue