blob: 3db7cc076f9cc5e2f3692499f9b8854af1f1e794 (
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
96
97
98
99
100
101
102
103
104
105
106
|
<!--
@component
A list of the player's past auctions, and their auction stats.
-->
<script lang="ts">
import { cleanId, millisecondsToTime, removeFormattingCode } from '$lib/utils'
import type { CleanMemberProfile, StatItem } from '$lib/APITypes'
import { fetchApi } from '$lib/api'
import Item from '$lib/minecraft/Item.svelte'
import type { MatcherFile } from 'skyblock-assets'
import Username from '$lib/minecraft/Username.svelte'
import Auction from '$lib/Auction.svelte'
import { onMount } from 'svelte'
export let data: CleanMemberProfile
export let stats: StatItem[]
export let pack: MatcherFile
let onlyThisProfile = true
let auctions: any[] = []
let loading = true
let page = 0
let totalPages: number | undefined = undefined
async function updateAuctions() {
loading = true
const thisPage = page
page += 1
const auctionsResponse = await fetchApi(
`playerauctions/${data.member.uuid}?page=${thisPage}`,
fetch
).then(r => r.json())
loading = false
auctions = [...auctions, ...auctionsResponse.auctions]
totalPages = auctionsResponse.pages
}
updateAuctions()
</script>
<div class="auction-stats-and-list-container">
<ul>
{#each stats.sort((a, b) => b.value - a.value) as stat}
<li>
<span class="stat-name">{cleanId(stat.categorizedName)}:</span>
<span class="stat-value">
{#if stat.unit === 'time'}
{millisecondsToTime(stat.value)}
{:else}
{stat.value.toLocaleString()}
{/if}
</span>
</li>
{/each}
</ul>
<div class="player-auctions-list-container">
{#if loading || auctions.length > 0}
<h3>Auctions sold</h3>
{/if}
{#if auctions.length > 0}
<div class="player-auctions-list">
{#each auctions as auction}
{#if !onlyThisProfile || auction.sellerProfileUuid == data.profile.uuid}
<Auction {auction} {pack} />
{/if}
{/each}
</div>
{#if !loading && page != totalPages}
<button on:click={updateAuctions}>Show more</button>
{/if}
{/if}
{#if loading}
Loading...
{/if}
</div>
</div>
<style>
li {
position: relative;
}
ul {
padding-left: 1em;
margin-top: 0.5em;
width: max-content;
}
.auction-stats-and-list-container {
display: grid;
grid-template-columns: 1fr auto;
}
.player-auctions-list {
display: flex;
flex-wrap: wrap;
column-gap: 0.5rem;
row-gap: 0.5rem;
}
.player-auctions-list-container {
margin-top: 0.5em;
margin-left: 0.5em;
}
</style>
|