Create a new test when visiting /test/
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
46f0c83784
commit
ed5b57ea19
2 changed files with 19 additions and 1 deletions
18
web/src/routes/test/+page.ts
Normal file
18
web/src/routes/test/+page.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { error, redirect, type Load } from "@sveltejs/kit";
|
||||
|
||||
import { createTest as apiCreateTest } from "$lib/api";
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -133,7 +133,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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue