75 lines
2.1 KiB
Svelte
75 lines
2.1 KiB
Svelte
<script>
|
|
import { onMount } from 'svelte';
|
|
import { draw, fade } from 'svelte/transition';
|
|
import { emit } from '@tauri-apps/api/event';
|
|
import { invoke } from '@tauri-apps/api/tauri';
|
|
|
|
import { appState } from '../lib/state.js';
|
|
import { navigate } from '../lib/routing.js';
|
|
import ErrorAlert from '../ui/ErrorAlert.svelte';
|
|
import Icon from '../ui/Icon.svelte';
|
|
import Link from '../ui/Link.svelte';
|
|
|
|
let success = false;
|
|
let error = null;
|
|
|
|
async function respond() {
|
|
let response = {
|
|
id: $appState.currentRequest.id,
|
|
approval: 'Approved',
|
|
};
|
|
|
|
try {
|
|
await invoke('respond', {response});
|
|
success = true;
|
|
$appState.currentRequest = null;
|
|
window.setTimeout(() => navigate('Home'), 1000);
|
|
}
|
|
catch (e) {
|
|
error = e;
|
|
}
|
|
|
|
}
|
|
|
|
onMount(respond);
|
|
</script>
|
|
|
|
<style>
|
|
:global(body) {
|
|
overflow: hidden;
|
|
}
|
|
</style>
|
|
|
|
{#if error}
|
|
<div class="flex flex-col h-screen items-center justify-center m-auto max-w-lg">
|
|
<ErrorAlert>
|
|
{error}
|
|
<svelte:fragment slot="buttons">
|
|
<Link target="Home">
|
|
<button class="btn btn-sm bg-transparent hover:bg-[#cd5a5a] border border-error-content text-error-content">
|
|
Ok
|
|
</button>
|
|
</Link>
|
|
</svelte:fragment>
|
|
</ErrorAlert>
|
|
</div>
|
|
{:else if success}
|
|
<div class="flex flex-col h-screen items-center justify-center max-w-max m-auto">
|
|
<svg xmlns="http://www.w3.org/2000/svg" class="w-36 h-36" fill="none" viewBox="0 0 24 24" stroke-width="1" stroke="currentColor">
|
|
<path in:draw="{{duration: 500}}" stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
</svg>
|
|
|
|
|
|
<div in:fade="{{delay: 200, duration: 300}}" class="text-2xl font-bold">Approved!</div>
|
|
</div>
|
|
{/if}
|
|
|
|
|
|
|
|
<!--
|
|
{#if error}
|
|
<div class="text-red-400">{error}</div>
|
|
{:else}
|
|
<h1 class="text-4xl text-gray-300">Approved!</h1>
|
|
{/if}
|
|
--> |