creddy/src/views/Home.svelte

49 lines
1.6 KiB
Svelte
Raw Normal View History

2022-11-23 17:11:44 -08:00
<script>
2023-04-25 08:49:00 -07:00
import { onMount } from 'svelte';
2022-12-22 21:50:09 -08:00
import { invoke } from '@tauri-apps/api/tauri';
2023-04-23 22:29:12 -07:00
2023-04-25 08:49:00 -07:00
import { appState } from '../lib/state.js';
2023-04-24 12:05:11 -07:00
import { navigate } from '../lib/routing.js';
2023-04-24 22:16:25 -07:00
import Nav from '../ui/Nav.svelte';
2023-04-23 22:29:12 -07:00
import Icon from '../ui/Icon.svelte';
2023-04-25 08:49:00 -07:00
import Link from '../ui/Link.svelte';
2022-11-23 17:11:44 -08:00
import vaultDoorSvg from '../assets/vault_door.svg?raw';
2022-11-23 17:11:44 -08:00
// onMount(async () => {
// // will block until a request comes in
// let req = await $appState.pendingRequests.get();
// $appState.currentRequest = req;
// navigate('Approve');
// });
2022-11-23 17:11:44 -08:00
</script>
2022-12-22 21:50:09 -08:00
<Nav position="fixed">
<h2 slot="title" class="text-3xl font-bold">Creddy</h2>
</Nav>
2022-12-22 21:50:09 -08:00
<div class="flex flex-col h-screen items-center justify-center p-4 space-y-4">
2023-04-25 22:10:14 -07:00
{#await invoke('get_session_status') then status}
{#if status === 'locked'}
{@html vaultDoorSvg}
2023-04-25 22:10:14 -07:00
<h2 class="text-2xl font-bold">Creddy is locked</h2>
2023-04-29 10:01:45 -07:00
<Link target="Unlock" hotkey="Enter" class="w-64">
<button class="btn btn-primary w-full">Unlock</button>
2023-04-25 22:10:14 -07:00
</Link>
{:else if status === 'unlocked'}
{@html vaultDoorSvg}
2023-04-25 22:10:14 -07:00
<h2 class="text-2xl font-bold">Waiting for requests</h2>
{:else if status === 'empty'}
{@html vaultDoorSvg}
<h2 class="text-2xl font-bold">No credentials found</h2>
2023-04-29 10:01:45 -07:00
<Link target="EnterCredentials" hotkey="Enter" class="w-64">
<button class="btn btn-primary w-full">Enter Credentials</button>
2023-04-25 22:10:14 -07:00
</Link>
{/if}
{/await}
</div>