Small fixes

This commit is contained in:
orosmatthew 2023-04-29 16:00:50 -04:00
parent e222c8966a
commit cb1e3060fd
3 changed files with 16 additions and 2 deletions

View File

@ -4,6 +4,7 @@
import type { Actions, PageData } from './$types';
let editing = false;
let error = false;
export let data: PageData;
export let form: Actions;
@ -21,11 +22,20 @@
const data = await res.json();
if (data.success) {
goto('/admin/problems');
} else {
error = true;
}
}
</script>
<h1 style="text-align:center" class="mb-4">{data.problemData.friendlyName}</h1>
{#if error}
<div class="alert alert-danger">
Error deleting problem (Is it being used in any submissions?)
</div>
{/if}
<div class="row">
<div class="col-6">
<a href="/admin/problems" class="btn btn-outline-primary">Back</a>

View File

@ -7,6 +7,10 @@ export const DELETE = (async ({ params }) => {
if (isNaN(problemId)) {
throw error(400, 'Invalid problem');
}
await db.problem.delete({ where: { id: problemId } });
try {
await db.problem.delete({ where: { id: problemId } });
} catch {
return json({ success: false });
}
return json({ success: true });
}) satisfies RequestHandler;

View File

@ -29,7 +29,7 @@
<a href="/admin/submissions" class="mb-3 btn btn-outline-primary">All Submissions</a>
<table class="table table-bordered table-hover">
<table class="table table-bordered">
<thead>
<tr>
<th>Team</th>