about summary refs log tree commit diff
path: root/assets/src/components/share/Request.svelte
blob: a5e77e70bc02e1192d23ba7adfa97a19685e3622 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<script lang="ts">
    import {
        acceptIncomingRequest,
        declineIncomingRequest,
        IncomingRequestState,
    } from "../../models/incoming_request";
    import type { IncomingRequest } from "../../models/incoming_request";
    import CheckIcon from "../icons/CheckIcon.svelte";
    import CloseIcon from "../icons/CloseIcon.svelte";

    export let request: IncomingRequest;
    const state = request.state;

    const time = `${request.info.receivedAt.getHours()}:${request.info.receivedAt.getMinutes()}`;

    async function accept() {
        acceptIncomingRequest(request);
    }

    function decline() {
        declineIncomingRequest(request);
    }
</script>

<!-- TODO: Replace placeholder values and show IP instead of token. -->
<ul class="request">
    {#if $state === IncomingRequestState.WAITING}
        <div class="buttons">
            <div class="round-button" on:click={accept}>
                <CheckIcon color="white" />
            </div>
            <div class="plain-button" on:click={decline}>
                <CloseIcon color="black" />
            </div>
        </div>
    {/if}

    <li>Requested at {time}</li>
    <li class="ip">{request.info.token}</li>
    <li>Trusowo, Russia</li>
    <li>Firefox 89</li>

    {#if $state === IncomingRequestState.IN_FLIGHT}
        Transferring...
    {:else if $state === IncomingRequestState.DONE}
        Done!
    {:else if $state === IncomingRequestState.DECLINED}
        Declined.
    {/if}
</ul>

<style>
    .request {
        background-color: white;
        color: #626262;
        padding: 17px 20px;
        font-size: 12px;
        line-height: 1.5rem;
        position: relative;
    }

    ul {
        list-style-type: none;
    }

    .ip {
        line-height: 1.75rem;
        font-size: 16px;
        color: black;
    }

    .buttons {
        position: absolute;
        right: 20px;
        display: flex;
        justify-content: space-between;
        width: 50px;
        align-items: center;
    }

    .round-button {
        width: 24px;
        height: 24px;
        border-radius: 100%;
        background-color: black;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .plain-button {
        display: flex;
        align-items: center;
    }
</style>