about summary refs log tree commit diff
path: root/assets/src/components/request/RequestStatus.svelte
blob: b4c9ef9714d291d62f9ead1c482e0ae07eae3aaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<script lang="ts">
    import data from "../../stores/data";
    import {
        initializeRequest,
        OwnRequestState,
    } from "../../models/own_request";
    import { startRequestConnection } from "../../network/channel/request_connection";

    const request = initializeRequest();
    const state = request.state;

    startRequestConnection(request);
</script>

<!-- TODO: Bind states of same path together -->
{#if $state === OwnRequestState.PENDING || $state === OwnRequestState.ACKNOWLEDGED}
    <h1>Waiting for a response...</h1>
    <p>
        {#if $state === OwnRequestState.ACKNOWLEDGED}
            Connecting to signaling server...
        {:else}
            The share’s content will become available to you once the sharer
            decides to accept your request.
        {/if}
    </p>
{:else if $state === OwnRequestState.IN_FLIGHT || $state === OwnRequestState.DONE}
    <h1>Your request was <b>accepted!</b></h1>
    {#if $state === OwnRequestState.IN_FLIGHT}
        Transferring...
    {:else}
        <p>Congratulations! You can access the received data below:</p>
        <div class="data">{$data.data}</div>
    {/if}
{:else if $state === OwnRequestState.DECLINED}
    <h1>Your request was <b>declined!</b></h1>
    <p>Sorry! I hope we can still be friends?</p>
{:else}
    <!-- TODO: Handle specific errors -->
    <h1>Eek!</h1>
    <p>An error occured during your request.</p>
{/if}

<style>
    .data {
        font-size: 14px;
        width: 100%;
        border: solid 1px #cccccc;
        padding: 10px 20px;
        box-sizing: border-box;
    }
</style>