add ability to agree with results closes #96

This commit is contained in:
2024-04-16 19:03:30 +01:00
parent f165e9e744
commit 00ddb91a22
4 changed files with 76 additions and 6 deletions

View File

@@ -32,10 +32,11 @@
</script>
<script lang="ts">
import { post } from 'src/lib/requests.svelte';
import { post, showMessage } from 'src/lib/requests.svelte';
import type { Model } from './+page.svelte';
import MessageSimple from 'src/lib/MessageSimple.svelte';
let { model } = $props<{ model: Model; uploadCounter?: number }>();
let { model }: { model: Model } = $props();
let page = $state(0);
let showNext = $state(false);
@@ -59,10 +60,27 @@
getList();
}
});
let userPreceptionMessages: MessageSimple;
// This returns a function that performs the call and does not do the call it self
function userPreception(task: string, agree: number) {
return async function () {
try {
await post('task/agreement', {
id: task,
agreement: agree
});
getList();
} catch (e) {
showMessage(e, userPreception);
}
};
}
</script>
<div>
<h2>Tasks</h2>
<MessageSimple bind:this={userPreceptionMessages} />
<table>
<thead>
<tr>
@@ -116,6 +134,16 @@
{:else}
TODO {task.user_confirmed}
{/if}
{#if task.user_confirmed == -1}
<button type="button" on:click={userPreception(task.id, 1)}>
<span class="bi bi-check"></span>
</button>
{/if}
{#if task.user_confirmed == 1}
<button class="danger" type="button" on:click={userPreception(task.id, -1)}>
<span class="bi bi-x-lg"></span>
</button>
{/if}
{:else}
-
{/if}