Small fixes
This commit is contained in:
parent
e222c8966a
commit
cb1e3060fd
@ -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>
|
||||
|
@ -7,6 +7,10 @@ export const DELETE = (async ({ params }) => {
|
||||
if (isNaN(problemId)) {
|
||||
throw error(400, 'Invalid problem');
|
||||
}
|
||||
try {
|
||||
await db.problem.delete({ where: { id: problemId } });
|
||||
} catch {
|
||||
return json({ success: false });
|
||||
}
|
||||
return json({ success: true });
|
||||
}) satisfies RequestHandler;
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user