feat: migrate to dedicated patch test management
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<script lang="ts">
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
import { Input } from '$lib/components/ui/input';
|
||||
import { Skeleton } from '$lib/components/ui/skeleton';
|
||||
import * as Modal from '$lib/components/ui/dialog';
|
||||
|
||||
type PatchTest = {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
notice_duration_hours: number;
|
||||
expiry_months: number;
|
||||
service_ids: string[];
|
||||
};
|
||||
|
||||
let patchTests = $state<PatchTest[]>([]);
|
||||
let loading = $state(true);
|
||||
let showModal = $state(false);
|
||||
|
||||
async function fetchPatchTests() {
|
||||
loading = true;
|
||||
try {
|
||||
const response = await fetch('/api/admin/patch-tests', {
|
||||
headers: { Authorization: `Bearer ${authStore.currentToken}` }
|
||||
});
|
||||
if (response.ok) {
|
||||
patchTests = await response.json();
|
||||
} else {
|
||||
toast.error('Failed to load patch tests');
|
||||
}
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
$effect(() => {
|
||||
fetchPatchTests();
|
||||
});
|
||||
</script>
|
||||
|
||||
<Card.Root>
|
||||
<Card.Header>
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<Card.Title>Patch Test Management</Card.Title>
|
||||
<Card.Description>Manage patch test requirements.</Card.Description>
|
||||
</div>
|
||||
<Button onclick={() => showModal = true}>Add Patch Test</Button>
|
||||
</div>
|
||||
</Card.Header>
|
||||
<Card.Content>
|
||||
{#if loading}
|
||||
<Skeleton class="h-20 w-full" />
|
||||
{:else}
|
||||
<div class="w-full overflow-x-auto">
|
||||
<table class="w-full table-auto border-collapse text-sm">
|
||||
<thead>
|
||||
<tr class="border-b text-left text-xs text-gray-500">
|
||||
<th class="py-3">Name</th>
|
||||
<th class="py-3">Notice (hrs)</th>
|
||||
<th class="py-3">Expiry (months)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each patchTests as pt}
|
||||
<tr class="border-b">
|
||||
<td class="py-3 font-medium">{pt.name}</td>
|
||||
<td class="py-3">{pt.notice_duration_hours}</td>
|
||||
<td class="py-3">{pt.expiry_months}</td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{/if}
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
<Modal.Root bind:open={showModal}>
|
||||
<Modal.Content>
|
||||
<Modal.Header>
|
||||
<Modal.Title>Add Patch Test</Modal.Title>
|
||||
</Modal.Header>
|
||||
<div class="p-4">
|
||||
<p>Patch test creation modal content goes here...</p>
|
||||
</div>
|
||||
</Modal.Content>
|
||||
</Modal.Root>
|
||||
Reference in New Issue
Block a user