feat: initial dashboard user delete

This commit is contained in:
EETagent 2022-12-30 23:15:26 +01:00
parent 07ccd44d56
commit 233da205f3

View file

@ -1,11 +1,12 @@
<script lang="ts"> <script lang="ts">
import { apiListCandidates } from '$lib/@api/admin'; import { apiDeleteCandidate, apiListCandidates } from '$lib/@api/admin';
import Home from '$lib/components/icons/Home.svelte'; import Home from '$lib/components/icons/Home.svelte';
import TextField from '$lib/components/textfield/TextField.svelte'; import TextField from '$lib/components/textfield/TextField.svelte';
import type { CandidatePreview } from '$lib/stores/candidate'; import type { CandidatePreview } from '$lib/stores/candidate';
import CreateCandidateModal from '$lib/components/admin/CreateCandidateModal.svelte'; import CreateCandidateModal from '$lib/components/admin/CreateCandidateModal.svelte';
import Fuse from 'fuse.js'; import Fuse from 'fuse.js';
import type { PageServerData } from './$types'; import type { PageServerData } from './$types';
import Delete from '$lib/components/button/Delete.svelte';
export let data: PageServerData; export let data: PageServerData;
@ -64,6 +65,11 @@
candidatesTable = fuse.search(searchValue).map((result) => result.item); candidatesTable = fuse.search(searchValue).map((result) => result.item);
} }
}; };
const deleteCandidate = async (id: number | undefined) => {
if (id) await apiDeleteCandidate(id);
getCandidates();
}
</script> </script>
{#if createCandidateModal} {#if createCandidateModal}
@ -118,6 +124,7 @@
Příjmení Příjmení
</th> </th>
<th scope="col" class="px-6 py-4 text-sm font-medium text-gray-900"> Obor </th> <th scope="col" class="px-6 py-4 text-sm font-medium text-gray-900"> Obor </th>
<th scope="col" class="px-6 py-4 text-sm font-medium text-gray-900" />
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -140,6 +147,9 @@
<td class="whitespace-nowrap px-6 py-4 text-sm text-gray-900"> <td class="whitespace-nowrap px-6 py-4 text-sm text-gray-900">
{candidate.study} {candidate.study}
</td> </td>
<td class="whitespace-nowrap px-6 py-4 text-sm">
<Delete on:delete={async () => await deleteCandidate(candidate.applicationId)} value="Odstranit" />
</td>
</tr> </tr>
{/each} {/each}
</tbody> </tbody>