aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/punks.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/punks.js')
0 files changed, 0 insertions, 0 deletions
re>
3403bf5c ^

cf9ccd67 ^
d309ab34 ^
3403bf5c ^

cf9ccd67 ^

3403bf5c ^









a97c7a00 ^

3403bf5c ^








cf9ccd67 ^

3403bf5c ^
66740dea ^
3403bf5c ^
a97c7a00 ^







3403bf5c ^
f4a66ec1 ^
3403bf5c ^

a97c7a00 ^


3403bf5c ^
a97c7a00 ^

d309ab34 ^
3403bf5c ^


a97c7a00 ^















3403bf5c ^































d309ab34 ^
3403bf5c ^


d309ab34 ^
3403bf5c ^

d309ab34 ^
d309ab34 ^
d309ab34 ^
3403bf5c ^






3b7e5e34 ^
3403bf5c ^


f4a66ec1 ^
3403bf5c ^












f4a66ec1 ^


3403bf5c ^




a97c7a00 ^














f4a66ec1 ^
a97c7a00 ^
3403bf5c ^


f4a66ec1 ^
3403bf5c ^





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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
        

                                                            
                                              
                                                  

                                                                  

                        









                                                                                

                                                                                                           








                                                                               

         
                       
                                     
                     







                                                                                                                                      
                                            
 

                                                                                      


                                                                                                                                                              
                                                                                          

                                                                                                                              
                                                                      


                                                                 















                                                                                                                                                   































                                                                                                                                                    
                                                              


                                                                                                                  
                                                                      

                                                                                                               
                                                              
                                                      
                                              






                                                                        
 


                                                                                                    
                                                                  












                                                                                                                                               


                                                              




                                    














                                                                                                                         
                                              
                                    


                               
      





                            
<script>
	import { onMount } from 'svelte';
	import { Icon, Avatar, Balance, Feed } from '$comp';
	import { t } from '$lib/translations';
	import { f, sat, sats } from '$lib/utils';
	import { sign, send, encrypt, decrypt } from '$lib/nostr';
	import { browser } from '$app/environment';

	export let data;
	let { messages, notes, invoices, sent, received, subject, user } = data;

	let keys = new Set();
	let latest = [];
	let i = 0;

	onMount(async () => {
		if (!browser) return;
		while (latest.length < 3 && i < messages.length) {
			let event = messages[i];
			let k = event.author.id === user.id ? event.recipient.pubkey : event.author.pubkey;
			if (!keys.has(k)) {
				keys.add(k);
				event.content = await decrypt({ event, user });
				if (event.content) latest.push(event);
			}
			i++;
		}

		latest = latest;
	});
</script>

<div class="space-y-8">
	{#if user?.id === subject.id}
		<div>
			<div class="flex justify-center lg:justify-start">
				<Balance {user} />
			</div>
			{#if !user.balance}
				<div class="space-y-8 mt-8">
					<p class="text-secondary text-lg">
						Welcome! Your account balance is empty. You can start by making a deposit or by asking
						someone to pay you.
					</p>

					<div class="flex gap-4 justify-center w-full">
						<a href={`/${user.username}/receive`}>
							<button
								class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60 bg-black text-white"
							>
								<div class="mx-auto flex">
									<Icon icon="numpad" style="my-auto h-6 mr-2 invert" />
									<div class="my-auto mt-1">Request Payment</div>
								</div>
							</button>
						</a>

						{#if user.eligible}
							<a href={`/buy`}>
								<button class="rounded-full border py-3 px-6 font-bold hover:opacity-80 flex w-60">
									<div class="mx-auto flex">
										<!-- <Icon icon="plus" style="my-auto h-6 mr-2" /> -->

										<img
											src="/images/bitcoin.svg"
											class="w-8 border-4 border-transparent mr-2"
											alt="Bitcoin"
										/>
										<div class="my-auto mt-1">Buy Bitcoin</div>
									</div>
								</button>
							</a>
						{/if}
					</div>
				</div>
			{/if}
		</div>
	{/if}

	{#if invoices.length}
		<div>
			<h1 class="text-secondary text-xl">Invoices</h1>
			{#each invoices as { amount, currency, rate, request: { requester, recipient }, hash }}
				{@const requested = user.username === requester?.username}
				<a href={`/${recipient.username}/invoice/${hash}` + (requested ? '/tip' : '')}>
					<div class="border-b p-2 last:border-b-0 hover:bg-gray-100">
						<div class="flex gap-2">
							<div>
								{#if requested}
									<div class="flex">
										<Avatar user={recipient} size={20} />
										<div class="my-auto text-left">
											<p class="text-secondary">{$t('payments.invoiceFrom')}</p>
											<p class="ml-1 text-lg break-words">{recipient.username}</p>
										</div>
									</div>
								{:else}
									<div class="flex">
										<Avatar user={requester} size={20} />
										<div class="my-auto text-left">
											<p class="text-secondary">{$t('payments.awaiting')}</p>
											<p class="ml-1 text-lg break-words">{requester.username}</p>
										</div>
									</div>
								{/if}
							</div>
							<div class="whitespace-nowrap my-auto ml-auto flex gap-2">
								<div class="font-bold">
									{f(amount * (rate / sats), currency)}
								</div>

								<div class="text-secondary">{sat(amount)}</div>
							</div>
						</div>
					</div>
				</a>
			{/each}
		</div>
	{/if}
	{#if received.length}
		<div>
			<h1 class="text-secondary text-xl">Requests</h1>

			{#each received as { id, invoice, memo, requester: r }}
				<a href={`/${user.username}/receive/${id}`}>
					<div class="border-b p-2 last:border-b-0 hover:bg-gray-100">
						<div class="flex">
							<div>
								<div class="flex">
									<Avatar user={r} size={20} />
									<div class="my-auto text-left">
										<p class="ml-1 text-lg break-words">{r.username}</p>
										<p class="ml-1 text-secondary">{memo}</p>
									</div>
								</div>
							</div>
							<div class="whitespace-nowrap my-auto ml-auto flex gap-2">
								<button class="rounded-full border py-2 px-4 font-bold hover:opacity-80 w-full"
									>Invoice</button
								>
							</div>
						</div>
					</div>
				</a>
			{/each}
		</div>
	{/if}

	{#if latest.length && user.id === subject.id}
		<div class="relative">
			{#each latest as { content, pubkey, author, recipient }}
				{@const user = author.id === user.id ? recipient : author}
				<a href={`/${user.username}/messages`}>
					<div class="flex hover:bg-gray-100 p-4 rounded-2xl">
						<div class="my-auto">
							<Avatar {user} size={'20'} disabled={true} />
						</div>
						<div class="my-auto truncate">
							<div class="my-auto ml-1 text-lg font-bold">{user.username}</div>
							<div class="my-auto ml-1 text-secondary text-lg truncate">
								{content}
							</div>
						</div>
					</div>
				</a>
			{/each}
		</div>
	{/if}
</div>

<style>
	h1 {
		@apply mb-2;
	}
</style>